Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] A snippet in Preserving custom content does not work #5569

Closed
AnnaTomanek opened this issue Oct 11, 2019 · 3 comments · Fixed by ckeditor/ckeditor5-engine#1801
Closed
Assignees
Labels
support:2 An issue reported by a commercially licensed client. type:docs This issue reports a task related to documentation (e.g. an idea for a guide).

Comments

@AnnaTomanek
Copy link
Contributor

The following snippet does not work on current master:
https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/framework/guides/deep-dive/ui/conversion-preserving-custom-content.html#adding-extra-attributes-to-elements-contained-in-a-figure

{@snippet framework/extending-content-custom-figure-attributes}

The following errors can be found in the console:

plugincollection.js:235
plugincollection-load: It was not possible to load the plugin. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-plugincollection-load
 {plugin: ƒ}
(anonymous) @ plugincollection.js:235
Promise.catch (async)
l @ plugincollection.js:214
init @ plugincollection.js:198
initPlugins @ editor.js:229
(anonymous) @ classiceditor.js:193
create @ classiceditor.js:189
389 @ extending-content-custom-figure-attributes.js:157
r @ bootstrap:19
(anonymous) @ bootstrap:83
(anonymous) @ bootstrap:83

extending-content-custom-figure-attributes.js:168
CKEditorError: schema-cannot-extend-missing-item: Cannot extend an item which was not registered yet. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-schema-cannot-extend-missing-item
 {"itemName":"image"}
    at ae.extend (https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/snippets/framework/build-extending-content-source/snippet.js:4:326616)
    at o (https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/snippets/framework/extending-content-custom-figure-attributes/snippet.js:4:1242)
    at new ClassicEditor.create.extraPlugins (https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/snippets/framework/extending-content-custom-figure-attributes/snippet.js:4:2493)
    at https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/snippets/framework/build-extending-content-source/snippet.js:4:320828
    at new Promise (<anonymous>)
    at https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/snippets/framework/build-extending-content-source/snippet.js:4:320560
    at l (https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/snippets/framework/build-extending-content-source/snippet.js:4:320865)
    at Array.map (<anonymous>)
    at Yt.init (https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/snippets/framework/build-extending-content-source/snippet.js:4:320402)
    at P.initPlugins (https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/snippets/framework/build-extending-content-source/snippet.js:4:385183)
(anonymous) @ extending-content-custom-figure-attributes.js:168
Promise.catch (async)
389 @ extending-content-custom-figure-attributes.js:167
r @ bootstrap:19
(anonymous) @ bootstrap:83
(anonymous) @ bootstrap:83
@AnnaTomanek AnnaTomanek added the type:docs This issue reports a task related to documentation (e.g. an idea for a guide). label Oct 11, 2019
@AnnaTomanek AnnaTomanek added this to the iteration 27 milestone Oct 11, 2019
@jodator jodator self-assigned this Oct 11, 2019
@Reinmar
Copy link
Member

Reinmar commented Oct 11, 2019

Ee... it's loaded via extraPlugins. I'd say, a plugin loaded with it should be loaded at the very end of the queue. Does it happen this way, if we get this error?

@jodator
Copy link
Contributor

jodator commented Oct 14, 2019

@Reinmar it doesn't matter if it is loaded at the end or at the beginning. The function() plugin code is being executed on loadPlugin phase while "image" schema item is being defined later during the "init" phase. It will not work because when the function() plugin is called the "image" schema item is not yet defined.

The order of plugins initialization is:

  1. Call each plugin constructor (class or funciton()).
  2. Call each plugin instance init() method.
  3. Call each plugin instance afterInit() method.

It is this issue again: #2905 (comment).

You cannot use function() as a plugin if you wish to extend schema or alter conversion which might be defined in Plugin.init() method.

@mlewand mlewand modified the milestones: iteration 27, iteration 28 Oct 25, 2019
@mlewand mlewand modified the milestones: iteration 28, iteration 29 Dec 5, 2019
@lslowikowska lslowikowska added the support:2 An issue reported by a commercially licensed client. label Jan 8, 2020
@Reinmar
Copy link
Member

Reinmar commented Jan 21, 2020

IMO, we need to give more power to simple function plugins. I explained the two options that I see in ckeditor/ckeditor5-engine#1801 (comment).

Reinmar added a commit to ckeditor/ckeditor5-engine that referenced this issue Jan 28, 2020
Docs: Fix custom figure attributes snippet. Closes ckeditor/ckeditor5#5569.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support:2 An issue reported by a commercially licensed client. type:docs This issue reports a task related to documentation (e.g. an idea for a guide).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants