【问题标题】:How to insert text in TinyMCE Editor where the cursor is?如何在光标所在的 TinyMCE 编辑器中插入文本?
【发布时间】:2018-02-14 03:53:06
【问题描述】:

我正在尝试在我的项目中使用 angular2-tinymce 库。我已成功将 tinymce 集成到我的模块中。但我找不到任何方法可以从 tinymce 编辑器中光标所在的位置插入文本。

// in add-progress-note.module.ts file
@NgModule({
  declarations: [
    AddProgressNotePage,
  ],
  imports: [
    IonicPageModule.forChild(AddProgressNotePage),
    TinymceModule.withConfig({
      menubar: false,
      plugins: ['textcolor'],
      toolbar: 'forecolor',
      resize: false,
      statusbar: false
    })
  ]
})

// in add-progress-note.html file           
<ion-row class="note-editor" id="noteArea">
            <app-tinymce class="note-input-textarea" [(ngModel)]='noteText' (ngModelChange)="onChangeNote()"></app-tinymce>
</ion-row>

// in add-progress-note.ts file
  onChangeNote(): void {
    console.log(this.noteText);
  }

我看到了这些链接:link1link2。但我无法在 TinymceModule

setup 配置中编写回调

如何在我的代码中合并在tinymce编辑器中从光标插入的文本?

【问题讨论】:

  • 您是否尝试通过工具栏按钮执行此操作?一份菜单?还有什么?什么会触发这种插入?
  • 我的页面中有一个按钮,就在 tinymce 编辑器的下方。当我单击按钮时,我将生成一个文本,我想将此文本附加到光标所在的 tinymce 编辑器中。

标签: angular ionic-framework tinymce


【解决方案1】:

我可以使用以下方法在 tinymce 编辑器中从光标位置插入文本:

     this.tinyMce.editor.execCommand('mceInsertContent', false, 'text');

【讨论】:

    猜你喜欢
    • 2012-11-03
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 2022-07-14
    • 1970-01-01
    • 2021-08-05
    • 2011-02-24
    相关资源
    最近更新 更多