@ckeditor/ckeditor5-engine 45.2.1-alpha.9 → 46.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/dist/index.js +2563 -2257
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/controller/datacontroller.d.ts +33 -32
- package/src/controller/datacontroller.js +29 -28
- package/src/controller/editingcontroller.d.ts +8 -8
- package/src/controller/editingcontroller.js +10 -10
- package/src/conversion/conversion.d.ts +18 -19
- package/src/conversion/conversion.js +4 -4
- package/src/conversion/conversionhelpers.d.ts +1 -1
- package/src/conversion/conversionhelpers.js +1 -1
- package/src/conversion/downcastdispatcher.d.ts +63 -69
- package/src/conversion/downcastdispatcher.js +16 -16
- package/src/conversion/downcasthelpers.d.ts +94 -83
- package/src/conversion/downcasthelpers.js +63 -53
- package/src/conversion/mapper.d.ts +27 -27
- package/src/conversion/mapper.js +15 -15
- package/src/conversion/modelconsumable.d.ts +26 -26
- package/src/conversion/modelconsumable.js +23 -23
- package/src/conversion/upcastdispatcher.d.ts +33 -32
- package/src/conversion/upcastdispatcher.js +19 -19
- package/src/conversion/upcasthelpers.d.ts +46 -38
- package/src/conversion/upcasthelpers.js +33 -24
- package/src/conversion/viewconsumable.d.ts +50 -45
- package/src/conversion/viewconsumable.js +32 -27
- package/src/dataprocessor/basichtmlwriter.d.ts +4 -2
- package/src/dataprocessor/basichtmlwriter.js +3 -1
- package/src/dataprocessor/dataprocessor.d.ts +7 -6
- package/src/dataprocessor/htmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/htmldataprocessor.js +6 -6
- package/src/dataprocessor/htmlwriter.d.ts +1 -1
- package/src/dataprocessor/xmldataprocessor.d.ts +10 -10
- package/src/dataprocessor/xmldataprocessor.js +6 -6
- package/src/dev-utils/model.d.ts +25 -26
- package/src/dev-utils/model.js +35 -36
- package/src/dev-utils/operationreplayer.d.ts +5 -3
- package/src/dev-utils/operationreplayer.js +4 -2
- package/src/dev-utils/utils.d.ts +8 -0
- package/src/dev-utils/utils.js +8 -0
- package/src/dev-utils/view.d.ts +66 -63
- package/src/dev-utils/view.js +144 -134
- package/src/index.d.ts +135 -106
- package/src/index.js +120 -71
- package/src/legacyerrors.d.ts +5 -0
- package/src/legacyerrors.js +17 -0
- package/src/model/batch.d.ts +2 -15
- package/src/model/batch.js +1 -23
- package/src/model/differ.d.ts +54 -31
- package/src/model/differ.js +15 -15
- package/src/model/document.d.ts +31 -31
- package/src/model/document.js +13 -13
- package/src/model/documentfragment.d.ts +45 -45
- package/src/model/documentfragment.js +40 -40
- package/src/model/documentselection.d.ts +92 -92
- package/src/model/documentselection.js +71 -70
- package/src/model/element.d.ts +31 -31
- package/src/model/element.js +29 -29
- package/src/model/history.d.ts +3 -3
- package/src/model/history.js +2 -2
- package/src/model/item.d.ts +4 -5
- package/src/model/liveposition.d.ts +31 -31
- package/src/model/liveposition.js +18 -18
- package/src/model/liverange.d.ts +42 -38
- package/src/model/liverange.js +17 -16
- package/src/model/markercollection.d.ts +41 -40
- package/src/model/markercollection.js +22 -20
- package/src/model/model.d.ts +82 -81
- package/src/model/model.js +54 -54
- package/src/model/node.d.ts +48 -48
- package/src/model/node.js +31 -31
- package/src/model/nodelist.d.ts +17 -17
- package/src/model/nodelist.js +11 -11
- package/src/model/operation/attributeoperation.d.ts +10 -10
- package/src/model/operation/attributeoperation.js +7 -7
- package/src/model/operation/detachoperation.d.ts +11 -9
- package/src/model/operation/detachoperation.js +8 -6
- package/src/model/operation/insertoperation.d.ts +13 -13
- package/src/model/operation/insertoperation.js +15 -15
- package/src/model/operation/markeroperation.d.ts +12 -12
- package/src/model/operation/markeroperation.js +5 -5
- package/src/model/operation/mergeoperation.d.ts +16 -16
- package/src/model/operation/mergeoperation.js +18 -18
- package/src/model/operation/moveoperation.d.ts +16 -16
- package/src/model/operation/moveoperation.js +18 -15
- package/src/model/operation/nooperation.d.ts +4 -4
- package/src/model/operation/nooperation.js +2 -2
- package/src/model/operation/operation.d.ts +10 -10
- package/src/model/operation/operation.js +5 -5
- package/src/model/operation/operationfactory.d.ts +4 -4
- package/src/model/operation/operationfactory.js +12 -12
- package/src/model/operation/renameoperation.d.ts +10 -10
- package/src/model/operation/renameoperation.js +7 -7
- package/src/model/operation/rootattributeoperation.d.ts +12 -12
- package/src/model/operation/rootattributeoperation.js +8 -8
- package/src/model/operation/rootoperation.d.ts +8 -8
- package/src/model/operation/rootoperation.js +3 -3
- package/src/model/operation/splitoperation.d.ts +17 -17
- package/src/model/operation/splitoperation.js +19 -19
- package/src/model/operation/transform.d.ts +11 -8
- package/src/model/operation/transform.js +66 -49
- package/src/model/operation/utils.d.ts +24 -23
- package/src/model/operation/utils.js +20 -20
- package/src/model/position.d.ts +101 -97
- package/src/model/position.js +69 -64
- package/src/model/range.d.ts +90 -90
- package/src/model/range.js +87 -87
- package/src/model/rootelement.d.ts +11 -11
- package/src/model/rootelement.js +9 -9
- package/src/model/schema.d.ts +158 -154
- package/src/model/schema.js +93 -90
- package/src/model/selection.d.ts +73 -73
- package/src/model/selection.js +62 -62
- package/src/model/text.d.ts +11 -10
- package/src/model/text.js +11 -10
- package/src/model/textproxy.d.ts +39 -38
- package/src/model/textproxy.js +31 -30
- package/src/model/treewalker.d.ts +37 -37
- package/src/model/treewalker.js +14 -14
- package/src/model/typecheckable.d.ts +45 -45
- package/src/model/typecheckable.js +1 -1
- package/src/model/utils/autoparagraphing.d.ts +7 -7
- package/src/model/utils/deletecontent.d.ts +7 -5
- package/src/model/utils/deletecontent.js +13 -11
- package/src/model/utils/getselectedcontent.d.ts +6 -5
- package/src/model/utils/getselectedcontent.js +2 -1
- package/src/model/utils/insertcontent.d.ts +9 -8
- package/src/model/utils/insertcontent.js +41 -40
- package/src/model/utils/insertobject.d.ts +9 -9
- package/src/model/utils/insertobject.js +4 -4
- package/src/model/utils/modifyselection.d.ts +5 -4
- package/src/model/utils/modifyselection.js +12 -11
- package/src/model/utils/selection-post-fixer.d.ts +12 -8
- package/src/model/utils/selection-post-fixer.js +15 -11
- package/src/model/writer.d.ts +102 -101
- package/src/model/writer.js +99 -98
- package/src/view/attributeelement.d.ts +29 -29
- package/src/view/attributeelement.js +25 -25
- package/src/view/containerelement.d.ts +16 -15
- package/src/view/containerelement.js +15 -14
- package/src/view/datatransfer.d.ts +7 -7
- package/src/view/datatransfer.js +1 -1
- package/src/view/document.d.ts +25 -25
- package/src/view/document.js +15 -15
- package/src/view/documentfragment.d.ts +21 -21
- package/src/view/documentfragment.js +14 -14
- package/src/view/documentselection.d.ts +65 -63
- package/src/view/documentselection.js +27 -25
- package/src/view/domconverter.d.ts +94 -89
- package/src/view/domconverter.js +78 -73
- package/src/view/downcastwriter.d.ts +185 -181
- package/src/view/downcastwriter.js +222 -210
- package/src/view/editableelement.d.ts +13 -13
- package/src/view/editableelement.js +8 -8
- package/src/view/element.d.ts +75 -74
- package/src/view/element.js +58 -58
- package/src/view/elementdefinition.d.ts +3 -4
- package/src/view/emptyelement.d.ts +13 -13
- package/src/view/emptyelement.js +13 -13
- package/src/view/filler.d.ts +14 -3
- package/src/view/filler.js +12 -1
- package/src/view/item.d.ts +4 -5
- package/src/view/matcher.d.ts +22 -19
- package/src/view/matcher.js +6 -6
- package/src/view/node.d.ts +33 -33
- package/src/view/node.js +9 -9
- package/src/view/observer/arrowkeysobserver.d.ts +10 -10
- package/src/view/observer/arrowkeysobserver.js +5 -5
- package/src/view/observer/bubblingemittermixin.d.ts +5 -5
- package/src/view/observer/bubblingemittermixin.js +2 -9
- package/src/view/observer/bubblingeventinfo.d.ts +9 -9
- package/src/view/observer/bubblingeventinfo.js +1 -1
- package/src/view/observer/clickobserver.d.ts +8 -8
- package/src/view/observer/clickobserver.js +4 -4
- package/src/view/observer/compositionobserver.d.ts +19 -19
- package/src/view/observer/compositionobserver.js +6 -6
- package/src/view/observer/domeventdata.d.ts +9 -9
- package/src/view/observer/domeventdata.js +2 -2
- package/src/view/observer/domeventobserver.d.ts +3 -3
- package/src/view/observer/domeventobserver.js +5 -5
- package/src/view/observer/fakeselectionobserver.d.ts +9 -9
- package/src/view/observer/fakeselectionobserver.js +8 -8
- package/src/view/observer/focusobserver.d.ts +16 -16
- package/src/view/observer/focusobserver.js +7 -7
- package/src/view/observer/inputobserver.d.ts +18 -18
- package/src/view/observer/inputobserver.js +5 -5
- package/src/view/observer/keyobserver.d.ts +11 -11
- package/src/view/observer/keyobserver.js +3 -3
- package/src/view/observer/mouseobserver.d.ts +16 -16
- package/src/view/observer/mouseobserver.js +3 -3
- package/src/view/observer/mutationobserver.d.ts +21 -21
- package/src/view/observer/mutationobserver.js +7 -7
- package/src/view/observer/observer.d.ts +12 -12
- package/src/view/observer/observer.js +6 -6
- package/src/view/observer/selectionobserver.d.ts +33 -33
- package/src/view/observer/selectionobserver.js +14 -14
- package/src/view/observer/tabobserver.d.ts +10 -10
- package/src/view/observer/tabobserver.js +5 -5
- package/src/view/observer/touchobserver.d.ts +13 -13
- package/src/view/observer/touchobserver.js +3 -3
- package/src/view/placeholder.d.ts +21 -21
- package/src/view/placeholder.js +23 -23
- package/src/view/position.d.ts +49 -49
- package/src/view/position.js +42 -42
- package/src/view/range.d.ts +76 -74
- package/src/view/range.js +67 -65
- package/src/view/rawelement.d.ts +19 -19
- package/src/view/rawelement.js +16 -16
- package/src/view/renderer.d.ts +14 -14
- package/src/view/renderer.js +7 -7
- package/src/view/rooteditableelement.d.ts +8 -7
- package/src/view/rooteditableelement.js +7 -6
- package/src/view/selection.d.ts +66 -64
- package/src/view/selection.js +50 -48
- package/src/view/styles/background.d.ts +2 -2
- package/src/view/styles/background.js +9 -9
- package/src/view/styles/border.d.ts +2 -2
- package/src/view/styles/border.js +13 -13
- package/src/view/styles/margin.d.ts +2 -2
- package/src/view/styles/margin.js +5 -5
- package/src/view/styles/padding.d.ts +2 -2
- package/src/view/styles/padding.js +5 -5
- package/src/view/styles/utils.d.ts +24 -24
- package/src/view/styles/utils.js +25 -25
- package/src/view/stylesmap.d.ts +28 -32
- package/src/view/stylesmap.js +52 -39
- package/src/view/text.d.ts +11 -11
- package/src/view/text.js +10 -10
- package/src/view/textproxy.d.ts +33 -32
- package/src/view/textproxy.js +23 -22
- package/src/view/tokenlist.d.ts +14 -14
- package/src/view/tokenlist.js +10 -10
- package/src/view/treewalker.d.ts +42 -40
- package/src/view/treewalker.js +36 -35
- package/src/view/typecheckable.d.ts +76 -75
- package/src/view/typecheckable.js +1 -1
- package/src/view/uielement.d.ts +22 -21
- package/src/view/uielement.js +17 -16
- package/src/view/upcastwriter.d.ts +70 -70
- package/src/view/upcastwriter.js +42 -42
- package/src/view/view.d.ts +70 -69
- package/src/view/view.js +56 -55
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module engine/conversion/downcasthelpers
|
|
9
9
|
*/
|
|
10
|
-
import ModelRange from '../model/range.js';
|
|
11
|
-
import ModelSelection from '../model/selection.js';
|
|
12
|
-
import ModelDocumentSelection from '../model/documentselection.js';
|
|
13
|
-
import ModelElement from '../model/element.js';
|
|
14
|
-
import ModelPosition from '../model/position.js';
|
|
15
|
-
import ViewAttributeElement from '../view/attributeelement.js';
|
|
16
|
-
import ConversionHelpers from './conversionhelpers.js';
|
|
17
|
-
import StylesMap from '../view/stylesmap.js';
|
|
10
|
+
import { ModelRange } from '../model/range.js';
|
|
11
|
+
import { ModelSelection } from '../model/selection.js';
|
|
12
|
+
import { ModelDocumentSelection } from '../model/documentselection.js';
|
|
13
|
+
import { ModelElement } from '../model/element.js';
|
|
14
|
+
import { ModelPosition } from '../model/position.js';
|
|
15
|
+
import { ViewAttributeElement } from '../view/attributeelement.js';
|
|
16
|
+
import { ConversionHelpers } from './conversionhelpers.js';
|
|
17
|
+
import { StylesMap } from '../view/stylesmap.js';
|
|
18
18
|
import { CKEditorError, toArray } from '@ckeditor/ckeditor5-utils';
|
|
19
19
|
import { cloneDeep } from 'es-toolkit/compat';
|
|
20
20
|
/**
|
|
@@ -24,7 +24,7 @@ import { cloneDeep } from 'es-toolkit/compat';
|
|
|
24
24
|
*
|
|
25
25
|
* @extends module:engine/conversion/conversionhelpers~ConversionHelpers
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export class DowncastHelpers extends ConversionHelpers {
|
|
28
28
|
/**
|
|
29
29
|
* Model element to view element conversion helper.
|
|
30
30
|
*
|
|
@@ -505,7 +505,7 @@ export default class DowncastHelpers extends ConversionHelpers {
|
|
|
505
505
|
* If a function is passed as the `config.view` parameter, it will be used to generate both boundary elements. The function
|
|
506
506
|
* receives the `data` object and {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API}
|
|
507
507
|
* as a parameters and should return an instance of the
|
|
508
|
-
* {@link module:engine/view/uielement~
|
|
508
|
+
* {@link module:engine/view/uielement~ViewUIElement view UI element}. The `data` object and
|
|
509
509
|
* {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi `conversionApi`} are passed from
|
|
510
510
|
* {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:addMarker}. Additionally,
|
|
511
511
|
* the `data.isOpening` parameter is passed, which is set to `true` for the marker start boundary element, and `false` for
|
|
@@ -528,13 +528,13 @@ export default class DowncastHelpers extends ConversionHelpers {
|
|
|
528
528
|
* Model marker to highlight conversion helper.
|
|
529
529
|
*
|
|
530
530
|
* This conversion results in creating a highlight on view nodes. For this kind of conversion,
|
|
531
|
-
* the {@link module:engine/conversion/downcasthelpers~
|
|
531
|
+
* the {@link module:engine/conversion/downcasthelpers~DowncastHighlightDescriptor} should be provided.
|
|
532
532
|
*
|
|
533
|
-
* For text nodes, a `<span>` {@link module:engine/view/attributeelement~
|
|
533
|
+
* For text nodes, a `<span>` {@link module:engine/view/attributeelement~ViewAttributeElement} is created and it wraps all text nodes
|
|
534
534
|
* in the converted marker range. For example, a model marker set like this: `<paragraph>F[oo b]ar</paragraph>` becomes
|
|
535
535
|
* `<p>F<span class="comment">oo b</span>ar</p>` in the view.
|
|
536
536
|
*
|
|
537
|
-
* {@link module:engine/view/containerelement~
|
|
537
|
+
* {@link module:engine/view/containerelement~ViewContainerElement} may provide a custom way of handling highlight. Most often,
|
|
538
538
|
* the element itself is given classes and attributes described in the highlight descriptor (instead of being wrapped in `<span>`).
|
|
539
539
|
* For example, a model marker set like this:
|
|
540
540
|
* `[<imageInline src="foo.jpg"></imageInline>]` becomes `<img src="foo.jpg" class="comment"></img>` in the view.
|
|
@@ -569,7 +569,7 @@ export default class DowncastHelpers extends ConversionHelpers {
|
|
|
569
569
|
* If a function is passed as the `config.view` parameter, it will be used to generate the highlight descriptor. The function
|
|
570
570
|
* receives the `data` object and {@link module:engine/conversion/downcastdispatcher~DowncastConversionApi downcast conversion API}
|
|
571
571
|
* as the parameters and should return a
|
|
572
|
-
* {@link module:engine/conversion/downcasthelpers~
|
|
572
|
+
* {@link module:engine/conversion/downcasthelpers~DowncastHighlightDescriptor highlight descriptor}.
|
|
573
573
|
* The `data` object properties are passed from {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:addMarker}.
|
|
574
574
|
*
|
|
575
575
|
* See {@link module:engine/conversion/conversion~Conversion#for `conversion.for()`} to learn how to add a converter
|
|
@@ -720,6 +720,7 @@ export default class DowncastHelpers extends ConversionHelpers {
|
|
|
720
720
|
* ```
|
|
721
721
|
*
|
|
722
722
|
* @returns Insert text event converter.
|
|
723
|
+
* @internal
|
|
723
724
|
*/
|
|
724
725
|
export function insertText() {
|
|
725
726
|
return (evt, data, conversionApi) => {
|
|
@@ -736,6 +737,7 @@ export function insertText() {
|
|
|
736
737
|
* Function factory that creates a default downcast converter for triggering attributes and children conversion.
|
|
737
738
|
*
|
|
738
739
|
* @returns The converter.
|
|
740
|
+
* @internal
|
|
739
741
|
*/
|
|
740
742
|
export function insertAttributesAndChildren() {
|
|
741
743
|
return (evt, data, conversionApi) => {
|
|
@@ -755,6 +757,7 @@ export function insertAttributesAndChildren() {
|
|
|
755
757
|
* ```
|
|
756
758
|
*
|
|
757
759
|
* @returns Remove event converter.
|
|
760
|
+
* @internal
|
|
758
761
|
*/
|
|
759
762
|
export function remove() {
|
|
760
763
|
return (evt, data, conversionApi) => {
|
|
@@ -773,11 +776,13 @@ export function remove() {
|
|
|
773
776
|
};
|
|
774
777
|
}
|
|
775
778
|
/**
|
|
776
|
-
* Creates a `<span>` {@link module:engine/view/attributeelement~
|
|
777
|
-
* provided by the {@link module:engine/conversion/downcasthelpers~
|
|
779
|
+
* Creates a `<span>` {@link module:engine/view/attributeelement~ViewAttributeElement view attribute element} from the information
|
|
780
|
+
* provided by the {@link module:engine/conversion/downcasthelpers~DowncastHighlightDescriptor highlight descriptor} object. If the priority
|
|
778
781
|
* is not provided in the descriptor, the default priority will be used.
|
|
782
|
+
*
|
|
783
|
+
* @internal
|
|
779
784
|
*/
|
|
780
|
-
export function
|
|
785
|
+
export function createViewElementFromDowncastHighlightDescriptor(writer, descriptor) {
|
|
781
786
|
const viewElement = writer.createAttributeElement('span', descriptor.attributes);
|
|
782
787
|
if (descriptor.classes) {
|
|
783
788
|
viewElement._addClass(descriptor.classes);
|
|
@@ -789,8 +794,9 @@ export function createViewElementFromHighlightDescriptor(writer, descriptor) {
|
|
|
789
794
|
return viewElement;
|
|
790
795
|
}
|
|
791
796
|
/**
|
|
792
|
-
* Function factory that creates a converter which converts a non-collapsed
|
|
793
|
-
*
|
|
797
|
+
* Function factory that creates a converter which converts a non-collapsed
|
|
798
|
+
* {@link module:engine/model/selection~ModelSelection model selection}
|
|
799
|
+
* to a {@link module:engine/view/documentselection~ViewDocumentSelection view selection}. The converter consumes appropriate
|
|
794
800
|
* value from the `consumable` object and maps model positions from the selection to view positions.
|
|
795
801
|
*
|
|
796
802
|
* ```ts
|
|
@@ -798,6 +804,7 @@ export function createViewElementFromHighlightDescriptor(writer, descriptor) {
|
|
|
798
804
|
* ```
|
|
799
805
|
*
|
|
800
806
|
* @returns Selection converter.
|
|
807
|
+
* @internal
|
|
801
808
|
*/
|
|
802
809
|
export function convertRangeSelection() {
|
|
803
810
|
return (evt, data, conversionApi) => {
|
|
@@ -816,10 +823,11 @@ export function convertRangeSelection() {
|
|
|
816
823
|
};
|
|
817
824
|
}
|
|
818
825
|
/**
|
|
819
|
-
* Function factory that creates a converter which converts a collapsed
|
|
820
|
-
*
|
|
826
|
+
* Function factory that creates a converter which converts a collapsed
|
|
827
|
+
* {@link module:engine/model/selection~ModelSelection model selection} to
|
|
828
|
+
* a {@link module:engine/view/documentselection~ViewDocumentSelection view selection}. The converter consumes appropriate
|
|
821
829
|
* value from the `consumable` object, maps the model selection position to the view position and breaks
|
|
822
|
-
* {@link module:engine/view/attributeelement~
|
|
830
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements} at the selection position.
|
|
823
831
|
*
|
|
824
832
|
* ```ts
|
|
825
833
|
* modelDispatcher.on( 'selection', convertCollapsedSelection() );
|
|
@@ -840,6 +848,7 @@ export function convertRangeSelection() {
|
|
|
840
848
|
* by merging attributes.
|
|
841
849
|
*
|
|
842
850
|
* @returns Selection converter.
|
|
851
|
+
* @internal
|
|
843
852
|
*/
|
|
844
853
|
export function convertCollapsedSelection() {
|
|
845
854
|
return (evt, data, conversionApi) => {
|
|
@@ -859,9 +868,9 @@ export function convertCollapsedSelection() {
|
|
|
859
868
|
}
|
|
860
869
|
/**
|
|
861
870
|
* Function factory that creates a converter which cleans artifacts after the previous
|
|
862
|
-
* {@link module:engine/model/selection~
|
|
863
|
-
* {@link module:engine/view/attributeelement~
|
|
864
|
-
* positions of all ranges.
|
|
871
|
+
* {@link module:engine/model/selection~ModelSelection model selection} conversion. It removes all empty
|
|
872
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement view attribute elements} and merges
|
|
873
|
+
* sibling attributes at all start and end positions of all ranges.
|
|
865
874
|
*
|
|
866
875
|
* ```
|
|
867
876
|
* <p><strong>^</strong></p>
|
|
@@ -884,6 +893,7 @@ export function convertCollapsedSelection() {
|
|
|
884
893
|
* which does the opposite by breaking attributes in the selection position.
|
|
885
894
|
*
|
|
886
895
|
* @returns Selection converter.
|
|
896
|
+
* @internal
|
|
887
897
|
*/
|
|
888
898
|
export function cleanSelection() {
|
|
889
899
|
return (evt, data, conversionApi) => {
|
|
@@ -919,7 +929,7 @@ export function cleanSelection() {
|
|
|
919
929
|
*
|
|
920
930
|
* Passed `Function` will be provided with the attribute value and then all the parameters of the
|
|
921
931
|
* {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:attribute `attribute` event}.
|
|
922
|
-
* It is expected that the function returns an {@link module:engine/view/element~
|
|
932
|
+
* It is expected that the function returns an {@link module:engine/view/element~ViewElement}.
|
|
923
933
|
* The result of the function will be the wrapping element.
|
|
924
934
|
* When the provided `Function` does not return any element, no conversion will take place.
|
|
925
935
|
*
|
|
@@ -973,7 +983,7 @@ export function wrap(elementCreator) {
|
|
|
973
983
|
* Function factory that creates a converter which converts node insertion changes from the model to the view.
|
|
974
984
|
* The function passed will be provided with all the parameters of the dispatcher's
|
|
975
985
|
* {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher#event:insert `insert` event}.
|
|
976
|
-
* It is expected that the function returns an {@link module:engine/view/element~
|
|
986
|
+
* It is expected that the function returns an {@link module:engine/view/element~ViewElement}.
|
|
977
987
|
* The result of the function will be inserted into the view.
|
|
978
988
|
*
|
|
979
989
|
* The converter automatically consumes the corresponding value from the consumables list and binds the model and view elements.
|
|
@@ -1021,7 +1031,7 @@ export function insertElement(elementCreator, consumer = defaultConsumer) {
|
|
|
1021
1031
|
/**
|
|
1022
1032
|
* Function factory that creates a converter which converts a single model node insertion to a view structure.
|
|
1023
1033
|
*
|
|
1024
|
-
* It is expected that the passed element creator function returns an {@link module:engine/view/element~
|
|
1034
|
+
* It is expected that the passed element creator function returns an {@link module:engine/view/element~ViewElement} with attached slots
|
|
1025
1035
|
* created with `writer.createSlot()` to indicate where child nodes should be converted.
|
|
1026
1036
|
*
|
|
1027
1037
|
* @see module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure
|
|
@@ -1060,7 +1070,7 @@ export function insertStructure(elementCreator, consumer) {
|
|
|
1060
1070
|
}
|
|
1061
1071
|
/**
|
|
1062
1072
|
* Function factory that creates a converter which converts marker adding change to the
|
|
1063
|
-
* {@link module:engine/view/uielement~
|
|
1073
|
+
* {@link module:engine/view/uielement~ViewUIElement view UI element}.
|
|
1064
1074
|
*
|
|
1065
1075
|
* The view UI element that will be added to the view depends on the passed parameter. See {@link ~insertElement}.
|
|
1066
1076
|
* In case of a non-collapsed range, the UI element will not wrap nodes but separate elements will be placed at the beginning
|
|
@@ -1110,7 +1120,7 @@ export function insertUIElement(elementCreator) {
|
|
|
1110
1120
|
};
|
|
1111
1121
|
}
|
|
1112
1122
|
/**
|
|
1113
|
-
* Function factory that returns a default downcast converter for removing a {@link module:engine/view/uielement~
|
|
1123
|
+
* Function factory that returns a default downcast converter for removing a {@link module:engine/view/uielement~ViewUIElement UI element}
|
|
1114
1124
|
* based on marker remove change.
|
|
1115
1125
|
*
|
|
1116
1126
|
* This converter unbinds elements from the marker name.
|
|
@@ -1284,7 +1294,7 @@ function removeMarkerData(viewCreator) {
|
|
|
1284
1294
|
* ```
|
|
1285
1295
|
*
|
|
1286
1296
|
* @param attributeCreator Function returning an object with two properties: `key` and `value`, which
|
|
1287
|
-
* represent the attribute key and attribute value to be set on a {@link module:engine/view/element~
|
|
1297
|
+
* represent the attribute key and attribute value to be set on a {@link module:engine/view/element~ViewElement view element}.
|
|
1288
1298
|
* The function is passed the model attribute value as the first parameter and additional data about the change as the second parameter.
|
|
1289
1299
|
* @returns Set/change attribute converter.
|
|
1290
1300
|
*/
|
|
@@ -1301,11 +1311,11 @@ function changeAttribute(attributeCreator) {
|
|
|
1301
1311
|
conversionApi.consumable.consume(data.item, evt.name);
|
|
1302
1312
|
const viewElement = conversionApi.mapper.toViewElement(data.item);
|
|
1303
1313
|
const viewWriter = conversionApi.writer;
|
|
1304
|
-
// If model item cannot be mapped to a view element, it means item is not an `Element` instance but a `
|
|
1314
|
+
// If model item cannot be mapped to a view element, it means item is not an `Element` instance but a `ModelTextProxy` node.
|
|
1305
1315
|
// Only elements can have attributes in a view so do not proceed for anything else (#1587).
|
|
1306
1316
|
if (!viewElement) {
|
|
1307
1317
|
/**
|
|
1308
|
-
* This error occurs when a {@link module:engine/model/textproxy~
|
|
1318
|
+
* This error occurs when a {@link module:engine/model/textproxy~ModelTextProxy text node's} attribute is to be downcasted
|
|
1309
1319
|
* by an {@link module:engine/conversion/conversion~Conversion#attributeToAttribute `Attribute to Attribute converter`}.
|
|
1310
1320
|
* In most cases it is caused by converters misconfiguration when only "generic" converter is defined:
|
|
1311
1321
|
*
|
|
@@ -1324,8 +1334,8 @@ function changeAttribute(attributeCreator) {
|
|
|
1324
1334
|
* } );
|
|
1325
1335
|
* ```
|
|
1326
1336
|
*
|
|
1327
|
-
* In such cases, to convert the same attribute for both {@link module:engine/model/element~
|
|
1328
|
-
* and {@link module:engine/model/textproxy~
|
|
1337
|
+
* In such cases, to convert the same attribute for both {@link module:engine/model/element~ModelElement}
|
|
1338
|
+
* and {@link module:engine/model/textproxy~ModelTextProxy `Text`} nodes, text specific
|
|
1329
1339
|
* {@link module:engine/conversion/conversion~Conversion#attributeToElement `Attribute to Element converter`}
|
|
1330
1340
|
* with higher {@link module:utils/priorities~PriorityString priority} must also be defined:
|
|
1331
1341
|
*
|
|
@@ -1377,8 +1387,8 @@ function changeAttribute(attributeCreator) {
|
|
|
1377
1387
|
}
|
|
1378
1388
|
/**
|
|
1379
1389
|
* Function factory that creates a converter which converts the text inside marker's range. The converter wraps the text with
|
|
1380
|
-
* {@link module:engine/view/attributeelement~
|
|
1381
|
-
* See {link module:engine/conversion/downcasthelpers~
|
|
1390
|
+
* {@link module:engine/view/attributeelement~ViewAttributeElement} created from the provided descriptor.
|
|
1391
|
+
* See {link module:engine/conversion/downcasthelpers~createViewElementFromDowncastHighlightDescriptor}.
|
|
1382
1392
|
*
|
|
1383
1393
|
* It can also be used to convert the selection that is inside a marker. In that case, an empty attribute element will be
|
|
1384
1394
|
* created and the selection will be put inside it.
|
|
@@ -1387,7 +1397,7 @@ function changeAttribute(attributeCreator) {
|
|
|
1387
1397
|
*
|
|
1388
1398
|
* If the highlight descriptor does not provide the `id` property, the name of the marker will be used.
|
|
1389
1399
|
*
|
|
1390
|
-
* This converter binds the created {@link module:engine/view/attributeelement~
|
|
1400
|
+
* This converter binds the created {@link module:engine/view/attributeelement~ViewAttributeElement attribute elemens} with the marker name
|
|
1391
1401
|
* using the {@link module:engine/conversion/mapper~Mapper#bindElementToMarker} method.
|
|
1392
1402
|
*/
|
|
1393
1403
|
function highlightText(highlightDescriptor) {
|
|
@@ -1406,7 +1416,7 @@ function highlightText(highlightDescriptor) {
|
|
|
1406
1416
|
return;
|
|
1407
1417
|
}
|
|
1408
1418
|
const viewWriter = conversionApi.writer;
|
|
1409
|
-
const viewElement =
|
|
1419
|
+
const viewElement = createViewElementFromDowncastHighlightDescriptor(viewWriter, descriptor);
|
|
1410
1420
|
const viewSelection = viewWriter.document.selection;
|
|
1411
1421
|
if (data.item instanceof ModelSelection || data.item instanceof ModelDocumentSelection) {
|
|
1412
1422
|
viewWriter.wrap(viewSelection.getFirstRange(), viewElement);
|
|
@@ -1429,7 +1439,7 @@ function highlightText(highlightDescriptor) {
|
|
|
1429
1439
|
* Converter function factory. It creates a function which applies the marker's highlight to an element inside the marker's range.
|
|
1430
1440
|
*
|
|
1431
1441
|
* The converter checks if an element has the `addHighlight` function stored as a
|
|
1432
|
-
* {@link module:engine/view/element~
|
|
1442
|
+
* {@link module:engine/view/element~ViewElement#_setCustomProperty custom property} and, if so, uses it to apply the highlight.
|
|
1433
1443
|
* In such case the converter will consume all element's children, assuming that they were handled by the element itself.
|
|
1434
1444
|
*
|
|
1435
1445
|
* When the `addHighlight` custom property is not present, the element is not converted in any special way.
|
|
@@ -1439,8 +1449,8 @@ function highlightText(highlightDescriptor) {
|
|
|
1439
1449
|
*
|
|
1440
1450
|
* If the highlight descriptor does not provide the `id` property, the name of the marker will be used.
|
|
1441
1451
|
*
|
|
1442
|
-
* This converter binds altered {@link module:engine/view/containerelement~
|
|
1443
|
-
* the {@link module:engine/conversion/mapper~Mapper#bindElementToMarker} method.
|
|
1452
|
+
* This converter binds altered {@link module:engine/view/containerelement~ViewContainerElement container elements}
|
|
1453
|
+
* with the marker name using the {@link module:engine/conversion/mapper~Mapper#bindElementToMarker} method.
|
|
1444
1454
|
*/
|
|
1445
1455
|
function highlightElement(highlightDescriptor) {
|
|
1446
1456
|
return (evt, data, conversionApi) => {
|
|
@@ -1476,11 +1486,11 @@ function highlightElement(highlightDescriptor) {
|
|
|
1476
1486
|
*
|
|
1477
1487
|
* Both text nodes and elements are handled by this converter but they are handled a bit differently.
|
|
1478
1488
|
*
|
|
1479
|
-
* Text nodes are unwrapped using the {@link module:engine/view/attributeelement~
|
|
1480
|
-
* provided highlight descriptor. See {link module:engine/conversion/downcasthelpers~
|
|
1489
|
+
* Text nodes are unwrapped using the {@link module:engine/view/attributeelement~ViewAttributeElement attribute element} created from the
|
|
1490
|
+
* provided highlight descriptor. See {link module:engine/conversion/downcasthelpers~DowncastHighlightDescriptor}.
|
|
1481
1491
|
*
|
|
1482
1492
|
* For elements, the converter checks if an element has the `removeHighlight` function stored as a
|
|
1483
|
-
* {@link module:engine/view/element~
|
|
1493
|
+
* {@link module:engine/view/element~ViewElement#_setCustomProperty custom property}. If so, it uses it to remove the highlight.
|
|
1484
1494
|
* In such case, the children of that element will not be converted.
|
|
1485
1495
|
*
|
|
1486
1496
|
* When `removeHighlight` is not present, the element is not converted in any special way.
|
|
@@ -1503,7 +1513,7 @@ function removeHighlight(highlightDescriptor) {
|
|
|
1503
1513
|
return;
|
|
1504
1514
|
}
|
|
1505
1515
|
// View element that will be used to unwrap `AttributeElement`s.
|
|
1506
|
-
const viewHighlightElement =
|
|
1516
|
+
const viewHighlightElement = createViewElementFromDowncastHighlightDescriptor(conversionApi.writer, descriptor);
|
|
1507
1517
|
// Get all elements bound with given marker name.
|
|
1508
1518
|
const elements = conversionApi.mapper.markerNameToElements(data.markerName);
|
|
1509
1519
|
if (!elements) {
|
|
@@ -1567,9 +1577,9 @@ function downcastElementToStructure(config) {
|
|
|
1567
1577
|
return (dispatcher) => {
|
|
1568
1578
|
if (dispatcher._conversionApi.schema.checkChild(model.name, '$text')) {
|
|
1569
1579
|
/**
|
|
1570
|
-
* This error occurs when a {@link module:engine/model/element~
|
|
1580
|
+
* This error occurs when a {@link module:engine/model/element~ModelElement model element} is downcasted
|
|
1571
1581
|
* via {@link module:engine/conversion/downcasthelpers~DowncastHelpers#elementToStructure} helper but the element was
|
|
1572
|
-
* allowed to host `$text` by the {@link module:engine/model/schema~
|
|
1582
|
+
* allowed to host `$text` by the {@link module:engine/model/schema~ModelSchema model schema}.
|
|
1573
1583
|
*
|
|
1574
1584
|
* For instance, this may be the result of `myElement` allowing the content of
|
|
1575
1585
|
* {@glink framework/deep-dive/schema#generic-items `$block`} in its schema definition:
|
|
@@ -1623,7 +1633,7 @@ function downcastElementToStructure(config) {
|
|
|
1623
1633
|
* @param config.model The key of the attribute to convert from or a `{ key, values }` object. `values` is an array
|
|
1624
1634
|
* of `String`s with possible values if the model attribute is an enumerable.
|
|
1625
1635
|
* @param config.view A view element definition or a function that takes the model attribute value and
|
|
1626
|
-
* {@link module:engine/view/downcastwriter~
|
|
1636
|
+
* {@link module:engine/view/downcastwriter~ViewDowncastWriter view downcast writer} as parameters and returns a view attribute element.
|
|
1627
1637
|
* If `config.model.values` is given, `config.view` should be an object assigning values from `config.model.values` to view element
|
|
1628
1638
|
* definitions or functions.
|
|
1629
1639
|
* @param config.converterPriority Converter priority.
|
|
@@ -1768,7 +1778,7 @@ function normalizeModelElementConfig(model) {
|
|
|
1768
1778
|
};
|
|
1769
1779
|
}
|
|
1770
1780
|
/**
|
|
1771
|
-
* Takes `config.view`, and if it is an {@link module:engine/view/elementdefinition~
|
|
1781
|
+
* Takes `config.view`, and if it is an {@link module:engine/view/elementdefinition~ViewElementDefinition}, converts it
|
|
1772
1782
|
* to a function (because lower level converters accept only element creator functions).
|
|
1773
1783
|
*
|
|
1774
1784
|
* @param view View configuration.
|
|
@@ -1783,7 +1793,7 @@ function normalizeToElementConfig(view, viewElementType) {
|
|
|
1783
1793
|
return ((modelData, conversionApi) => createViewElementFromDefinition(view, conversionApi, viewElementType));
|
|
1784
1794
|
}
|
|
1785
1795
|
/**
|
|
1786
|
-
* Creates a view element instance from the provided {@link module:engine/view/elementdefinition~
|
|
1796
|
+
* Creates a view element instance from the provided {@link module:engine/view/elementdefinition~ViewElementDefinition} and class.
|
|
1787
1797
|
*/
|
|
1788
1798
|
function createViewElementFromDefinition(viewElementDefinition, conversionApi, viewElementType) {
|
|
1789
1799
|
if (typeof viewElementDefinition == 'string') {
|
|
@@ -2033,7 +2043,7 @@ function validateSlotsChildren(element, slotsMap, conversionApi) {
|
|
|
2033
2043
|
* Filters provided to `writer.createSlot()` overlap (at least two filters accept the same child element).
|
|
2034
2044
|
*
|
|
2035
2045
|
* @error conversion-slot-filter-overlap
|
|
2036
|
-
* @param {module:engine/model/element~
|
|
2046
|
+
* @param {module:engine/model/element~ModelElement} element The element of which children would not be properly
|
|
2037
2047
|
* allocated to multiple slots.
|
|
2038
2048
|
*/
|
|
2039
2049
|
throw new CKEditorError('conversion-slot-filter-overlap', conversionApi.dispatcher, { element });
|
|
@@ -2044,7 +2054,7 @@ function validateSlotsChildren(element, slotsMap, conversionApi) {
|
|
|
2044
2054
|
* the children elements would not be assigned to any of the slots).
|
|
2045
2055
|
*
|
|
2046
2056
|
* @error conversion-slot-filter-incomplete
|
|
2047
|
-
* @param {module:engine/model/element~
|
|
2057
|
+
* @param {module:engine/model/element~ModelElement} element The element of which children would not be properly
|
|
2048
2058
|
* allocated to multiple slots.
|
|
2049
2059
|
*/
|
|
2050
2060
|
throw new CKEditorError('conversion-slot-filter-incomplete', conversionApi.dispatcher, { element });
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/conversion/mapper
|
|
7
7
|
*/
|
|
8
|
-
import ModelPosition from '../model/position.js';
|
|
9
|
-
import ModelRange from '../model/range.js';
|
|
10
|
-
import ViewPosition from '../view/position.js';
|
|
11
|
-
import ViewRange from '../view/range.js';
|
|
12
|
-
import type ViewDocumentFragment from '../view/documentfragment.js';
|
|
13
|
-
import type ViewElement from '../view/element.js';
|
|
14
|
-
import type ModelElement from '../model/element.js';
|
|
15
|
-
import type ModelDocumentFragment from '../model/documentfragment.js';
|
|
16
|
-
import type {
|
|
8
|
+
import { ModelPosition } from '../model/position.js';
|
|
9
|
+
import { ModelRange } from '../model/range.js';
|
|
10
|
+
import { ViewPosition } from '../view/position.js';
|
|
11
|
+
import { ViewRange } from '../view/range.js';
|
|
12
|
+
import { type ViewDocumentFragment } from '../view/documentfragment.js';
|
|
13
|
+
import { type ViewElement } from '../view/element.js';
|
|
14
|
+
import { type ModelElement } from '../model/element.js';
|
|
15
|
+
import { type ModelDocumentFragment } from '../model/documentfragment.js';
|
|
16
|
+
import type { ViewNode } from '../view/node.js';
|
|
17
17
|
declare const Mapper_base: {
|
|
18
18
|
new (): import("@ckeditor/ckeditor5-utils").Emitter;
|
|
19
19
|
prototype: import("@ckeditor/ckeditor5-utils").Emitter;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* Maps elements, positions and markers between the {@link module:engine/view/document~
|
|
22
|
+
* Maps elements, positions and markers between the {@link module:engine/view/document~ViewDocument view} and
|
|
23
23
|
* the {@link module:engine/model/model model}.
|
|
24
24
|
*
|
|
25
25
|
* The instance of the Mapper used for the editing pipeline is available in
|
|
@@ -37,7 +37,7 @@ declare const Mapper_base: {
|
|
|
37
37
|
* with `'lowest'` priority. To override default `Mapper` mapping, add custom callback with higher priority and
|
|
38
38
|
* stop the event.
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export declare class Mapper extends /* #__PURE__ */ Mapper_base {
|
|
41
41
|
/**
|
|
42
42
|
* Model element to view element mapping.
|
|
43
43
|
*/
|
|
@@ -54,7 +54,7 @@ export default class Mapper extends /* #__PURE__ */ Mapper_base {
|
|
|
54
54
|
/**
|
|
55
55
|
* Model marker name to view elements mapping.
|
|
56
56
|
*
|
|
57
|
-
* Keys are `String`s while values are `Set`s with {@link module:engine/view/element~
|
|
57
|
+
* Keys are `String`s while values are `Set`s with {@link module:engine/view/element~ViewElement view elements}.
|
|
58
58
|
* One marker (name) can be mapped to multiple elements.
|
|
59
59
|
*/
|
|
60
60
|
private _markerNameToElements;
|
|
@@ -92,7 +92,7 @@ export default class Mapper extends /* #__PURE__ */ Mapper_base {
|
|
|
92
92
|
*/
|
|
93
93
|
bindElements(modelElement: ModelElement | ModelDocumentFragment, viewElement: ViewElement | ViewDocumentFragment): void;
|
|
94
94
|
/**
|
|
95
|
-
* Unbinds the given {@link module:engine/view/element~
|
|
95
|
+
* Unbinds the given {@link module:engine/view/element~ViewElement view element} from the map.
|
|
96
96
|
*
|
|
97
97
|
* **Note:** view-to-model binding will be removed, if it existed. However, corresponding model-to-view binding
|
|
98
98
|
* will be removed only if model element is still bound to the passed `viewElement`.
|
|
@@ -109,7 +109,7 @@ export default class Mapper extends /* #__PURE__ */ Mapper_base {
|
|
|
109
109
|
defer?: boolean;
|
|
110
110
|
}): void;
|
|
111
111
|
/**
|
|
112
|
-
* Unbinds the given {@link module:engine/model/element~
|
|
112
|
+
* Unbinds the given {@link module:engine/model/element~ModelElement model element} from the map.
|
|
113
113
|
*
|
|
114
114
|
* **Note:** the model-to-view binding will be removed, if it existed. However, the corresponding view-to-model binding
|
|
115
115
|
* will be removed only if the view element is still bound to the passed `modelElement`.
|
|
@@ -121,7 +121,7 @@ export default class Mapper extends /* #__PURE__ */ Mapper_base {
|
|
|
121
121
|
*/
|
|
122
122
|
unbindModelElement(modelElement: ModelElement): void;
|
|
123
123
|
/**
|
|
124
|
-
* Binds the given marker name with the given {@link module:engine/view/element~
|
|
124
|
+
* Binds the given marker name with the given {@link module:engine/view/element~ViewElement view element}. The element
|
|
125
125
|
* will be added to the current set of elements bound with the given marker name.
|
|
126
126
|
*
|
|
127
127
|
* @param element Element to bind.
|
|
@@ -153,7 +153,7 @@ export default class Mapper extends /* #__PURE__ */ Mapper_base {
|
|
|
153
153
|
/**
|
|
154
154
|
* Gets the corresponding model element.
|
|
155
155
|
*
|
|
156
|
-
* **Note:** {@link module:engine/view/uielement~
|
|
156
|
+
* **Note:** {@link module:engine/view/uielement~ViewUIElement} does not have corresponding element in model.
|
|
157
157
|
*
|
|
158
158
|
* @label ELEMENT
|
|
159
159
|
* @param viewElement View element.
|
|
@@ -299,11 +299,11 @@ export default class Mapper extends /* #__PURE__ */ Mapper_base {
|
|
|
299
299
|
* The length is calculated as follows:
|
|
300
300
|
* * if a {@link #registerViewToModelLength length mapping callback} is provided for the given `viewNode`, it is used to
|
|
301
301
|
* evaluate the model length (`viewNode` is used as first and only parameter passed to the callback),
|
|
302
|
-
* * length of a {@link module:engine/view/text~
|
|
303
|
-
* {@link module:engine/view/text~
|
|
304
|
-
* * length of a {@link module:engine/view/uielement~
|
|
305
|
-
* * length of a mapped {@link module:engine/view/element~
|
|
306
|
-
* * length of a non-mapped {@link module:engine/view/element~
|
|
302
|
+
* * length of a {@link module:engine/view/text~ViewText text node} is equal to the length of its
|
|
303
|
+
* {@link module:engine/view/text~ViewText#data data},
|
|
304
|
+
* * length of a {@link module:engine/view/uielement~ViewUIElement ui element} is equal to 0,
|
|
305
|
+
* * length of a mapped {@link module:engine/view/element~ViewElement element} is equal to 1,
|
|
306
|
+
* * length of a non-mapped {@link module:engine/view/element~ViewElement element} is equal to the length of its children.
|
|
307
307
|
*
|
|
308
308
|
* Examples:
|
|
309
309
|
*
|
|
@@ -553,8 +553,8 @@ export declare class MapperCache extends /* #__PURE__ */ MapperCache_base {
|
|
|
553
553
|
}
|
|
554
554
|
/**
|
|
555
555
|
* Fired for each model-to-view position mapping request. The purpose of this event is to enable custom model-to-view position
|
|
556
|
-
* mapping. Callbacks added to this event take {@link module:engine/model/position~
|
|
557
|
-
* calculate the {@link module:engine/view/position~
|
|
556
|
+
* mapping. Callbacks added to this event take {@link module:engine/model/position~ModelPosition model position} and are expected to
|
|
557
|
+
* calculate the {@link module:engine/view/position~ViewPosition view position}. The calculated view position should be added as
|
|
558
558
|
* a `viewPosition` value in the `data` object that is passed as one of parameters to the event callback.
|
|
559
559
|
*
|
|
560
560
|
* ```ts
|
|
@@ -624,7 +624,7 @@ export type MapperModelToViewPositionEvent = {
|
|
|
624
624
|
};
|
|
625
625
|
/**
|
|
626
626
|
* Data pipeline object that can store and pass data between callbacks. The callback should add
|
|
627
|
-
* the `viewPosition` value to that object with calculated the {@link module:engine/view/position~
|
|
627
|
+
* the `viewPosition` value to that object with calculated the {@link module:engine/view/position~ViewPosition view position}.
|
|
628
628
|
*/
|
|
629
629
|
export type MapperModelToViewPositionEventData = {
|
|
630
630
|
/**
|
|
@@ -637,7 +637,7 @@ export type MapperModelToViewPositionEventData = {
|
|
|
637
637
|
modelPosition: ModelPosition;
|
|
638
638
|
/**
|
|
639
639
|
* The callback should add the `viewPosition` value to that object with calculated the
|
|
640
|
-
* {@link module:engine/view/position~
|
|
640
|
+
* {@link module:engine/view/position~ViewPosition view position}.
|
|
641
641
|
*/
|
|
642
642
|
viewPosition?: ViewPosition;
|
|
643
643
|
/**
|
|
@@ -683,7 +683,7 @@ export type MapperViewToModelPositionEvent = {
|
|
|
683
683
|
};
|
|
684
684
|
/**
|
|
685
685
|
* Data pipeline object that can store and pass data between callbacks. The callback should add
|
|
686
|
-
* `modelPosition` value to that object with calculated {@link module:engine/model/position~
|
|
686
|
+
* `modelPosition` value to that object with calculated {@link module:engine/model/position~ModelPosition model position}.
|
|
687
687
|
*/
|
|
688
688
|
export type MapperViewToModelPositionEventData = {
|
|
689
689
|
/**
|
|
@@ -692,7 +692,7 @@ export type MapperViewToModelPositionEventData = {
|
|
|
692
692
|
mapper: Mapper;
|
|
693
693
|
/**
|
|
694
694
|
* The callback should add `modelPosition` value to that object with calculated
|
|
695
|
-
* {@link module:engine/model/position~
|
|
695
|
+
* {@link module:engine/model/position~ModelPosition model position}.
|
|
696
696
|
*/
|
|
697
697
|
modelPosition?: ModelPosition;
|
|
698
698
|
/**
|
package/src/conversion/mapper.js
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/conversion/mapper
|
|
7
7
|
*/
|
|
8
|
-
import ModelPosition from '../model/position.js';
|
|
9
|
-
import ModelRange from '../model/range.js';
|
|
10
|
-
import ViewPosition from '../view/position.js';
|
|
11
|
-
import ViewRange from '../view/range.js';
|
|
8
|
+
import { ModelPosition } from '../model/position.js';
|
|
9
|
+
import { ModelRange } from '../model/range.js';
|
|
10
|
+
import { ViewPosition } from '../view/position.js';
|
|
11
|
+
import { ViewRange } from '../view/range.js';
|
|
12
12
|
import { CKEditorError, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
13
13
|
/**
|
|
14
|
-
* Maps elements, positions and markers between the {@link module:engine/view/document~
|
|
14
|
+
* Maps elements, positions and markers between the {@link module:engine/view/document~ViewDocument view} and
|
|
15
15
|
* the {@link module:engine/model/model model}.
|
|
16
16
|
*
|
|
17
17
|
* The instance of the Mapper used for the editing pipeline is available in
|
|
@@ -29,7 +29,7 @@ import { CKEditorError, EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
|
29
29
|
* with `'lowest'` priority. To override default `Mapper` mapping, add custom callback with higher priority and
|
|
30
30
|
* stop the event.
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export class Mapper extends /* #__PURE__ */ EmitterMixin() {
|
|
33
33
|
/**
|
|
34
34
|
* Model element to view element mapping.
|
|
35
35
|
*/
|
|
@@ -46,7 +46,7 @@ export default class Mapper extends /* #__PURE__ */ EmitterMixin() {
|
|
|
46
46
|
/**
|
|
47
47
|
* Model marker name to view elements mapping.
|
|
48
48
|
*
|
|
49
|
-
* Keys are `String`s while values are `Set`s with {@link module:engine/view/element~
|
|
49
|
+
* Keys are `String`s while values are `Set`s with {@link module:engine/view/element~ViewElement view elements}.
|
|
50
50
|
* One marker (name) can be mapped to multiple elements.
|
|
51
51
|
*/
|
|
52
52
|
_markerNameToElements = new Map();
|
|
@@ -118,7 +118,7 @@ export default class Mapper extends /* #__PURE__ */ EmitterMixin() {
|
|
|
118
118
|
this._viewToModelMapping.set(viewElement, modelElement);
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
|
-
* Unbinds the given {@link module:engine/view/element~
|
|
121
|
+
* Unbinds the given {@link module:engine/view/element~ViewElement view element} from the map.
|
|
122
122
|
*
|
|
123
123
|
* **Note:** view-to-model binding will be removed, if it existed. However, corresponding model-to-view binding
|
|
124
124
|
* will be removed only if model element is still bound to the passed `viewElement`.
|
|
@@ -153,7 +153,7 @@ export default class Mapper extends /* #__PURE__ */ EmitterMixin() {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
|
-
* Unbinds the given {@link module:engine/model/element~
|
|
156
|
+
* Unbinds the given {@link module:engine/model/element~ModelElement model element} from the map.
|
|
157
157
|
*
|
|
158
158
|
* **Note:** the model-to-view binding will be removed, if it existed. However, the corresponding view-to-model binding
|
|
159
159
|
* will be removed only if the view element is still bound to the passed `modelElement`.
|
|
@@ -175,7 +175,7 @@ export default class Mapper extends /* #__PURE__ */ EmitterMixin() {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
|
-
* Binds the given marker name with the given {@link module:engine/view/element~
|
|
178
|
+
* Binds the given marker name with the given {@link module:engine/view/element~ViewElement view element}. The element
|
|
179
179
|
* will be added to the current set of elements bound with the given marker name.
|
|
180
180
|
*
|
|
181
181
|
* @param element Element to bind.
|
|
@@ -426,11 +426,11 @@ export default class Mapper extends /* #__PURE__ */ EmitterMixin() {
|
|
|
426
426
|
* The length is calculated as follows:
|
|
427
427
|
* * if a {@link #registerViewToModelLength length mapping callback} is provided for the given `viewNode`, it is used to
|
|
428
428
|
* evaluate the model length (`viewNode` is used as first and only parameter passed to the callback),
|
|
429
|
-
* * length of a {@link module:engine/view/text~
|
|
430
|
-
* {@link module:engine/view/text~
|
|
431
|
-
* * length of a {@link module:engine/view/uielement~
|
|
432
|
-
* * length of a mapped {@link module:engine/view/element~
|
|
433
|
-
* * length of a non-mapped {@link module:engine/view/element~
|
|
429
|
+
* * length of a {@link module:engine/view/text~ViewText text node} is equal to the length of its
|
|
430
|
+
* {@link module:engine/view/text~ViewText#data data},
|
|
431
|
+
* * length of a {@link module:engine/view/uielement~ViewUIElement ui element} is equal to 0,
|
|
432
|
+
* * length of a mapped {@link module:engine/view/element~ViewElement element} is equal to 1,
|
|
433
|
+
* * length of a non-mapped {@link module:engine/view/element~ViewElement element} is equal to the length of its children.
|
|
434
434
|
*
|
|
435
435
|
* Examples:
|
|
436
436
|
*
|