@ckeditor/ckeditor5-editor-inline 36.0.0 → 37.0.0-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/build/editor-inline.js +1 -1
- package/package.json +17 -16
- package/src/index.d.ts +8 -0
- package/src/inlineeditor.d.ts +157 -0
- package/src/inlineeditor.js +1 -1
- package/src/inlineeditorui.d.ts +52 -0
- package/src/inlineeditoruiview.d.ts +137 -0
package/build/editor-inline.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
/*!
|
2
2
|
* @license Copyright (c) 2003-2023, 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(i){var r=e[i];if(void 0!==r)return r.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},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 i={};(()=>{"use strict";o.r(i),o.d(i,{InlineEditor:()=>
|
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(i){var r=e[i];if(void 0!==r)return r.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},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 i={};(()=>{"use strict";o.r(i),o.d(i,{InlineEditor:()=>A});var t=o(704),e=o(209);const r=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,h=l?l.toStringTag:void 0;const u=function(t){var e=c.call(t,h),o=t[h];try{t[h]=void 0;var i=!0}catch(t){}var r=d.call(t);return i&&(e?t[h]=o:delete t[h]),r};var p=Object.prototype.toString;const b=function(t){return p.call(t)};var f="[object Null]",g="[object Undefined]",w=l?l.toStringTag:void 0;const v=function(t){return null==t?void 0===t?g:f:w&&w in Object(t)?u(t):b(t)};const m=function(t,e){return function(o){return t(e(o))}}(Object.getPrototypeOf,Object);var y="[object Object]",O=Function.prototype,T=Object.prototype,j=O.toString,E=T.hasOwnProperty,P=j.call(Object);const x=function(t){if(!r(t)||v(t)!=y)return!1;var e=m(t);if(null===e)return!0;var o=E.call(e,"constructor")&&e.constructor;return"function"==typeof o&&o instanceof o&&j.call(o)==P};const _=function(t){return r(t)&&1===t.nodeType&&!x(t)};var F=o(273),S=o(492);class C extends F.EditorUI{constructor(t,e){super(t),this.view=e,this._toolbarConfig=(0,F.normalizeToolbarConfig)(t.config.get("toolbar"))}get element(){return this.view.editable.element}init(){const t=this.editor,e=this.view,o=t.editing.view,i=e.editable,r=o.document.getRoot();i.name=r.rootName,e.render();const n=i.element;this.setEditableElement(i.name,n),i.bind("isFocused").to(this.focusTracker),o.attachDomRoot(n),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const t=this.view;this.editor.editing.view.detachDomRoot(t.editable.name),t.destroy()}_initToolbar(){const t=this.editor,e=this.view,o=e.editable.element,i=e.toolbar;e.panel.bind("isVisible").to(this.focusTracker,"isFocused"),e.bind("viewportTopOffset").to(this,"viewportOffset",(({top:t})=>t||0)),e.listenTo(t.ui,"update",(()=>{e.panel.isVisible&&e.panel.pin({target:o,positions:e.panelPositions})})),i.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(i)}_initPlaceholder(){const t=this.editor,e=t.editing.view,o=e.document.getRoot(),i=t.sourceElement,r=t.config.get("placeholder")||i&&"textarea"===i.tagName.toLowerCase()&&i.getAttribute("placeholder");r&&(0,S.enablePlaceholder)({view:e,element:o,text:r,isDirectHost:!1,keepOnFocus:!0})}}const D=(0,e.toUnit)("px");class R extends F.EditorUIView{constructor(t,e,o,i={}){super(t);const r=t.t;this.toolbar=new F.ToolbarView(t,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull,isFloating:!0}),this.set("viewportTopOffset",0),this.panel=new F.BalloonPanelView(t),this.panelPositions=this._getPanelPositions(),this.panel.extendTemplate({attributes:{class:"ck-toolbar-container"}}),this.editable=new F.InlineEditableUIView(t,e,o,{label:t=>r("Rich Text Editor. Editing area: %0",t.name)}),this._resizeObserver=null}render(){super.render(),this.body.add(this.panel),this.registerChild(this.editable),this.panel.content.add(this.toolbar);if(this.toolbar.options.shouldGroupWhenFull){const t=this.editable.element;this._resizeObserver=new e.ResizeObserver(t,(()=>{this.toolbar.maxWidth=D(new e.Rect(t).width)}))}}destroy(){super.destroy(),this._resizeObserver&&this._resizeObserver.destroy()}_getPanelPositionTop(t,e){let o;return o=t.top>e.height+this.viewportTopOffset?t.top-e.height:t.bottom>e.height+this.viewportTopOffset+50?this.viewportTopOffset:t.bottom,o}_getPanelPositions(){const t=[(t,e)=>({top:this._getPanelPositionTop(t,e),left:t.left,name:"toolbar_west",config:{withArrow:!1}}),(t,e)=>({top:this._getPanelPositionTop(t,e),left:t.left+t.width-e.width,name:"toolbar_east",config:{withArrow:!1}})];return"ltr"===this.locale.uiLanguageDirection?t:t.reverse()}}class A extends((0,t.DataApiMixin)((0,t.ElementApiMixin)(t.Editor))){constructor(o,i={}){if(!z(o)&&void 0!==i.initialData)throw new e.CKEditorError("editor-create-initial-data",null);super(i),void 0===this.config.get("initialData")&&this.config.set("initialData",function(t){return z(t)?(0,e.getDataFromElement)(t):t}(o)),this.model.document.createRoot(),z(o)&&(this.sourceElement=o,(0,t.secureSourceElement)(this));const r=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new R(this.locale,this.editing.view,this.sourceElement,{shouldToolbarGroupWhenFull:r});this.ui=new C(this,n),(0,t.attachToForm)(this)}destroy(){const t=this.getData();return this.ui.destroy(),super.destroy().then((()=>{this.sourceElement&&this.updateSourceElement(t)}))}static create(t,o={}){return new Promise((i=>{if(z(t)&&"TEXTAREA"===t.tagName)throw new e.CKEditorError("editor-wrong-element",null);const r=new this(t,o);i(r.initPlugins().then((()=>r.ui.init())).then((()=>r.data.init(r.config.get("initialData")))).then((()=>r.fire("ready"))).then((()=>r)))}))}}function z(t){return _(t)}})(),(window.CKEditor5=window.CKEditor5||{}).editorInline=i})();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-editor-inline",
|
3
|
-
"version": "
|
3
|
+
"version": "37.0.0-alpha.0",
|
4
4
|
"description": "Inline editor implementation for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -11,23 +11,23 @@
|
|
11
11
|
],
|
12
12
|
"main": "src/index.js",
|
13
13
|
"dependencies": {
|
14
|
-
"ckeditor5": "^
|
14
|
+
"ckeditor5": "^37.0.0-alpha.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-image": "^
|
25
|
-
"@ckeditor/ckeditor5-paragraph": "^
|
26
|
-
"@ckeditor/ckeditor5-theme-lark": "^
|
27
|
-
"@ckeditor/ckeditor5-typing": "^
|
28
|
-
"@ckeditor/ckeditor5-ui": "^
|
29
|
-
"@ckeditor/ckeditor5-undo": "^
|
30
|
-
"@ckeditor/ckeditor5-utils": "^
|
18
|
+
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
|
19
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
|
20
|
+
"@ckeditor/ckeditor5-dev-utils": "^34.0.0",
|
21
|
+
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
|
22
|
+
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
|
23
|
+
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
|
24
|
+
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.0",
|
25
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
|
26
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.0",
|
27
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
|
28
|
+
"@ckeditor/ckeditor5-ui": "^37.0.0-alpha.0",
|
29
|
+
"@ckeditor/ckeditor5-undo": "^37.0.0-alpha.0",
|
30
|
+
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
|
31
31
|
"typescript": "^4.8.4",
|
32
32
|
"webpack": "^5.58.1",
|
33
33
|
"webpack-cli": "^4.9.0"
|
@@ -58,5 +58,6 @@
|
|
58
58
|
"dll:build": "webpack",
|
59
59
|
"build": "tsc -p ./tsconfig.release.json",
|
60
60
|
"postversion": "npm run build"
|
61
|
-
}
|
61
|
+
},
|
62
|
+
"types": "src/index.d.ts"
|
62
63
|
}
|
package/src/index.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module editor-inline
|
7
|
+
*/
|
8
|
+
export { default as InlineEditor } from './inlineeditor';
|
@@ -0,0 +1,157 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module editor-inline/inlineeditor
|
7
|
+
*/
|
8
|
+
import { Editor, type EditorConfig } from 'ckeditor5/src/core';
|
9
|
+
import InlineEditorUI from './inlineeditorui';
|
10
|
+
declare const InlineEditor_base: import("ckeditor5/src/utils").Mixed<import("ckeditor5/src/utils").Mixed<typeof Editor, import("ckeditor5/src/core").ElementApi>, import("ckeditor5/src/core").DataApi>;
|
11
|
+
/**
|
12
|
+
* The {@glink installation/getting-started/predefined-builds#inline-editor inline editor} implementation.
|
13
|
+
* It uses an inline editable and a floating toolbar.
|
14
|
+
* See the {@glink examples/builds/inline-editor demo}.
|
15
|
+
*
|
16
|
+
* In order to create a inline editor instance, use the static
|
17
|
+
* {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`} method.
|
18
|
+
*
|
19
|
+
* # Inline editor and inline build
|
20
|
+
*
|
21
|
+
* The inline editor can be used directly from source (if you installed the
|
22
|
+
* [`@ckeditor/ckeditor5-editor-inline`](https://www.npmjs.com/package/@ckeditor/ckeditor5-editor-inline) package)
|
23
|
+
* but it is also available in the {@glink installation/getting-started/predefined-builds#inline-editor inline build}.
|
24
|
+
*
|
25
|
+
* {@glink installation/getting-started/predefined-builds Builds}
|
26
|
+
* are ready-to-use editors with plugins bundled in. When using the editor from
|
27
|
+
* source you need to take care of loading all plugins by yourself
|
28
|
+
* (through the {@link module:core/editor/editorconfig~EditorConfig#plugins `config.plugins`} option).
|
29
|
+
* Using the editor from source gives much better flexibility and allows easier customization.
|
30
|
+
*
|
31
|
+
* Read more about initializing the editor from source or as a build in
|
32
|
+
* {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}.
|
33
|
+
*/
|
34
|
+
export default class InlineEditor extends InlineEditor_base {
|
35
|
+
/**
|
36
|
+
* @inheritDoc
|
37
|
+
*/
|
38
|
+
readonly ui: InlineEditorUI;
|
39
|
+
/**
|
40
|
+
* Creates an instance of the inline editor.
|
41
|
+
*
|
42
|
+
* **Note:** Do not use the constructor to create editor instances. Use the static
|
43
|
+
* {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`} method instead.
|
44
|
+
*
|
45
|
+
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
46
|
+
* (on which the editor will be initialized) or initial data for the editor. For more information see
|
47
|
+
* {@link module:editor-inline/inlineeditor~InlineEditor.create `InlineEditor.create()`}.
|
48
|
+
* @param config The editor configuration.
|
49
|
+
*/
|
50
|
+
protected constructor(sourceElementOrData: HTMLElement | string, config?: EditorConfig);
|
51
|
+
/**
|
52
|
+
* Destroys the editor instance, releasing all resources used by it.
|
53
|
+
*
|
54
|
+
* Updates the original editor element with the data if the
|
55
|
+
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy `updateSourceElementOnDestroy`}
|
56
|
+
* configuration option is set to `true`.
|
57
|
+
*/
|
58
|
+
destroy(): Promise<unknown>;
|
59
|
+
/**
|
60
|
+
* Creates a new inline editor instance.
|
61
|
+
*
|
62
|
+
* There are three general ways how the editor can be initialized.
|
63
|
+
*
|
64
|
+
* # Using an existing DOM element (and loading data from it)
|
65
|
+
*
|
66
|
+
* You can initialize the editor using an existing DOM element:
|
67
|
+
*
|
68
|
+
* ```ts
|
69
|
+
* InlineEditor
|
70
|
+
* .create( document.querySelector( '#editor' ) )
|
71
|
+
* .then( editor => {
|
72
|
+
* console.log( 'Editor was initialized', editor );
|
73
|
+
* } )
|
74
|
+
* .catch( err => {
|
75
|
+
* console.error( err.stack );
|
76
|
+
* } );
|
77
|
+
* ```
|
78
|
+
*
|
79
|
+
* The element's content will be used as the editor data and the element will become the editable element.
|
80
|
+
*
|
81
|
+
* # Creating a detached editor
|
82
|
+
*
|
83
|
+
* Alternatively, you can initialize the editor by passing the initial data directly as a `String`.
|
84
|
+
* In this case, the editor will render an element that must be inserted into the DOM for the editor to work properly:
|
85
|
+
*
|
86
|
+
* ```ts
|
87
|
+
* InlineEditor
|
88
|
+
* .create( '<p>Hello world!</p>' )
|
89
|
+
* .then( editor => {
|
90
|
+
* console.log( 'Editor was initialized', editor );
|
91
|
+
*
|
92
|
+
* // Initial data was provided so the editor UI element needs to be added manually to the DOM.
|
93
|
+
* document.body.appendChild( editor.ui.element );
|
94
|
+
* } )
|
95
|
+
* .catch( err => {
|
96
|
+
* console.error( err.stack );
|
97
|
+
* } );
|
98
|
+
* ```
|
99
|
+
*
|
100
|
+
* This lets you dynamically append the editor to your web page whenever it is convenient for you. You may use this method if your
|
101
|
+
* web page content is generated on the client side and the DOM structure is not ready at the moment when you initialize the editor.
|
102
|
+
*
|
103
|
+
* # Using an existing DOM element (and data provided in `config.initialData`)
|
104
|
+
*
|
105
|
+
* You can also mix these two ways by providing a DOM element to be used and passing the initial data through the configuration:
|
106
|
+
*
|
107
|
+
* ```ts
|
108
|
+
* InlineEditor
|
109
|
+
* .create( document.querySelector( '#editor' ), {
|
110
|
+
* initialData: '<h2>Initial data</h2><p>Foo bar.</p>'
|
111
|
+
* } )
|
112
|
+
* .then( editor => {
|
113
|
+
* console.log( 'Editor was initialized', editor );
|
114
|
+
* } )
|
115
|
+
* .catch( err => {
|
116
|
+
* console.error( err.stack );
|
117
|
+
* } );
|
118
|
+
* ```
|
119
|
+
*
|
120
|
+
* This method can be used to initialize the editor on an existing element with the specified content in case if your integration
|
121
|
+
* makes it difficult to set the content of the source element.
|
122
|
+
*
|
123
|
+
* Note that an error will be thrown if you pass the initial data both as the first parameter and also in the configuration.
|
124
|
+
*
|
125
|
+
* # Configuring the editor
|
126
|
+
*
|
127
|
+
* See the {@link module:core/editor/editorconfig~EditorConfig editor configuration documentation} to learn more about
|
128
|
+
* customizing plugins, toolbar and more.
|
129
|
+
*
|
130
|
+
* # Using the editor from source
|
131
|
+
*
|
132
|
+
* The code samples listed in the previous sections of this documentation assume that you are using an
|
133
|
+
* {@glink installation/getting-started/predefined-builds editor build} (for example – `@ckeditor/ckeditor5-build-inline`).
|
134
|
+
*
|
135
|
+
* If you want to use the inline editor from source (`@ckeditor/ckeditor5-editor-inline/src/inlineeditor`),
|
136
|
+
* you need to define the list of
|
137
|
+
* {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
|
138
|
+
* {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
|
139
|
+
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
|
140
|
+
*
|
141
|
+
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
142
|
+
* or the editor's initial data.
|
143
|
+
*
|
144
|
+
* If a DOM element is passed, its content will be automatically loaded to the editor upon initialization.
|
145
|
+
* The editor data will be set back to the original element once the editor is destroyed only if the
|
146
|
+
* {@link module:core/editor/editorconfig~EditorConfig#updateSourceElementOnDestroy updateSourceElementOnDestroy}
|
147
|
+
* option is set to `true`.
|
148
|
+
*
|
149
|
+
* If the initial data is passed, a detached editor will be created. In this case you need to insert it into the DOM manually.
|
150
|
+
* It is available under the {@link module:editor-inline/inlineeditorui~InlineEditorUI#element `editor.ui.element`} property.
|
151
|
+
*
|
152
|
+
* @param config The editor configuration.
|
153
|
+
* @returns A promise resolved once the editor is ready. The promise resolves with the created editor instance.
|
154
|
+
*/
|
155
|
+
static create(sourceElementOrData: HTMLElement | string, config?: EditorConfig): Promise<InlineEditor>;
|
156
|
+
}
|
157
|
+
export {};
|
package/src/inlineeditor.js
CHANGED
@@ -167,7 +167,7 @@ export default class InlineEditor extends DataApiMixin(ElementApiMixin(Editor))
|
|
167
167
|
* you need to define the list of
|
168
168
|
* {@link module:core/editor/editorconfig~EditorConfig#plugins plugins to be initialized} and
|
169
169
|
* {@link module:core/editor/editorconfig~EditorConfig#toolbar toolbar items}. Read more about using the editor from
|
170
|
-
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source dedicated guide}.
|
170
|
+
* source in the {@glink installation/advanced/alternative-setups/integrating-from-source-webpack dedicated guide}.
|
171
171
|
*
|
172
172
|
* @param sourceElementOrData The DOM element that will be the source for the created editor
|
173
173
|
* or the editor's initial data.
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module editor-inline/inlineeditorui
|
7
|
+
*/
|
8
|
+
import { type Editor } from 'ckeditor5/src/core';
|
9
|
+
import { EditorUI } from 'ckeditor5/src/ui';
|
10
|
+
import type InlineEditorUIView from './inlineeditoruiview';
|
11
|
+
/**
|
12
|
+
* The inline editor UI class.
|
13
|
+
*
|
14
|
+
* @extends module:core/editor/editorui~EditorUI
|
15
|
+
*/
|
16
|
+
export default class InlineEditorUI extends EditorUI {
|
17
|
+
/**
|
18
|
+
* The main (top–most) view of the editor UI.
|
19
|
+
*/
|
20
|
+
readonly view: InlineEditorUIView;
|
21
|
+
/**
|
22
|
+
* A normalized `config.toolbar` object.
|
23
|
+
*/
|
24
|
+
private readonly _toolbarConfig;
|
25
|
+
/**
|
26
|
+
* Creates an instance of the inline editor UI class.
|
27
|
+
*
|
28
|
+
* @param editor The editor instance.
|
29
|
+
* @param view The view of the UI.
|
30
|
+
*/
|
31
|
+
constructor(editor: Editor, view: InlineEditorUIView);
|
32
|
+
/**
|
33
|
+
* @inheritDoc
|
34
|
+
*/
|
35
|
+
get element(): HTMLElement | null;
|
36
|
+
/**
|
37
|
+
* Initializes the UI.
|
38
|
+
*/
|
39
|
+
init(): void;
|
40
|
+
/**
|
41
|
+
* @inheritDoc
|
42
|
+
*/
|
43
|
+
destroy(): void;
|
44
|
+
/**
|
45
|
+
* Initializes the inline editor toolbar and its panel.
|
46
|
+
*/
|
47
|
+
private _initToolbar;
|
48
|
+
/**
|
49
|
+
* Enable the placeholder text on the editing root, if any was configured.
|
50
|
+
*/
|
51
|
+
private _initPlaceholder;
|
52
|
+
}
|
@@ -0,0 +1,137 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* @module editor-inline/inlineeditoruiview
|
7
|
+
*/
|
8
|
+
import { BalloonPanelView, EditorUIView, InlineEditableUIView, ToolbarView } from 'ckeditor5/src/ui';
|
9
|
+
import { type PositioningFunction, type Locale } from 'ckeditor5/src/utils';
|
10
|
+
import type { View } from 'ckeditor5/src/engine';
|
11
|
+
/**
|
12
|
+
* Inline editor UI view. Uses an nline editable and a floating toolbar.
|
13
|
+
*/
|
14
|
+
export default class InlineEditorUIView extends EditorUIView {
|
15
|
+
/**
|
16
|
+
* A floating toolbar view instance.
|
17
|
+
*/
|
18
|
+
readonly toolbar: ToolbarView;
|
19
|
+
/**
|
20
|
+
* The offset from the top edge of the web browser's viewport which makes the
|
21
|
+
* UI become sticky. The default value is `0`, which means that the UI becomes
|
22
|
+
* sticky when its upper edge touches the top of the page viewport.
|
23
|
+
*
|
24
|
+
* This attribute is useful when the web page has UI elements positioned to the top
|
25
|
+
* either using `position: fixed` or `position: sticky`, which would cover the
|
26
|
+
* UI or vice–versa (depending on the `z-index` hierarchy).
|
27
|
+
*
|
28
|
+
* Bound to {@link module:core/editor/editorui~EditorUI#viewportOffset `EditorUI#viewportOffset`}.
|
29
|
+
*
|
30
|
+
* If {@link module:core/editor/editorconfig~EditorConfig#ui `EditorConfig#ui.viewportOffset.top`} is defined, then
|
31
|
+
* it will override the default value.
|
32
|
+
*
|
33
|
+
* @observable
|
34
|
+
* @default 0
|
35
|
+
*/
|
36
|
+
viewportTopOffset: number;
|
37
|
+
/**
|
38
|
+
* A balloon panel view instance.
|
39
|
+
*/
|
40
|
+
readonly panel: BalloonPanelView;
|
41
|
+
/**
|
42
|
+
* A set of positioning functions used by the {@link #panel} to float around
|
43
|
+
* {@link #element editableElement}.
|
44
|
+
*
|
45
|
+
* The positioning functions are as follows:
|
46
|
+
*
|
47
|
+
* * West:
|
48
|
+
*
|
49
|
+
* ```
|
50
|
+
* [ Panel ]
|
51
|
+
* +------------------+
|
52
|
+
* | #editableElement |
|
53
|
+
* +------------------+
|
54
|
+
*
|
55
|
+
* +------------------+
|
56
|
+
* | #editableElement |
|
57
|
+
* |[ Panel ] |
|
58
|
+
* | |
|
59
|
+
* +------------------+
|
60
|
+
*
|
61
|
+
* +------------------+
|
62
|
+
* | #editableElement |
|
63
|
+
* +------------------+
|
64
|
+
* [ Panel ]
|
65
|
+
* ```
|
66
|
+
*
|
67
|
+
* * East:
|
68
|
+
*
|
69
|
+
* ```
|
70
|
+
* [ Panel ]
|
71
|
+
* +------------------+
|
72
|
+
* | #editableElement |
|
73
|
+
* +------------------+
|
74
|
+
*
|
75
|
+
* +------------------+
|
76
|
+
* | #editableElement |
|
77
|
+
* | [ Panel ]|
|
78
|
+
* | |
|
79
|
+
* +------------------+
|
80
|
+
*
|
81
|
+
* +------------------+
|
82
|
+
* | #editableElement |
|
83
|
+
* +------------------+
|
84
|
+
* [ Panel ]
|
85
|
+
* ```
|
86
|
+
*
|
87
|
+
* See: {@link module:utils/dom/position~Options#positions}.
|
88
|
+
*/
|
89
|
+
readonly panelPositions: Array<PositioningFunction>;
|
90
|
+
/**
|
91
|
+
* Editable UI view.
|
92
|
+
*/
|
93
|
+
readonly editable: InlineEditableUIView;
|
94
|
+
/**
|
95
|
+
* An instance of the resize observer that helps dynamically determine the geometry of the toolbar
|
96
|
+
* and manage items that do not fit into a single row.
|
97
|
+
*
|
98
|
+
* **Note:** Created in {@link #render}.
|
99
|
+
*/
|
100
|
+
private _resizeObserver;
|
101
|
+
/**
|
102
|
+
* Creates an instance of the inline editor UI view.
|
103
|
+
*
|
104
|
+
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
105
|
+
* @param editingView The editing view instance this view is related to.
|
106
|
+
* @param editableElement The editable element. If not specified, it will be automatically created by
|
107
|
+
* {@link module:ui/editableui/editableuiview~EditableUIView}. Otherwise, the given element will be used.
|
108
|
+
* @param options Configuration options for the view instance.
|
109
|
+
* @param options.shouldToolbarGroupWhenFull When set `true` enables automatic items grouping
|
110
|
+
* in the main {@link module:editor-inline/inlineeditoruiview~InlineEditorUIView#toolbar toolbar}.
|
111
|
+
* See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
|
112
|
+
*/
|
113
|
+
constructor(locale: Locale, editingView: View, editableElement?: HTMLElement, options?: {
|
114
|
+
shouldToolbarGroupWhenFull?: boolean;
|
115
|
+
});
|
116
|
+
/**
|
117
|
+
* @inheritDoc
|
118
|
+
*/
|
119
|
+
render(): void;
|
120
|
+
/**
|
121
|
+
* @inheritDoc
|
122
|
+
*/
|
123
|
+
destroy(): void;
|
124
|
+
/**
|
125
|
+
* Determines the panel top position of the {@link #panel} in {@link #panelPositions}.
|
126
|
+
*
|
127
|
+
* @param editableRect Rect of the {@link #element}.
|
128
|
+
* @param panelRect Rect of the {@link #panel}.
|
129
|
+
*/
|
130
|
+
private _getPanelPositionTop;
|
131
|
+
/**
|
132
|
+
* Returns the positions for {@link #panelPositions}.
|
133
|
+
*
|
134
|
+
* See: {@link module:utils/dom/position~Options#positions}.
|
135
|
+
*/
|
136
|
+
private _getPanelPositions;
|
137
|
+
}
|