代码之家  ›  专栏  ›  技术社区  ›  Leon Segal

tinymce角度图像选取器语法

  •  0
  • Leon Segal  · 技术社区  · 4 年前

    我有一个使用angular的ionic应用程序,我想把一个图像选择器放到tinymce编辑器中,这是我在页面上介绍的。

    在教堂里 docs ngModel here

     <h1>TinyMCE 5 Angular Demo</h1>
     <editor
       [(ngModel)]="dataModel"
       [init]="{
         height: 500,
         menubar: false,
         plugins: [
           'advlist autolink lists link image charmap print preview anchor',
           'searchreplace visualblocks code fullscreen',
           'insertdatetime media table paste code help wordcount'
         ],
         toolbar:
           'undo redo | formatselect | bold italic backcolor | \
           alignleft aligncenter alignright alignjustify | \
           bullist numlist outdent indent | removeformat | help'
       }"
     ></editor>
    

    一切正常,但现在我想添加一个图像选择器,但是 docs for that 暗示在ts文件中使用js,如下所示:

    tinymce.init({
      selector: 'textarea',  // change this value according to your HTML
      file_picker_callback: function(callback, value, meta) {
        // Provide file and text for the link dialog
        if (meta.filetype == 'file') {
          callback('mypage.html', {text: 'My text'});
        }
    
        // Provide image and alt text for the image dialog
        if (meta.filetype == 'image') {
          callback('myimage.jpg', {alt: 'My alt text'});
        }
    
        // Provide alternative source and posted for the media dialog
        if (meta.filetype == 'media') {
          callback('movie.mp4', {source2: 'alt.ogg', poster: 'image.jpg'});
        }
      }
    });
    

    我现在有点困了,因为我需要打电话 file_picker_callback 从html中的指令,我似乎不知道该怎么做。

    或者,我想我可以参考 NG模型

    我已经开始阅读角度文档,以了解发生了什么(以及要做什么),但只要朝着正确的方向努力一点也不会出错。

    0 回复  |  直到 4 年前
        1
  •  0
  •   Leon Segal    4 年前

    其实很简单,只要用 this

    file_picker_callback: this.filePickerCallback
    

    然后创建函数 filePickerCallback