@ckeditor/ckeditor5-editor-decoupled 32.0.0 → 34.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -2
- package/README.md +3 -2
- package/build/editor-decoupled.js +2 -2
- package/package.json +14 -14
- package/src/decouplededitor.js +24 -24
package/LICENSE.md
CHANGED
|
@@ -2,7 +2,7 @@ Software License Agreement
|
|
|
2
2
|
==========================
|
|
3
3
|
|
|
4
4
|
**Decoupled editor implementation** – https://github.com/ckeditor/ckeditor5-editor-decoupled <br>
|
|
5
|
-
Copyright (c) 2003-2022, [CKSource
|
|
5
|
+
Copyright (c) 2003-2022, [CKSource Holding sp. z o.o.](https://cksource.com) All rights reserved.
|
|
6
6
|
|
|
7
7
|
Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).
|
|
8
8
|
|
|
@@ -14,4 +14,4 @@ Where not otherwise indicated, all CKEditor content is authored by CKSource engi
|
|
|
14
14
|
Trademarks
|
|
15
15
|
----------
|
|
16
16
|
|
|
17
|
-
**CKEditor** is a trademark of [CKSource
|
|
17
|
+
**CKEditor** is a trademark of [CKSource Holding sp. z o.o.](https://cksource.com) All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
|
package/README.md
CHANGED
|
@@ -3,13 +3,14 @@ CKEditor 5 decoupled editor implementation
|
|
|
3
3
|
|
|
4
4
|
[](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled)
|
|
5
5
|
[](https://coveralls.io/github/ckeditor/ckeditor5?branch=master)
|
|
6
|
-
[](https://travis-ci.com/ckeditor/ckeditor5)
|
|
6
|
+
[](https://app.travis-ci.com/github/ckeditor/ckeditor5)
|
|
7
|
+

|
|
7
8
|
|
|
8
9
|
The decoupled editor implementation for CKEditor 5.
|
|
9
10
|
|
|
10
11
|
This package contains the [`DecoupledEditor`](https://ckeditor.com/docs/ckeditor5/latest/api/module_editor-decoupled_decouplededitor-DecoupledEditor.html) class. Follow there to learn more about this type of editor and how to initialize it.
|
|
11
12
|
|
|
12
|
-
This package contains the source version of the decoupled editor. This editor implementation is also available in the [document build](https://www.npmjs.com/package/@ckeditor/ckeditor5-build-decoupled-document). Read more about [CKEditor 5 builds](https://ckeditor.com/docs/ckeditor5/latest/
|
|
13
|
+
This package contains the source version of the decoupled editor. This editor implementation is also available in the [document build](https://www.npmjs.com/package/@ckeditor/ckeditor5-build-decoupled-document). Read more about [CKEditor 5 builds](https://ckeditor.com/docs/ckeditor5/latest/installation/index.html).
|
|
13
14
|
|
|
14
15
|
## Documentation
|
|
15
16
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @license Copyright (c) 2003-2022, CKSource
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
|
-
*/(()=>{var t={704:(t,e,o)=>{t.exports=o(79)("./src/core.js")},492:(t,e,o)=>{t.exports=o(79)("./src/engine.js")},273:(t,e,o)=>{t.exports=o(79)("./src/ui.js")},209:(t,e,o)=>{t.exports=o(79)("./src/utils.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function o(r){var i=e[r];if(void 0!==i)return i.exports;var n=e[r]={exports:{}};return t[r](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};(()=>{"use strict";o.r(r),o.d(r,{DecoupledEditor:()=>S});var t=o(704),e=o(209);const i=function(t){return null!=t&&"object"==typeof t};const n="object"==typeof global&&global&&global.Object===Object&&global;var s="object"==typeof self&&self&&self.Object===Object&&self;const l=(n||s||Function("return this")()).Symbol;var a=Object.prototype,c=a.hasOwnProperty,
|
|
4
|
+
*/(()=>{var t={704:(t,e,o)=>{t.exports=o(79)("./src/core.js")},492:(t,e,o)=>{t.exports=o(79)("./src/engine.js")},273:(t,e,o)=>{t.exports=o(79)("./src/ui.js")},209:(t,e,o)=>{t.exports=o(79)("./src/utils.js")},79:t=>{"use strict";t.exports=CKEditor5.dll}},e={};function o(r){var i=e[r];if(void 0!==i)return i.exports;var n=e[r]={exports:{}};return t[r](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};(()=>{"use strict";o.r(r),o.d(r,{DecoupledEditor:()=>S});var t=o(704),e=o(209);const i=function(t){return null!=t&&"object"==typeof t};const n="object"==typeof global&&global&&global.Object===Object&&global;var s="object"==typeof self&&self&&self.Object===Object&&self;const l=(n||s||Function("return this")()).Symbol;var a=Object.prototype,c=a.hasOwnProperty,d=a.toString,u=l?l.toStringTag:void 0;const h=function(t){var e=c.call(t,u),o=t[u];try{t[u]=void 0;var r=!0}catch(t){}var i=d.call(t);return r&&(e?t[u]=o:delete t[u]),i};var b=Object.prototype.toString;const g=function(t){return b.call(t)};var p=l?l.toStringTag:void 0;const f=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":p&&p in Object(t)?h(t):g(t)};const m=function(t,e){return function(o){return t(e(o))}}(Object.getPrototypeOf,Object);var v=Function.prototype,y=Object.prototype,w=v.toString,j=y.hasOwnProperty,E=w.call(Object);const O=function(t){if(!i(t)||"[object Object]"!=f(t))return!1;var e=m(t);if(null===e)return!0;var o=j.call(e,"constructor")&&e.constructor;return"function"==typeof o&&o instanceof o&&w.call(o)==E};const T=function(t){return i(t)&&1===t.nodeType&&!O(t)};var x=o(273),D=o(492);class F extends t.EditorUI{constructor(t,e){super(t),this.view=e}init(){const t=this.editor,e=this.view,o=t.editing.view,r=e.editable,i=o.document.getRoot();e.editable.name=i.rootName,e.render();const n=r.element;this.setEditableElement(r.name,n),this.focusTracker.add(n),e.editable.bind("isFocused").to(this.focusTracker),o.attachDomRoot(n),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){const t=this.view;this.editor.editing.view.detachDomRoot(t.editable.name),t.destroy(),super.destroy()}_initToolbar(){const t=this.editor,e=this.view.toolbar;e.fillFromConfig(t.config.get("toolbar"),this.componentFactory),(0,x.enableToolbarKeyboardFocus)({origin:t.editing.view,originFocusTracker:this.focusTracker,originKeystrokeHandler:t.keystrokes,toolbar:e})}_initPlaceholder(){const t=this.editor,e=t.editing.view,o=e.document.getRoot(),r=t.sourceElement,i=t.config.get("placeholder")||r&&"textarea"===r.tagName.toLowerCase()&&r.getAttribute("placeholder");i&&(0,D.enablePlaceholder)({view:e,element:o,text:i,isDirectHost:!1,keepOnFocus:!0})}}class P extends x.EditorUIView{constructor(t,e,o={}){super(t),this.toolbar=new x.ToolbarView(t,{shouldGroupWhenFull:o.shouldToolbarGroupWhenFull}),this.editable=new x.InlineEditableUIView(t,e,o.editableElement),this.toolbar.extendTemplate({attributes:{class:["ck-reset_all","ck-rounded-corners"],dir:t.uiLanguageDirection}})}render(){super.render(),this.registerChild([this.toolbar,this.editable])}}class S extends t.Editor{constructor(o,r={}){if(!T(o)&&void 0!==r.initialData)throw new e.CKEditorError("editor-create-initial-data",null);super(r),void 0===this.config.get("initialData")&&this.config.set("initialData",function(t){return T(t)?(0,e.getDataFromElement)(t):t}(o)),T(o)&&(this.sourceElement=o,(0,t.secureSourceElement)(this)),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new P(this.locale,this.editing.view,{editableElement:this.sourceElement,shouldToolbarGroupWhenFull:i});this.ui=new F(this,n)}destroy(){const t=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&(0,e.setDataInElement)(this.sourceElement,t)}))}static create(t,o={}){return new Promise((r=>{if(T(t)&&"TEXTAREA"===t.tagName)throw new e.CKEditorError("editor-wrong-element",null);const i=new this(t,o);r(i.initPlugins().then((()=>i.ui.init())).then((()=>i.data.init(i.config.get("initialData")))).then((()=>i.fire("ready"))).then((()=>i)))}))}}(0,e.mix)(S,t.DataApiMixin)})(),(window.CKEditor5=window.CKEditor5||{}).editorDecoupled=r})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-editor-decoupled",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "34.1.0",
|
|
4
4
|
"description": "Decoupled editor implementation for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -11,22 +11,22 @@
|
|
|
11
11
|
],
|
|
12
12
|
"main": "src/index.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"ckeditor5": "^
|
|
14
|
+
"ckeditor5": "^34.1.0",
|
|
15
15
|
"lodash-es": "^4.17.15"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@ckeditor/ckeditor5-basic-styles": "^
|
|
19
|
-
"@ckeditor/ckeditor5-core": "^
|
|
20
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
21
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
22
|
-
"@ckeditor/ckeditor5-enter": "^
|
|
23
|
-
"@ckeditor/ckeditor5-heading": "^
|
|
24
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
|
25
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
|
26
|
-
"@ckeditor/ckeditor5-typing": "^
|
|
27
|
-
"@ckeditor/ckeditor5-ui": "^
|
|
28
|
-
"@ckeditor/ckeditor5-undo": "^
|
|
29
|
-
"@ckeditor/ckeditor5-utils": "^
|
|
18
|
+
"@ckeditor/ckeditor5-basic-styles": "^34.1.0",
|
|
19
|
+
"@ckeditor/ckeditor5-core": "^34.1.0",
|
|
20
|
+
"@ckeditor/ckeditor5-dev-utils": "^30.0.0",
|
|
21
|
+
"@ckeditor/ckeditor5-engine": "^34.1.0",
|
|
22
|
+
"@ckeditor/ckeditor5-enter": "^34.1.0",
|
|
23
|
+
"@ckeditor/ckeditor5-heading": "^34.1.0",
|
|
24
|
+
"@ckeditor/ckeditor5-paragraph": "^34.1.0",
|
|
25
|
+
"@ckeditor/ckeditor5-theme-lark": "^34.1.0",
|
|
26
|
+
"@ckeditor/ckeditor5-typing": "^34.1.0",
|
|
27
|
+
"@ckeditor/ckeditor5-ui": "^34.1.0",
|
|
28
|
+
"@ckeditor/ckeditor5-undo": "^34.1.0",
|
|
29
|
+
"@ckeditor/ckeditor5-utils": "^34.1.0",
|
|
30
30
|
"webpack": "^5.58.1",
|
|
31
31
|
"webpack-cli": "^4.9.0"
|
|
32
32
|
},
|
package/src/decouplededitor.js
CHANGED
|
@@ -16,7 +16,7 @@ import DecoupledEditorUI from './decouplededitorui';
|
|
|
16
16
|
import DecoupledEditorUIView from './decouplededitoruiview';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* The {@glink
|
|
19
|
+
* The {@glink installation/advanced/alternative-setups/predefined-builds#document-editor decoupled editor} implementation.
|
|
20
20
|
* It provides an inline editable and a toolbar. However, unlike other editors,
|
|
21
21
|
* it does not render these components anywhere in the DOM unless configured.
|
|
22
22
|
*
|
|
@@ -33,9 +33,11 @@ import DecoupledEditorUIView from './decouplededitoruiview';
|
|
|
33
33
|
*
|
|
34
34
|
* The decoupled editor can be used directly from source (if you installed the
|
|
35
35
|
* [`@ckeditor/ckeditor5-editor-decoupled`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-decoupled) package)
|
|
36
|
-
* but it is also available in the
|
|
36
|
+
* but it is also available in the
|
|
37
|
+
* {@glink installation/advanced/alternative-setups/predefined-builds#document-editor document editor build}.
|
|
37
38
|
*
|
|
38
|
-
* {@glink
|
|
39
|
+
* {@glink installation/advanced/alternative-setups/predefined-builds Builds}
|
|
40
|
+
* are ready-to-use editors with plugins bundled in. When using the editor from
|
|
39
41
|
* source you need to take care of loading all plugins by yourself
|
|
40
42
|
* (through the {@link module:core/editor/editorconfig~EditorConfig#plugins `config.plugins`} option).
|
|
41
43
|
* Using the editor from source gives much better flexibility and allows for easier customization.
|
|
@@ -58,11 +60,22 @@ export default class DecoupledEditor extends Editor {
|
|
|
58
60
|
* @param {HTMLElement|String} sourceElementOrData The DOM element that will be the source for the created editor
|
|
59
61
|
* (on which the editor will be initialized) or initial data for the editor. For more information see
|
|
60
62
|
* {@link module:editor-balloon/ballooneditor~BalloonEditor.create `BalloonEditor.create()`}.
|
|
61
|
-
* @param {module:core/editor/editorconfig~EditorConfig} config The editor configuration.
|
|
63
|
+
* @param {module:core/editor/editorconfig~EditorConfig} [config] The editor configuration.
|
|
62
64
|
*/
|
|
63
|
-
constructor( sourceElementOrData, config ) {
|
|
65
|
+
constructor( sourceElementOrData, config = {} ) {
|
|
66
|
+
// If both `config.initialData` is set and initial data is passed as the constructor parameter, then throw.
|
|
67
|
+
if ( !isElement( sourceElementOrData ) && config.initialData !== undefined ) {
|
|
68
|
+
// Documented in core/editor/editorconfig.jsdoc.
|
|
69
|
+
// eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
|
|
70
|
+
throw new CKEditorError( 'editor-create-initial-data', null );
|
|
71
|
+
}
|
|
72
|
+
|
|
64
73
|
super( config );
|
|
65
74
|
|
|
75
|
+
if ( this.config.get( 'initialData' ) === undefined ) {
|
|
76
|
+
this.config.set( 'initialData', getInitialData( sourceElementOrData ) );
|
|
77
|
+
}
|
|
78
|
+
|
|
66
79
|
if ( isElement( sourceElementOrData ) ) {
|
|
67
80
|
this.sourceElement = sourceElementOrData;
|
|
68
81
|
secureSourceElement( this );
|
|
@@ -193,13 +206,14 @@ export default class DecoupledEditor extends Editor {
|
|
|
193
206
|
* # Using the editor from source
|
|
194
207
|
*
|
|
195
208
|
* The code samples listed in the previous sections of this documentation assume that you are using an
|
|
196
|
-
* {@glink
|
|
209
|
+
* {@glink installation/advanced/alternative-setups/predefined-builds editor build}
|
|
210
|
+
* (for example – `@ckeditor/ckeditor5-build-decoupled`).
|
|
197
211
|
*
|
|
198
212
|
* If you want to use the decoupled editor from source (`@ckeditor/ckeditor5-editor-decoupled/src/decouplededitor`),
|
|
199
213
|
* you need to define the list of
|
|
200
214
|
* {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
|
|
201
215
|
* {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
|
|
202
|
-
* source in the {@glink
|
|
216
|
+
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source dedicated guide}.
|
|
203
217
|
*
|
|
204
218
|
* @param {HTMLElement|String} sourceElementOrData The DOM element that will be the source for the created editor
|
|
205
219
|
* or the editor's initial data.
|
|
@@ -216,9 +230,7 @@ export default class DecoupledEditor extends Editor {
|
|
|
216
230
|
*/
|
|
217
231
|
static create( sourceElementOrData, config = {} ) {
|
|
218
232
|
return new Promise( resolve => {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if ( isHTMLElement && sourceElementOrData.tagName === 'TEXTAREA' ) {
|
|
233
|
+
if ( isElement( sourceElementOrData ) && sourceElementOrData.tagName === 'TEXTAREA' ) {
|
|
222
234
|
// Documented in core/editor/editor.js
|
|
223
235
|
// eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
|
|
224
236
|
throw new CKEditorError( 'editor-wrong-element', null );
|
|
@@ -228,20 +240,8 @@ export default class DecoupledEditor extends Editor {
|
|
|
228
240
|
|
|
229
241
|
resolve(
|
|
230
242
|
editor.initPlugins()
|
|
231
|
-
.then( () =>
|
|
232
|
-
|
|
233
|
-
} )
|
|
234
|
-
.then( () => {
|
|
235
|
-
if ( !isHTMLElement && config.initialData ) {
|
|
236
|
-
// Documented in core/editor/editorconfig.jdoc.
|
|
237
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
|
|
238
|
-
throw new CKEditorError( 'editor-create-initial-data', null );
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const initialData = config.initialData !== undefined ? config.initialData : getInitialData( sourceElementOrData );
|
|
242
|
-
|
|
243
|
-
return editor.data.init( initialData );
|
|
244
|
-
} )
|
|
243
|
+
.then( () => editor.ui.init() )
|
|
244
|
+
.then( () => editor.data.init( editor.config.get( 'initialData' ) ) )
|
|
245
245
|
.then( () => editor.fire( 'ready' ) )
|
|
246
246
|
.then( () => editor )
|
|
247
247
|
);
|