Froala WYSIWYG 编辑器未显示 React 中的所有工具栏按钮

2024-02-04

工具栏按钮未显示在由 facebook/create-react-app 创建的 React 应用程序中。

我尝试在 src/index.tsx 中或在使用组件之前导入 JS 和 CSS 文件。我还尝试导入单独的插件。他们都没有工作。

// Froala Editor JS files.
import 'froala-editor/js/froala_editor.pkgd.min.js';
import 'froala-editor/js/plugins.pkgd.min.js';
// Froala Editor CSS files.
import 'froala-editor/css/froala_style.min.css';
import 'froala-editor/css/froala_editor.pkgd.min.css';
import 'froala-editor/css/plugins.pkgd.min.css';
// Froala requires Font Awesome.
import 'font-awesome/css/font-awesome.css';

这就是我设置选项的方式。我什至尝试只设置对齐按钮,但它不起作用。

<FroalaEditor
  model={model}
  onModelChange={onModelChange}
  config={{
    key: FROALA_KEY,
    attribution: false,
    toolbarButtons: {
      moreText: {
        buttons: [
          'bold',
          'italic',
          'underline',
          'strikeThrough',
          'subscript',
          'superscript',
          'fontFamily',
          'fontSize',
          'textColor',
          'backgroundColor',
          'inlineClass',
          'inlineStyle',
          'clearFormatting',
        ],
        align: 'left',
        buttonsVisible: 3,
      },
      moreParagraph: {
        buttons: [
          'alignLeft',
          'alignCenter',
          'formatOLSimple',
          'alignRight',
          'alignJustify',
          'formatOL',
          'formatUL',
          'paragraphFormat',
          'paragraphStyle',
          'lineHeight',
          'outdent',
          'indent',
          'quote',
        ],
        align: 'left',
        buttonsVisible: 3,
      },
      moreRich: {
        buttons: [
          'insertLink',
          'insertImage',
          'insertVideo',
          'insertTable',
          'emoticons',
          'fontAwesome',
          'specialCharacters',
          'embedly',
          'insertFile',
          'insertHR',
        ],
        align: 'left',
        buttonsVisible: 3,
      },
      moreMisc: {
        buttons: [
          'undo',
          'redo',
          'fullscreen',
          'print',
          'getPDF',
          'spellChecker',
          'selectAll',
          'html',
          'help',
        ],
        align: 'right',
        buttonsVisible: 2,
      },
    },
    ...config,
  }}
/>

I can only see these buttons on the UI no matter how I set up the options. enter image description here


我刚刚发现了问题所在。您还必须在配置中的pluginsEnabled 数组中传递插件。像这样:

pluginsEnabled: [
  'fullscreen',
  'codeBeautifier',
],
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Froala WYSIWYG 编辑器未显示 React 中的所有工具栏按钮 的相关文章

随机推荐