@ckeditor/ckeditor5-widget 48.8.1-alpha.4 → 49.0.0-alpha.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 +1 -1
- package/dist/augmentation.d.ts +11 -11
- package/dist/highlightstack.d.ts +65 -64
- package/dist/index-content.css +3 -0
- package/dist/index-content.css.map +1 -0
- package/dist/index-editor.css +433 -426
- package/dist/index-editor.css.map +1 -0
- package/dist/index.css +331 -328
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +19 -17
- package/dist/index.js +2647 -3053
- package/dist/index.js.map +1 -1
- package/dist/translations/af.js +1 -1
- package/dist/translations/af.umd.js +5 -3
- package/dist/translations/ar.js +1 -1
- package/dist/translations/ar.umd.js +5 -3
- package/dist/translations/ast.js +1 -1
- package/dist/translations/ast.umd.js +5 -3
- package/dist/translations/az.js +1 -1
- package/dist/translations/az.umd.js +5 -3
- package/dist/translations/be.js +1 -1
- package/dist/translations/be.umd.js +5 -3
- package/dist/translations/bg.js +1 -1
- package/dist/translations/bg.umd.js +5 -3
- package/dist/translations/bn.js +1 -1
- package/dist/translations/bn.umd.js +5 -3
- package/dist/translations/bs.js +1 -1
- package/dist/translations/bs.umd.js +5 -3
- package/dist/translations/ca.js +1 -1
- package/dist/translations/ca.umd.js +5 -3
- package/dist/translations/cs.js +1 -1
- package/dist/translations/cs.umd.js +5 -3
- package/dist/translations/da.js +1 -1
- package/dist/translations/da.umd.js +5 -3
- package/dist/translations/de-ch.js +1 -1
- package/dist/translations/de-ch.umd.js +5 -3
- package/dist/translations/de.js +1 -1
- package/dist/translations/de.umd.js +5 -3
- package/dist/translations/el.js +1 -1
- package/dist/translations/el.umd.js +5 -3
- package/dist/translations/en-au.js +1 -1
- package/dist/translations/en-au.umd.js +5 -3
- package/dist/translations/en-gb.js +1 -1
- package/dist/translations/en-gb.umd.js +5 -3
- package/dist/translations/en.js +1 -1
- package/dist/translations/en.umd.js +5 -3
- package/dist/translations/eo.js +1 -1
- package/dist/translations/eo.umd.js +5 -3
- package/dist/translations/es-co.js +1 -1
- package/dist/translations/es-co.umd.js +5 -3
- package/dist/translations/es.js +1 -1
- package/dist/translations/es.umd.js +5 -3
- package/dist/translations/et.js +1 -1
- package/dist/translations/et.umd.js +5 -3
- package/dist/translations/eu.js +1 -1
- package/dist/translations/eu.umd.js +5 -3
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fa.umd.js +5 -3
- package/dist/translations/fi.js +1 -1
- package/dist/translations/fi.umd.js +5 -3
- package/dist/translations/fr.js +1 -1
- package/dist/translations/fr.umd.js +5 -3
- package/dist/translations/gl.js +1 -1
- package/dist/translations/gl.umd.js +5 -3
- package/dist/translations/gu.js +1 -1
- package/dist/translations/gu.umd.js +5 -3
- package/dist/translations/he.js +1 -1
- package/dist/translations/he.umd.js +5 -3
- package/dist/translations/hi.js +1 -1
- package/dist/translations/hi.umd.js +5 -3
- package/dist/translations/hr.js +1 -1
- package/dist/translations/hr.umd.js +5 -3
- package/dist/translations/hu.js +1 -1
- package/dist/translations/hu.umd.js +5 -3
- package/dist/translations/hy.js +1 -1
- package/dist/translations/hy.umd.js +5 -3
- package/dist/translations/id.js +1 -1
- package/dist/translations/id.umd.js +5 -3
- package/dist/translations/it.js +1 -1
- package/dist/translations/it.umd.js +5 -3
- package/dist/translations/ja.js +1 -1
- package/dist/translations/ja.umd.js +5 -3
- package/dist/translations/jv.js +1 -1
- package/dist/translations/jv.umd.js +5 -3
- package/dist/translations/kk.js +1 -1
- package/dist/translations/kk.umd.js +5 -3
- package/dist/translations/km.js +1 -1
- package/dist/translations/km.umd.js +5 -3
- package/dist/translations/kn.js +1 -1
- package/dist/translations/kn.umd.js +5 -3
- package/dist/translations/ko.js +1 -1
- package/dist/translations/ko.umd.js +5 -3
- package/dist/translations/ku.js +1 -1
- package/dist/translations/ku.umd.js +5 -3
- package/dist/translations/lt.js +1 -1
- package/dist/translations/lt.umd.js +5 -3
- package/dist/translations/lv.js +1 -1
- package/dist/translations/lv.umd.js +5 -3
- package/dist/translations/ms.js +1 -1
- package/dist/translations/ms.umd.js +5 -3
- package/dist/translations/nb.js +1 -1
- package/dist/translations/nb.umd.js +5 -3
- package/dist/translations/ne.js +1 -1
- package/dist/translations/ne.umd.js +5 -3
- package/dist/translations/nl.js +1 -1
- package/dist/translations/nl.umd.js +5 -3
- package/dist/translations/no.js +1 -1
- package/dist/translations/no.umd.js +5 -3
- package/dist/translations/oc.js +1 -1
- package/dist/translations/oc.umd.js +5 -3
- package/dist/translations/pl.js +1 -1
- package/dist/translations/pl.umd.js +5 -3
- package/dist/translations/pt-br.js +1 -1
- package/dist/translations/pt-br.umd.js +5 -3
- package/dist/translations/pt.js +1 -1
- package/dist/translations/pt.umd.js +5 -3
- package/dist/translations/ro.js +1 -1
- package/dist/translations/ro.umd.js +5 -3
- package/dist/translations/ru.js +1 -1
- package/dist/translations/ru.umd.js +5 -3
- package/dist/translations/si.js +1 -1
- package/dist/translations/si.umd.js +5 -3
- package/dist/translations/sk.js +1 -1
- package/dist/translations/sk.umd.js +5 -3
- package/dist/translations/sl.js +1 -1
- package/dist/translations/sl.umd.js +5 -3
- package/dist/translations/sq.js +1 -1
- package/dist/translations/sq.umd.js +5 -3
- package/dist/translations/sr-latn.js +1 -1
- package/dist/translations/sr-latn.umd.js +5 -3
- package/dist/translations/sr.js +1 -1
- package/dist/translations/sr.umd.js +5 -3
- package/dist/translations/sv.js +1 -1
- package/dist/translations/sv.umd.js +5 -3
- package/dist/translations/th.js +1 -1
- package/dist/translations/th.umd.js +5 -3
- package/dist/translations/ti.js +1 -1
- package/dist/translations/ti.umd.js +5 -3
- package/dist/translations/tk.js +1 -1
- package/dist/translations/tk.umd.js +5 -3
- package/dist/translations/tr.js +1 -1
- package/dist/translations/tr.umd.js +5 -3
- package/dist/translations/tt.js +1 -1
- package/dist/translations/tt.umd.js +5 -3
- package/dist/translations/ug.js +1 -1
- package/dist/translations/ug.umd.js +5 -3
- package/dist/translations/uk.js +1 -1
- package/dist/translations/uk.umd.js +5 -3
- package/dist/translations/ur.js +1 -1
- package/dist/translations/ur.umd.js +5 -3
- package/dist/translations/uz.js +1 -1
- package/dist/translations/uz.umd.js +5 -3
- package/dist/translations/vi.js +1 -1
- package/dist/translations/vi.umd.js +5 -3
- package/dist/translations/zh-cn.js +1 -1
- package/dist/translations/zh-cn.umd.js +5 -3
- package/dist/translations/zh.js +1 -1
- package/dist/translations/zh.umd.js +5 -3
- package/dist/utils.d.ts +192 -189
- package/dist/verticalnavigation.d.ts +11 -11
- package/dist/widget.d.ts +112 -113
- package/dist/widgetresize/resizer.d.ts +166 -169
- package/dist/widgetresize/resizerstate.d.ts +122 -121
- package/dist/widgetresize/sizeview.d.ts +52 -52
- package/dist/widgetresize.d.ts +120 -121
- package/dist/widgettoolbarrepository.d.ts +96 -96
- package/dist/widgettypearound/utils.d.ts +70 -37
- package/dist/widgettypearound/widgettypearound.d.ts +225 -226
- package/package.json +9 -9
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
( e => {
|
|
7
|
-
const { [ 'zh-cn' ]:
|
|
7
|
+
const { [ 'zh-cn' ]: translations } = {"zh-cn":{"dictionary":{"Widget toolbar":"小部件工具栏","Insert paragraph before block":"在前面插入段落","Insert paragraph after block":"在后面插入段落","Press Enter to type after or press Shift + Enter to type before the widget":"按下“Enter”键,在小组件后输入;按下“Shift+Enter”键,在小组件前输入","Keystrokes that can be used when a widget is selected (for example: image, table, etc.)":"当小组件被选中时(例如:图片、表格等)可以使用的按键","Insert a new paragraph directly after a widget":"直接在小组件之后插入新段落","Insert a new paragraph directly before a widget":"直接在小组件之前插入新段落","Move the caret to allow typing directly before a widget":"移动插入符,以允许在小组件之前直接输入文字","Move the caret to allow typing directly after a widget":"移动插入符,以允许在小组件之后直接输入文字","Move focus from an editable area back to the parent widget":"将焦点从可编辑区域移回父窗口小组件"}}};
|
|
8
8
|
e[ 'zh-cn' ] ||= { dictionary: {}, getPluralForm: null };
|
|
9
|
-
e[ 'zh-cn' ].dictionary = Object.assign( e[ 'zh-cn' ].dictionary, dictionary );
|
|
10
|
-
|
|
9
|
+
e[ 'zh-cn' ].dictionary = Object.assign( e[ 'zh-cn' ].dictionary, translations.dictionary );
|
|
10
|
+
if ( translations.getPluralForm ) {
|
|
11
|
+
e[ 'zh-cn' ].getPluralForm = translations.getPluralForm;
|
|
12
|
+
}
|
|
11
13
|
} )( window.CKEDITOR_TRANSLATIONS ||= {} );
|
package/dist/translations/zh.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
export default {"zh":{"dictionary":{"Widget toolbar":"小工具","Insert paragraph before block":"在這個區塊前面插入一個段落","Insert paragraph after block":"在這個區塊後面插入一個段落","Press Enter to type after or press Shift + Enter to type before the widget":"按下 Enter 在小工具後輸入,或按下 Shift + Enter 在小工具前輸入","Keystrokes that can be used when a widget is selected (for example: image, table, etc.)":"小工具選取時可使用的按鍵(例如:圖片、表格等)","Insert a new paragraph directly after a widget":"在小工具後直接插入新段落","Insert a new paragraph directly before a widget":"在小工具前直接插入新段落","Move the caret to allow typing directly before a widget":"移動插入符號,以便在小工具前直接輸入","Move the caret to allow typing directly after a widget":"移動插入符號,以便在小工具後直接輸入","Move focus from an editable area back to the parent widget":"將焦點從可編輯區域移回上層小工具"}
|
|
5
|
+
export default {"zh":{"dictionary":{"Widget toolbar":"小工具","Insert paragraph before block":"在這個區塊前面插入一個段落","Insert paragraph after block":"在這個區塊後面插入一個段落","Press Enter to type after or press Shift + Enter to type before the widget":"按下 Enter 在小工具後輸入,或按下 Shift + Enter 在小工具前輸入","Keystrokes that can be used when a widget is selected (for example: image, table, etc.)":"小工具選取時可使用的按鍵(例如:圖片、表格等)","Insert a new paragraph directly after a widget":"在小工具後直接插入新段落","Insert a new paragraph directly before a widget":"在小工具前直接插入新段落","Move the caret to allow typing directly before a widget":"移動插入符號,以便在小工具前直接輸入","Move the caret to allow typing directly after a widget":"移動插入符號,以便在小工具後直接輸入","Move focus from an editable area back to the parent widget":"將焦點從可編輯區域移回上層小工具"}}}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
( e => {
|
|
7
|
-
const { [ 'zh' ]:
|
|
7
|
+
const { [ 'zh' ]: translations } = {"zh":{"dictionary":{"Widget toolbar":"小工具","Insert paragraph before block":"在這個區塊前面插入一個段落","Insert paragraph after block":"在這個區塊後面插入一個段落","Press Enter to type after or press Shift + Enter to type before the widget":"按下 Enter 在小工具後輸入,或按下 Shift + Enter 在小工具前輸入","Keystrokes that can be used when a widget is selected (for example: image, table, etc.)":"小工具選取時可使用的按鍵(例如:圖片、表格等)","Insert a new paragraph directly after a widget":"在小工具後直接插入新段落","Insert a new paragraph directly before a widget":"在小工具前直接插入新段落","Move the caret to allow typing directly before a widget":"移動插入符號,以便在小工具前直接輸入","Move the caret to allow typing directly after a widget":"移動插入符號,以便在小工具後直接輸入","Move focus from an editable area back to the parent widget":"將焦點從可編輯區域移回上層小工具"}}};
|
|
8
8
|
e[ 'zh' ] ||= { dictionary: {}, getPluralForm: null };
|
|
9
|
-
e[ 'zh' ].dictionary = Object.assign( e[ 'zh' ].dictionary, dictionary );
|
|
10
|
-
|
|
9
|
+
e[ 'zh' ].dictionary = Object.assign( e[ 'zh' ].dictionary, translations.dictionary );
|
|
10
|
+
if ( translations.getPluralForm ) {
|
|
11
|
+
e[ 'zh' ].getPluralForm = translations.getPluralForm;
|
|
12
|
+
}
|
|
11
13
|
} )( window.CKEDITOR_TRANSLATIONS ||= {} );
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,216 +1,219 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Rect, type GetCallback } from
|
|
6
|
-
import { type DowncastHighlightDescriptor, type MapperViewToModelPositionEvent, type ModelDocumentSelection, type ViewDowncastWriter, type Model, type ModelRange, type ModelSelection, type ViewEditableElement, type ViewElement, type ViewTypeCheckable } from
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
|
+
import { Rect, type GetCallback } from "@ckeditor/ckeditor5-utils";
|
|
6
|
+
import { type DowncastHighlightDescriptor, type MapperViewToModelPositionEvent, type ModelDocumentSelection, type ViewDowncastWriter, type Model, type ModelRange, type ModelSelection, type ViewEditableElement, type ViewElement, type ViewTypeCheckable } from "@ckeditor/ckeditor5-engine";
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
* CSS class added to each widget element.
|
|
9
|
+
*/
|
|
10
10
|
export declare const WIDGET_CLASS_NAME = "ck-widget";
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
* CSS class added to currently selected widget element.
|
|
13
|
+
*/
|
|
14
14
|
export declare const WIDGET_SELECTED_CLASS_NAME = "ck-widget_selected";
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
* Returns `true` if given {@link module:engine/view/node~ViewNode} is an {@link module:engine/view/element~ViewElement} and a widget.
|
|
17
|
+
*/
|
|
18
18
|
export declare function isWidget(node: ViewTypeCheckable): boolean;
|
|
19
19
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
20
|
+
* Converts the given {@link module:engine/view/element~ViewElement} to a widget in the following way:
|
|
21
|
+
*
|
|
22
|
+
* * sets the `contenteditable` attribute to `"false"`,
|
|
23
|
+
* * adds the `ck-widget` CSS class,
|
|
24
|
+
* * adds a custom {@link module:engine/view/element~ViewElement#getFillerOffset `getFillerOffset()`} method returning `null`,
|
|
25
|
+
* * adds a custom property allowing to recognize widget elements by using {@link ~isWidget `isWidget()`},
|
|
26
|
+
* * implements the {@link ~setHighlightHandling view highlight on widgets}.
|
|
27
|
+
*
|
|
28
|
+
* This function needs to be used in conjunction with
|
|
29
|
+
* {@link module:engine/conversion/downcasthelpers~DowncastHelpers downcast conversion helpers}
|
|
30
|
+
* like {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`}.
|
|
31
|
+
* Moreover, typically you will want to use `toWidget()` only for `editingDowncast`, while keeping the `dataDowncast` clean.
|
|
32
|
+
*
|
|
33
|
+
* For example, in order to convert a `<widget>` model element to `<div class="widget">` in the view, you can define
|
|
34
|
+
* such converters:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* editor.conversion.for( 'editingDowncast' )
|
|
38
|
+
* .elementToElement( {
|
|
39
|
+
* model: 'widget',
|
|
40
|
+
* view: ( modelItem, { writer } ) => {
|
|
41
|
+
* const div = writer.createContainerElement( 'div', { class: 'widget' } );
|
|
42
|
+
*
|
|
43
|
+
* return toWidget( div, writer, { label: 'some widget' } );
|
|
44
|
+
* }
|
|
45
|
+
* } );
|
|
46
|
+
*
|
|
47
|
+
* editor.conversion.for( 'dataDowncast' )
|
|
48
|
+
* .elementToElement( {
|
|
49
|
+
* model: 'widget',
|
|
50
|
+
* view: ( modelItem, { writer } ) => {
|
|
51
|
+
* return writer.createContainerElement( 'div', { class: 'widget' } );
|
|
52
|
+
* }
|
|
53
|
+
* } );
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* See the full source code of the widget (with a nested editable) schema definition and converters in
|
|
57
|
+
* [this sample](https://github.com/ckeditor/ckeditor5-widget/blob/master/tests/manual/widget-with-nestededitable.js).
|
|
58
|
+
*
|
|
59
|
+
* @param options Additional options.
|
|
60
|
+
* @param options.label Element's label provided to the {@link ~setLabel} function. It can be passed as
|
|
61
|
+
* a plain string or a function returning a string. It represents the widget for assistive technologies (like screen readers).
|
|
62
|
+
* @param options.hasSelectionHandle If `true`, the widget will have a selection handle added.
|
|
63
|
+
* @returns Returns the same element.
|
|
64
|
+
*/
|
|
65
65
|
export declare function toWidget(element: ViewElement, writer: ViewDowncastWriter, options?: {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
label?: string | (() => string);
|
|
67
|
+
hasSelectionHandle?: boolean;
|
|
68
68
|
}): ViewElement;
|
|
69
69
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
* Sets highlight handling methods. Uses {@link module:widget/highlightstack~WidgetHighlightStack} to
|
|
71
|
+
* properly determine which highlight descriptor should be used at given time.
|
|
72
|
+
*/
|
|
73
73
|
export declare function setHighlightHandling(element: ViewElement, writer: ViewDowncastWriter, add?: (element: ViewElement, descriptor: DowncastHighlightDescriptor, writer: ViewDowncastWriter) => void, remove?: (element: ViewElement, descriptor: DowncastHighlightDescriptor, writer: ViewDowncastWriter) => void): void;
|
|
74
74
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
* Sets label for given element.
|
|
76
|
+
* It can be passed as a plain string or a function returning a string. Function will be called each time label is retrieved by
|
|
77
|
+
* {@link ~getLabel `getLabel()`}.
|
|
78
|
+
*/
|
|
79
79
|
export declare function setLabel(element: ViewElement, labelOrCreator: string | (() => string)): void;
|
|
80
80
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
* Returns the label of the provided element.
|
|
82
|
+
*/
|
|
83
83
|
export declare function getLabel(element: ViewElement): string;
|
|
84
84
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
85
|
+
* Adds functionality to the provided {@link module:engine/view/editableelement~ViewEditableElement} to act as a widget's editable:
|
|
86
|
+
*
|
|
87
|
+
* * sets the `contenteditable` attribute to `true` when
|
|
88
|
+
* {@link module:engine/view/editableelement~ViewEditableElement#isReadOnly} is `false`,
|
|
89
|
+
* otherwise sets it to `false`,
|
|
90
|
+
* * adds the `ck-editor__editable` and `ck-editor__nested-editable` CSS classes,
|
|
91
|
+
* * adds the `ck-editor__nested-editable_focused` CSS class when the editable is focused and removes it when it is blurred.
|
|
92
|
+
* * implements the {@link ~setHighlightHandling view highlight on widget's editable}.
|
|
93
|
+
* * sets the `role` attribute to `textbox` for accessibility purposes.
|
|
94
|
+
*
|
|
95
|
+
* Similarly to {@link ~toWidget `toWidget()`} this function should be used in `editingDowncast` only and it is usually
|
|
96
|
+
* used together with {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToElement `elementToElement()`}.
|
|
97
|
+
*
|
|
98
|
+
* For example, in order to convert a `<nested>` model element to `<div class="nested">` in the view, you can define
|
|
99
|
+
* such converters:
|
|
100
|
+
*
|
|
101
|
+
* ```ts
|
|
102
|
+
* editor.conversion.for( 'editingDowncast' )
|
|
103
|
+
* .elementToElement( {
|
|
104
|
+
* model: 'nested',
|
|
105
|
+
* view: ( modelItem, { writer } ) => {
|
|
106
|
+
* const div = writer.createEditableElement( 'div', { class: 'nested' } );
|
|
107
|
+
*
|
|
108
|
+
* return toWidgetEditable( nested, writer, { label: 'label for editable' } );
|
|
109
|
+
* }
|
|
110
|
+
* } );
|
|
111
|
+
*
|
|
112
|
+
* editor.conversion.for( 'dataDowncast' )
|
|
113
|
+
* .elementToElement( {
|
|
114
|
+
* model: 'nested',
|
|
115
|
+
* view: ( modelItem, { writer } ) => {
|
|
116
|
+
* return writer.createContainerElement( 'div', { class: 'nested' } );
|
|
117
|
+
* }
|
|
118
|
+
* } );
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* See the full source code of the widget (with nested editable) schema definition and converters in
|
|
122
|
+
* [this sample](https://github.com/ckeditor/ckeditor5-widget/blob/master/tests/manual/widget-with-nestededitable.js).
|
|
123
|
+
*
|
|
124
|
+
* @param options Additional options.
|
|
125
|
+
* @param options.label Editable's label used by assistive technologies (e.g. screen readers).
|
|
126
|
+
* @param options.withAriaRole Whether to add the role="textbox" attribute on the editable. Defaults to `true`.
|
|
127
|
+
* @returns Returns the same element that was provided in the `editable` parameter
|
|
128
|
+
*/
|
|
129
129
|
export declare function toWidgetEditable(editable: ViewEditableElement, writer: ViewDowncastWriter, options?: {
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
label?: string;
|
|
131
|
+
withAriaRole?: boolean;
|
|
132
132
|
}): ViewEditableElement;
|
|
133
133
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
134
|
+
* Returns a model range which is optimal (in terms of UX) for inserting a widget block.
|
|
135
|
+
*
|
|
136
|
+
* For instance, if a selection is in the middle of a paragraph, the collapsed range before this paragraph
|
|
137
|
+
* will be returned so that it is not split. If the selection is at the end of a paragraph,
|
|
138
|
+
* the collapsed range after this paragraph will be returned.
|
|
139
|
+
*
|
|
140
|
+
* Note: If the selection is placed in an empty block, the range in that block will be returned. If that range
|
|
141
|
+
* is then passed to {@link module:engine/model/model~Model#insertContent}, the block will be fully replaced
|
|
142
|
+
* by the inserted widget block.
|
|
143
|
+
*
|
|
144
|
+
* @param selection The selection based on which the insertion position should be calculated.
|
|
145
|
+
* @param model Model instance.
|
|
146
|
+
* @returns The optimal range.
|
|
147
|
+
*/
|
|
148
148
|
export declare function findOptimalInsertionRange(selection: ModelSelection | ModelDocumentSelection, model: Model): ModelRange;
|
|
149
149
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
150
|
+
* A util to be used in order to map view positions to correct model positions when implementing a widget
|
|
151
|
+
* which renders non-empty view element for an empty model element.
|
|
152
|
+
*
|
|
153
|
+
* For example:
|
|
154
|
+
*
|
|
155
|
+
* ```
|
|
156
|
+
* // Model:
|
|
157
|
+
* <placeholder type="name"></placeholder>
|
|
158
|
+
*
|
|
159
|
+
* // View:
|
|
160
|
+
* <span class="placeholder">name</span>
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* In such case, view positions inside `<span>` cannot be correctly mapped to the model (because the model element is empty).
|
|
164
|
+
* To handle mapping positions inside `<span class="placeholder">` to the model use this util as follows:
|
|
165
|
+
*
|
|
166
|
+
* ```ts
|
|
167
|
+
* editor.editing.mapper.on(
|
|
168
|
+
* 'viewToModelPosition',
|
|
169
|
+
* viewToModelPositionOutsideModelElement( model, viewElement => viewElement.hasClass( 'placeholder' ) )
|
|
170
|
+
* );
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* The callback will try to map the view offset of selection to an expected model position.
|
|
174
|
+
*
|
|
175
|
+
* 1. When the position is at the end (or in the middle) of the inline widget:
|
|
176
|
+
*
|
|
177
|
+
* ```
|
|
178
|
+
* // View:
|
|
179
|
+
* <p>foo <span class="placeholder">name|</span> bar</p>
|
|
180
|
+
*
|
|
181
|
+
* // Model:
|
|
182
|
+
* <paragraph>foo <placeholder type="name"></placeholder>| bar</paragraph>
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* 2. When the position is at the beginning of the inline widget:
|
|
186
|
+
*
|
|
187
|
+
* ```
|
|
188
|
+
* // View:
|
|
189
|
+
* <p>foo <span class="placeholder">|name</span> bar</p>
|
|
190
|
+
*
|
|
191
|
+
* // Model:
|
|
192
|
+
* <paragraph>foo |<placeholder type="name"></placeholder> bar</paragraph>
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @param model Model instance on which the callback operates.
|
|
196
|
+
* @param viewElementMatcher Function that is passed a view element and should return `true` if the custom mapping
|
|
197
|
+
* should be applied to the given view element.
|
|
198
|
+
*/
|
|
199
199
|
export declare function viewToModelPositionOutsideModelElement(model: Model, viewElementMatcher: (element: ViewElement) => boolean): GetCallback<MapperViewToModelPositionEvent>;
|
|
200
200
|
/**
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
201
|
+
* Starting from a DOM resize host element (an element that receives dimensions as a result of resizing),
|
|
202
|
+
* this helper returns the width of the found ancestor element.
|
|
203
|
+
*
|
|
204
|
+
* * It searches up to 5 levels of ancestors only.
|
|
205
|
+
*
|
|
206
|
+
* The search crosses shadow DOM boundaries, so for a resize host inside a shadow root it continues
|
|
207
|
+
* through the host into the surrounding (light) DOM instead of stopping at the boundary.
|
|
208
|
+
*
|
|
209
|
+
* @param domResizeHost Resize host DOM element that receives dimensions as a result of resizing.
|
|
210
|
+
* @returns Width of ancestor element in pixels or 0 if no ancestor with a computed width has been found.
|
|
211
|
+
*/
|
|
209
212
|
export declare function calculateResizeHostAncestorWidth(domResizeHost: HTMLElement): number;
|
|
210
213
|
/**
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
* Calculates a relative width of a `domResizeHost` compared to its ancestor in percents.
|
|
215
|
+
*
|
|
216
|
+
* @param domResizeHost Resize host DOM element.
|
|
217
|
+
* @returns Percentage value between 0 and 100.
|
|
218
|
+
*/
|
|
216
219
|
export declare function calculateResizeHostPercentageWidth(domResizeHost: HTMLElement, resizeHostRect?: Rect): number;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
+
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { type GetCallback } from
|
|
9
|
-
import type { EditingController, ViewDocumentArrowKeyEvent } from
|
|
6
|
+
* @module widget/verticalnavigation
|
|
7
|
+
*/
|
|
8
|
+
import { type GetCallback } from "@ckeditor/ckeditor5-utils";
|
|
9
|
+
import type { EditingController, ViewDocumentArrowKeyEvent } from "@ckeditor/ckeditor5-engine";
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
* Returns 'keydown' handler for up/down arrow keys that modifies the caret movement if it's in a text line next to an object.
|
|
12
|
+
*
|
|
13
|
+
* @param editing The editing controller.
|
|
14
|
+
*/
|
|
15
15
|
export declare function verticalWidgetNavigationHandler(editing: EditingController): GetCallback<ViewDocumentArrowKeyEvent>;
|