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

Presets #135

Closed
Reinmar opened this issue Mar 2, 2016 · 5 comments
Closed

Presets #135

Reinmar opened this issue Mar 2, 2016 · 5 comments

Comments

@Reinmar
Copy link
Member

Reinmar commented Mar 2, 2016

tl;dr: Presets are features requiring other features and following naming convention ckeditor5-preset-*/*.

A granularity of CKEditor features will mean that even a basic editor will require plenty of them.

For instance, CKEditor 4's basic preset would translate into something like the following set of features:

(Notes: Feature names passed in format foo are resolved to foo/foo. By "requiring" I mean a feature which requires other features – many times "foo/foo" is an index feature.)

  • typing (requring delete/backspace)
  • enter (requiring enter/blockenter, enter/softenter)
  • delete (requiring delete/forwarddelete, delete/backwardelete, delete/forwardworddelete, delete/backwardworddelete)
  • clipboard (requiring clipboard/copy, clipboard/cut, clipboard/paste, clipboard/draganddrop)
  • bascistyle/bold and basicstyle/italic
  • link
  • list (requiring list/numberedlist, list/bulletedlist and more)

We can already see that some features are shortcuts to a other features. For example enter/enter can be a feature requiring two other features enter/blockenter and enter/softenter. By requiring enter/enter (which can also be required as enter) the developer will enable two features at once.

Those "index" features become kind of a presets themselves. The same mechanism can be used by typical presets. So e.g. we could have a feature ckeditor5-preset/basic that would require all the features listed above. This method allows to mix multiple presets – i.e. ckeditor5-preset/basic and ckeditor5-preset/media can be used together.

There's one problem with the naming convention that I proposed above – if the developer runs npm install ckeditor5-preset, then a hundred packages will be installed, because dependencies of all possible presets will need to be resolved. Therefore, I propose to keep presets in separate packages with names starting with ckeditor5-preset-* – so ckeditor5-preset-basic/basic, ckeditor5-preset-media/media. This will allow other developers creating their presets and won't affect npm that badly. The only downside are the feature names (preset-basic/basic), but the same is true in creators (creator-classic/classic). We can eventually decide that preset-basic is automatically resolved to preset-basic/basic and creator-classic to creator-classic/classic.

This was referenced Mar 2, 2016
@fredck
Copy link
Contributor

fredck commented Mar 3, 2016

Aren't presets simply clones of ckeditor5 with customized package.json including all required packages?

@Reinmar
Copy link
Member Author

Reinmar commented Mar 3, 2016

This is possible as well. But having presets as features will allow to compose them and publishing them will be easier.

See this building scenario: https://github.com/ckeditor/ckeditor5-design/wiki/Building#integrating-ckeditor-into-another-project

Let's say you want CKEditor standard preset and some more packages. You do:

npm install --save-dev ckeditor5-preset-standard
npm install --save-dev ckeditor5-media
npm install --save-dev ckeditor5-creator-classic

Then you say to the builder that you need the following features:

features: [ 'preset-standard/standard', 'media' ]
creator: 'creator-classic/classic'

@fredck
Copy link
Contributor

fredck commented Mar 3, 2016

I'm smelling the birth of the removeFeatures configuration :D

@Reinmar
Copy link
Member Author

Reinmar commented Mar 3, 2016

Yes, I thought exactly the same when explaining this to PJ today. I'm not sure though how it could work, because if something is some feature's requirement, then it must be loaded. But perhaps we can handle this differently in presets... The plugin collection would know which features it should not load and it would simply avoid instantiating those. However, since features tell their dependencies by constructors, if you pass strings to removeFeatures we may have problems resolving what's what. So first we would need to load all features listed in removeFeatures to gain access to their constructors and later on we could easily filter those out.

All this is possible, but perhaps we won't really need removeFeatures. I don't think that it's so inconvenient if you need to whitelist stuff instead of blacklist. That's how it works in the apps normally – – removePlugins was quiet unique to CKEditor 3-4. We just need to come up with good presets build from smaller presets, so you don't need to list 100 features if you just want to remove one.

@Reinmar
Copy link
Member Author

Reinmar commented May 5, 2017

Already implemented: https://github.com/ckeditor/ckeditor5-presets

@Reinmar Reinmar closed this as completed May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants