在Typescript / Vue项目中使用Froala编辑器

时间:2019-09-06 19:05:54

标签: typescript vue.js froala

我正在尝试在Typescript / Vue项目中使用Froala,但是遇到了一个奇怪的导入问题。

由于Froala缺少正确的输入方式,所以我将自己的字体滚动到了froala.d.ts:

declare module 'froala-editor'

并在我的组件中,将其导入,如下所示:

import FroalaEditor from 'froala-editor';

在我的组件mount()回调中,我初始化了该组件:

this.editor = new FroalaEditor(`div#${this.componentId}`, {            
    theme: 'gray',
    toolbarButtons: ['bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', 'fontFamily', 'fontSize', 'color', 'inlineStyle', 'paragraphStyle', 'paragraphFormat', 'align', 'formatOL', 'formatUL', 'indent', 'outdent', 'insertTable', 'specialCharacters', 'insertHR', 'selectAll', 'clearFormatting', 'undo', 'redo'],
    toolbarVisibleWithoutSelection: true,
    key: 'AABBFFGETYOUROWNLICENSEKEY==',
    attribution: false
});

this.editor.html.set(this.value);

该组件将初始化,并且我会得到一个快乐的,经过良好调整的Froala编辑器,该编辑器恰好在用户界面中所期望的位置。奇怪的是,编辑器对象没有'html'属性,Froala文档坚持认为它应该:

Screenshot

我猜想这与模块的导入方式有关,但是我被卡住了。

我知道Froala有一个普通的Vue包装器,但是由于它是应用程序框架的一部分,所以我宁愿直接包装Froala,而不是包装一个包装器。

0 个答案:

没有答案
相关问题