从 tinyMCE 获取文本内容 table

Getting the text content from a tinyMCE table

我的 tinyMCE 编辑器中有一个 table,我想 select 并按以下方式复制文本内容。

如果我 select 并从 table 复制 'one and two',我应该得到文本,
"one two".

如果我复制所有 table 内容,我应该得到文本,
“一二
三四

有什么方法可以完成吗? 我尝试使用 ed.getContent({format: 'text'}),但它从编辑器返回所有内容。

如果您只想获取当前选择(而不是编辑器的所有内容),您需要使用选择 API 来实现。

例如:

tinymce.activeEditor.selection.getContent({format: 'text'});

...或...

editor.selection.getContent({format: 'text'});