最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to move toolbox from workspace in Google Blockly to another zone or div? - Stack Overflow

programmeradmin9浏览0评论

[

So, I need to move flyoutToolBox panel with blocks (yellow) to left div(red) ( I am using React js + ant design components)

But I have problem, because

Blockly.inject

command init this toolbox into the workspace automatically. Are there some ways to implement my idea and will I have problems with dragging and moving blocks from the left panel? I was trying to find out it by searching official documentatioт,but in vain.

BlocklyWorkspace.jsx

import React, { useEffect, useRef } from 'react';
import * as Blockly from 'blockly'; // Импортируем Blockly как объект
import 'blockly/blocks';
import 'blockly/javascript';
import './BlocklyWorkspace.css';
const BlocklyEditor = () => {
  const blocklyDiv = useRef(null);

  useEffect(() => {
    // Инициализация Blockly
    if (blocklyDiv.current) {
      Blockly.inject(blocklyDiv.current, {
        renderer: 'zelos', 
        toolbox: `
          <xml xmlns=";>
            <block type="controls_if"></block>
            <block type="logic_compare"></block>
            <block type="math_number"></block>
            <block type="text"></block>
          </xml>W
        `
      });
    }


  }, []);

  return (
    <div
      ref={blocklyDiv}
      style={{ height: '100vh', width: '100vw' }}
    >

    </div>
  );
};

export default BlocklyEditor;

BlockPanel.jsx


const BlockPanel = ({children}) => {

  return (
    <Layout>
>!       <Sider width={145} collapsedWidth={51} collapsible collapsed={collapsed} onCollapse={(value) => setCollapsed(value)} className='categories'>
>!         <Menu theme="dark" defaultSelectedKes={[activeCategory.id]} mode="inline" items={menuItems} className='categ'/>
>!       </Sider>
      **<Sider width={250} className='blocks'>
          //this is the div where I need to move a toolbox
      </Sider>**
      <Workspace>
          <FileManager/>
      </Workspace>

    </Layout>
  );
};

export default BlockPanel;
发布评论

评论列表(0)

  1. 暂无评论