Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BraftEditor.use 实现自定义的行内组件 entnty ,entnty 在输出的 html 中 onClick 事件不执行 #949

Open
lindsay135 opened this issue Nov 7, 2021 · 1 comment

Comments

@lindsay135
Copy link

使用 BraftEditor.use 方法给富文本编辑器添加中间件,实现自定义的行内组件 entnty ,entnty 在输出的 html 中 onClick 事件不执行

在线代码及主要代码如下:

在线代码地址:
https://codesandbox.io/s/youthful-rgb-rdmkv?file=/src/index.js:1741-1748

主要代码如下:

BraftEditor.use([
  {
    type: "entity",
    name: "AT",
    control: (props) => {
      return {
        key: "wxAT",
        type: "component",
        component: (
          <span onMouseDown={(e) => { e.stopPropagation() }}>
            <button>@</button>
          </span>
        )
      }
    },
    mutability: "IMMUTABLE",
    data: {
      text: '111'
    },
    component: (props) => {
      return (
        <span className="keyboard-item-wxat" style={{color: 'red'}}>
          {props.children}
        </span>
      );
    },
    **exporter: (entityObject, originalText) => {
      return <span style={{color: 'blue'}}>
        <span className="control-item button" onClick={() => alert(123)}>{originalText}</span>
        </span>
    }**
  };
])

富文本内容生成 html 预览时,期望效果是点击事件有反应

期望点击后有弹框弹出,实际效果是点击时没有弹框

11png

@lindsay135
Copy link
Author

希望大佬们能帮我解决下问题,感谢感谢感谢!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant