【问题标题】:TinyMCE custom toolbar button eventTinyMCE 自定义工具栏按钮事件
【发布时间】:2022-12-23 18:01:37
【问题描述】:

我必须访问按钮的onClick event,类似于event.target。将按钮添加到工具栏时,我们有 onAction 处理程序,它不公开 onClick event 但只有 isEnabledsetEnabled 方法。我可以访问window.event,但已弃用。所以代码会是这样的:

editor.ui.registry.addButton('button', {
    text: 'Button text',
    icon: 'icon',
    onAction: (api:ToolbarButtonInstanceApi) => { // Here I have access to only button 
                                                  //api, but I need access to event as 
                                                  //well so I can use it as event.currentTarget
    },
});```

How could I access to `onClick event`?

【问题讨论】:

    标签: events onclick tinymce toolbar


    【解决方案1】:

    我也一直在研究这个,因为我需要做类似的事情,或者至少找到一种在单击时访问按钮节点的方法,到目前为止,我还没有想出任何可以在 onAction 处理程序中使用的东西,并且尝试在该箭头函数内访问 .this 将为您提供全局窗口详细信息。我觉得一定有办法!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 2016-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多