简体   繁体   中英

CKEditor5 Text Alignment

I am try to configure my page with the CK5 editor. I did:

ClassicEditor.create(document.querySelector('#editor'), {
  language: 'pt-br',
  toolbar: ['heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote'],
  heading: {
    options: [{
      model: 'paragraph',
      title: 'Paragrafo',
      class: 'ck-heading_paragraph'
    }, {
      model: 'heading1',
      view: 'h1',
      title: 'Cabeçalho 1',
      class: 'ck-heading_heading1'
    }, {
      model: 'heading2',
      view: 'h2',
      title: 'Cabeçalho 2',
      class: 'ck-heading_heading2'
    }, {
      model: 'heading3',
      view: 'h3',
      title: 'Cabeçalho 3',
      class: 'ck-heading_heading2'
    }]
  }
}).then(editor => {
  console.log(editor);
}).catch(error => {
  console.log(error);
});

This works, but doesn't have an 'alignment' option. I found this link on how to install the @ckeditor/ckeditor5-alignment package

I followed carefully the steps show in this link, I have installed the NPM package manager and was raised the 'node_modules' paste in my application, but my browser report the error

Uncaught SyntaxError: Unexpected identifier

from this line:

import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment';

I'm not an expert in NPM, but followed the steps shown. I don't know what is missing.

You have to create your own build in order to add some extra plugins. You cannot add plugins to ckeditor5 without building it. More information:
Ckeditor5 Custom Builds

As a complement to @Dariush Salami's answer, take a look at this link , and check if it'll help you.

If you would like to install plugins locally on your own machine, please see how this can be done here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM