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

Plugins outside of the editor - editor context #5891

Closed
oskarwrobel opened this issue Dec 3, 2019 · 0 comments · Fixed by ckeditor/ckeditor5-core#204
Closed

Plugins outside of the editor - editor context #5891

oskarwrobel opened this issue Dec 3, 2019 · 0 comments · Fixed by ckeditor/ckeditor5-core#204
Assignees
Labels
type:feature This issue reports a feature request (an idea for a new functionality or a missing option).

Comments

@oskarwrobel
Copy link
Contributor

oskarwrobel commented Dec 3, 2019

The time has come when some of our plugins evolved so much that they can be used outside of the editor. Such plugins have to stay compatible with the editor (like it was before) but also have to be ready to be used without the editor, or even with multiple editors at once.

After some researches and discussions, we decided to introduce a Context class, that's gonna be an environment for the plugins used outside of the editor. Also, a new type of plugin, a ContextPlugin will be introduced to represents plugins compatible with the context and the editor. The current Plugin class will be compatible only with the editor like it was before.

Context API will be similar to the editor API but will be limited only to some properties:

Context.plugins
Context.config
Context.locale

Scenarios

Single editor usage

For the single editor, not much change. Editor, when created, initialize additional property editor.context, with an empty context used only by this editor. There are no changes in the editor API for basic usage.

Shared editor usage

Assume that the Comments plugin requires the Sidebar plugin.

const context = async Context.create( {
	plugins: [ Sidebar ],
	sidebar: {
		container: sidebarElement
	}
} );

const editor1 = async ClassicEditor.create( editorElement1, {
	context: context,
	plugins: [ ArticlePlugins, Comments ]
} );

const editor2 = async ClassicEditor.create( editorElement2, {
	context: context,
	plugins: [ ArticlePlugins, Comments ]
} );

If the context property is passed to the editor it means that:

  • context.plugins (instances) should be added to the editor plugins,
  • editor.config should be extended by the context.config,
  • editor.locale should use context.locale.

Note, that this way, both editors will share the same Sidebar plugin. When any of these editors use editor.plugins.get( 'Sidebar' ) they will get the same instance.

When it comes to dependencies:

  • it should be possible, for the context plugins to requires another context plugins,
  • it should be possible, for the editor plugins to requires context plugins,
  • it should NOT be possible, for the context plugins to require editor plugins.
@oskarwrobel oskarwrobel added type:feature This issue reports a feature request (an idea for a new functionality or a missing option). status:confirmed labels Dec 3, 2019
@oskarwrobel oskarwrobel added this to the iteration 29 milestone Dec 3, 2019
@oskarwrobel oskarwrobel self-assigned this Dec 3, 2019
@mlewand mlewand changed the title Plugins outside of the editor Plugins outside of the editor - editor context Dec 5, 2019
Reinmar added a commit to ckeditor/ckeditor5-core that referenced this issue Jan 16, 2020
Feature: Introduced the concept of editor contexts and context plugins. Contexts provide a common, higher-level environment for solutions which use multiple editors and/or plugins that work outside an editor. Closes ckeditor/ckeditor5#5891.
Reinmar added a commit to ckeditor/ckeditor5-cloud-services that referenced this issue Jan 29, 2020
Other: Changed the `CloudServices` plugin to a context plugin. Part of ckeditor/ckeditor5#5891.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant