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

Include CKEditor version number somewhere #1005

Closed
wwalc opened this issue Apr 26, 2018 · 11 comments
Closed

Include CKEditor version number somewhere #1005

wwalc opened this issue Apr 26, 2018 · 11 comments
Assignees
Labels
type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Milestone

Comments

@wwalc
Copy link
Member

wwalc commented Apr 26, 2018

Currently when I have a js bundle it's hard to determine what version I'm running actually.

@Reinmar
Copy link
Member

Reinmar commented Apr 26, 2018

In the license header? Or somewhere as a static property in the editor class (could be done by requiring it from package.json in the Editor class)?

@Reinmar
Copy link
Member

Reinmar commented Apr 26, 2018

The former will be easier to extract with regexp from the source. The latter will be available programmatically in JS. So, we could also have both.

@Reinmar Reinmar added type:feature This issue reports a feature request (an idea for a new functionality or a missing option). status:confirmed labels Apr 26, 2018
@Reinmar Reinmar added this to the backlog milestone Apr 26, 2018
@ma2ciek
Copy link
Contributor

ma2ciek commented Apr 26, 2018

Note: requiring a version from package.json will result in bundling whole package.json. As I remember, webpack@4 solves it.

@Reinmar Reinmar modified the milestones: backlog, next Jun 11, 2018
@wwalc
Copy link
Member Author

wwalc commented Jun 11, 2018

There is one more place where the version number would be really useful: in the DOM as a data attribute of the ck-editor__editable. This way we could easily understand the version number of the editor when trying to investigate something in users applications.

In users applications CKEditor JS source files are many times merged with other JS files and sometimes obfuscated, which makes getting the version number from source code really cumbersome.

@Reinmar
Copy link
Member

Reinmar commented Jun 11, 2018

Alternatively, we could expose it as a global variable. Not very clean and I'm not 100% sure that it'd be accessible in all cases, but polluting the editable element with it isn't cool too.

@pjasiun
Copy link

pjasiun commented Jun 11, 2018

The clean solution would be to have editor.version property which exposes the version from the package.json. As far as I remember the talk with @ma2ciek as soon as Webpack will support JSON tree shaking we will be able to do it as simple as:

import { version as ckeditor5PackageVersion } from '@ckeditor/ckeditor5/package.json';
// ...
this.version = ckeditor5PackageVersion;

However, to make it useful editor need to be exposed.

@Reinmar
Copy link
Member

Reinmar commented Jun 11, 2018

However, to make it useful editor need to be exposed.

Exactly. That's why we need a global. No one exposes editor except us. But it can look like this:

import { version as ckeditor5PackageVersion } from '@ckeditor/ckeditor5/package.json';
// ...
window.CKEDITOR_VERSION = ckeditor5PackageVersion;

@Reinmar Reinmar modified the milestones: next, iteration 19 Jun 19, 2018
@Reinmar
Copy link
Member

Reinmar commented Jun 27, 2018

BTW, we can add a check. If window.CKEDITOR_VERSION is defined when this module will be executed, we can log a warning that either someone loaded two builds on one page. Or that packages got duplicated while installation (which might be caused by mismatched dependency versions).

Also, this is exactly the code which we can put in the ckeditor5 package :) We didn't know what to put there and I think that we have an answer :)

@pjasiun
Copy link

pjasiun commented Jun 27, 2018

I was thinking if we should have window.CKEDITOR_VERSION or window.CKEDITOR.VERSION. We will soon have window.CKEDITOR_DEBUG (or window.CKEDITOR.DEBUG). But I think that window.CKEDITOR.* gives us nothing and brings problem who should initialize it, so window.CKEDITOR_VERSION (and window.CKEDITOR_DEBUG in the future) looks better.

@Reinmar
Copy link
Member

Reinmar commented Jun 27, 2018

BTW, one of the problems here is accessing the global object. It's not always window (see #879) so we need to be careful.

@Reinmar
Copy link
Member

Reinmar commented Jul 19, 2018

This is how you can get the version of CKEditor 5 from the console:

console.log( CKEDITOR_VERSION ); // -> '11.0.0'

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

No branches or pull requests

5 participants