@ckeditor/ckeditor5-engine 38.2.0-alpha.0 → 39.0.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/README.md +0 -1
- package/package.json +3 -4
- package/src/controller/editingcontroller.js +2 -2
- package/src/conversion/downcastdispatcher.d.ts +15 -0
- package/src/conversion/downcastdispatcher.js +28 -19
- package/src/conversion/downcasthelpers.d.ts +6 -6
- package/src/conversion/downcasthelpers.js +6 -6
- package/src/dev-utils/view.js +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/model/differ.d.ts +14 -0
- package/src/model/differ.js +70 -11
- package/src/model/document.d.ts +9 -1
- package/src/model/document.js +14 -9
- package/src/model/documentselection.js +8 -2
- package/src/model/model.d.ts +0 -1
- package/src/model/model.js +0 -1
- package/src/model/operation/rootoperation.d.ts +0 -4
- package/src/model/operation/rootoperation.js +0 -24
- package/src/model/operation/transform.js +2 -2
- package/src/model/rootelement.d.ts +6 -0
- package/src/model/rootelement.js +6 -0
- package/src/model/schema.d.ts +10 -0
- package/src/model/schema.js +5 -0
- package/src/model/utils/autoparagraphing.js +1 -2
- package/src/view/domconverter.d.ts +43 -53
- package/src/view/domconverter.js +266 -214
- package/src/view/editableelement.d.ts +10 -0
- package/src/view/editableelement.js +1 -0
- package/src/view/filler.d.ts +2 -2
- package/src/view/filler.js +6 -4
- package/src/view/observer/selectionobserver.js +2 -2
- package/src/view/placeholder.d.ts +13 -5
- package/src/view/placeholder.js +21 -12
- package/src/view/renderer.js +1 -2
- package/src/view/view.d.ts +14 -7
- package/src/view/view.js +13 -1
package/src/model/rootelement.js
CHANGED
|
@@ -23,6 +23,12 @@ export default class RootElement extends Element {
|
|
|
23
23
|
* @internal
|
|
24
24
|
*/
|
|
25
25
|
this._isAttached = true;
|
|
26
|
+
/**
|
|
27
|
+
* Informs if the root element is loaded (default).
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
this._isLoaded = true;
|
|
26
32
|
this._document = document;
|
|
27
33
|
this.rootName = rootName;
|
|
28
34
|
}
|
package/src/model/schema.d.ts
CHANGED
|
@@ -1169,6 +1169,16 @@ export interface AttributeProperties {
|
|
|
1169
1169
|
* Indicates that given text attribute should be copied to the next block when enter is pressed.
|
|
1170
1170
|
*/
|
|
1171
1171
|
copyOnEnter?: boolean;
|
|
1172
|
+
/**
|
|
1173
|
+
* Indicates that given attribute should be preserved while replacing the element.
|
|
1174
|
+
*/
|
|
1175
|
+
copyOnReplace?: boolean;
|
|
1176
|
+
/**
|
|
1177
|
+
* Indicates that given text attribute should be copied from an inline object to the next inserted inline content.
|
|
1178
|
+
*
|
|
1179
|
+
* @default true
|
|
1180
|
+
*/
|
|
1181
|
+
copyFromObject?: boolean;
|
|
1172
1182
|
[name: string]: unknown;
|
|
1173
1183
|
}
|
|
1174
1184
|
export type SchemaAttributeCheckCallback = (context: SchemaContext, attributeName: string) => unknown;
|
package/src/model/schema.js
CHANGED
|
@@ -677,6 +677,11 @@ export default class Schema extends ObservableMixin() {
|
|
|
677
677
|
* @returns Nearest selection range or `null` if one cannot be found.
|
|
678
678
|
*/
|
|
679
679
|
getNearestSelectionRange(position, direction = 'both') {
|
|
680
|
+
if (position.root.rootName == '$graveyard') {
|
|
681
|
+
// No valid selection range in the graveyard.
|
|
682
|
+
// This is important when getting the document selection default range.
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
680
685
|
// Return collapsed range if provided position is valid.
|
|
681
686
|
if (this.checkChild(position, '$text')) {
|
|
682
687
|
return new Range(position);
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export function autoParagraphEmptyRoots(writer) {
|
|
16
16
|
const { schema, document } = writer.model;
|
|
17
|
-
for (const
|
|
18
|
-
const root = document.getRoot(rootName);
|
|
17
|
+
for (const root of document.getRoots()) {
|
|
19
18
|
if (root.isEmpty && !schema.checkChild(root, '$text')) {
|
|
20
19
|
// If paragraph element is allowed in the root, create paragraph element.
|
|
21
20
|
if (schema.checkChild(root, 'paragraph')) {
|
|
@@ -98,9 +98,9 @@ export default class DomConverter {
|
|
|
98
98
|
*/
|
|
99
99
|
private readonly _rawContentElementMatcher;
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
101
|
+
* Matcher for inline object view elements. This is an extension of a simple {@link #inlineObjectElements} array of element names.
|
|
102
102
|
*/
|
|
103
|
-
private readonly
|
|
103
|
+
private readonly _inlineObjectElementMatcher;
|
|
104
104
|
/**
|
|
105
105
|
* Creates a DOM converter.
|
|
106
106
|
*
|
|
@@ -269,9 +269,10 @@ export default class DomConverter {
|
|
|
269
269
|
*
|
|
270
270
|
* @param domElement Parent DOM element.
|
|
271
271
|
* @param options See {@link module:engine/view/domconverter~DomConverter#domToView} options parameter.
|
|
272
|
+
* @param inlineNodes An array that will be populated with inline nodes. It's used internally for whitespace processing.
|
|
272
273
|
* @returns View nodes.
|
|
273
274
|
*/
|
|
274
|
-
domChildrenToView(domElement: DomElement, options
|
|
275
|
+
domChildrenToView(domElement: DomElement, options?: Parameters<DomConverter['domToView']>[1], inlineNodes?: Array<ViewNode>): IterableIterator<ViewNode>;
|
|
275
276
|
/**
|
|
276
277
|
* Converts DOM selection to view {@link module:engine/view/selection~Selection}.
|
|
277
278
|
* Ranges which cannot be converted will be omitted.
|
|
@@ -391,6 +392,12 @@ export default class DomConverter {
|
|
|
391
392
|
* Focuses DOM editable that is corresponding to provided {@link module:engine/view/editableelement~EditableElement}.
|
|
392
393
|
*/
|
|
393
394
|
focus(viewEditable: EditableElement): void;
|
|
395
|
+
/**
|
|
396
|
+
* Remove DOM selection from blurred editable, so it won't interfere with clicking on dropdowns (especially on iOS).
|
|
397
|
+
*
|
|
398
|
+
* @internal
|
|
399
|
+
*/
|
|
400
|
+
_clearDomSelection(): void;
|
|
394
401
|
/**
|
|
395
402
|
* Returns `true` when `node.nodeType` equals `Node.ELEMENT_NODE`.
|
|
396
403
|
*
|
|
@@ -459,6 +466,17 @@ export default class DomConverter {
|
|
|
459
466
|
* be treated as raw data.
|
|
460
467
|
*/
|
|
461
468
|
registerRawContentMatcher(pattern: MatcherPattern): void;
|
|
469
|
+
/**
|
|
470
|
+
* Registers a {@link module:engine/view/matcher~MatcherPattern} for inline object view elements.
|
|
471
|
+
*
|
|
472
|
+
* This is affecting how {@link module:engine/view/domconverter~DomConverter#domToView} and
|
|
473
|
+
* {@link module:engine/view/domconverter~DomConverter#domChildrenToView} process DOM nodes.
|
|
474
|
+
*
|
|
475
|
+
* This is an extension of a simple {@link #inlineObjectElements} array of element names.
|
|
476
|
+
*
|
|
477
|
+
* @param pattern Pattern matching a view element which should be treated as an inline object.
|
|
478
|
+
*/
|
|
479
|
+
registerInlineObjectMatcher(pattern: MatcherPattern): void;
|
|
462
480
|
/**
|
|
463
481
|
* Returns the block {@link module:engine/view/filler filler} node based on the current {@link #blockFillerMode} setting.
|
|
464
482
|
*/
|
|
@@ -471,6 +489,24 @@ export default class DomConverter {
|
|
|
471
489
|
* @returns `true` if given position is at a correct place for selection boundary, `false` otherwise.
|
|
472
490
|
*/
|
|
473
491
|
private _isDomSelectionPositionCorrect;
|
|
492
|
+
/**
|
|
493
|
+
* Internal generator for {@link #domToView}. Also used by {@link #domChildrenToView}.
|
|
494
|
+
* Separates DOM nodes conversion from whitespaces processing.
|
|
495
|
+
*
|
|
496
|
+
* @param domNode DOM node or document fragment to transform.
|
|
497
|
+
* @param inlineNodes An array of recently encountered inline nodes truncated to the block element boundaries.
|
|
498
|
+
* Used later to process whitespaces.
|
|
499
|
+
*/
|
|
500
|
+
private _domToView;
|
|
501
|
+
/**
|
|
502
|
+
* Internal helper that walks the list of inline view nodes already generated from DOM nodes
|
|
503
|
+
* and handles whitespaces and NBSPs.
|
|
504
|
+
*
|
|
505
|
+
* @param domParent The DOM parent of the given inline nodes. This should be a document fragment or
|
|
506
|
+
* a block element to whitespace processing start cleaning.
|
|
507
|
+
* @param inlineNodes An array of recently encountered inline nodes truncated to the block element boundaries.
|
|
508
|
+
*/
|
|
509
|
+
private _processDomInlineNodes;
|
|
474
510
|
/**
|
|
475
511
|
* Takes text data from a given {@link module:engine/view/text~Text#data} and processes it so
|
|
476
512
|
* it is correctly displayed in the DOM.
|
|
@@ -496,36 +532,6 @@ export default class DomConverter {
|
|
|
496
532
|
* @returns `true` if given `node` ends with space, `false` otherwise.
|
|
497
533
|
*/
|
|
498
534
|
private _nodeEndsWithSpace;
|
|
499
|
-
/**
|
|
500
|
-
* Takes text data from native `Text` node and processes it to a correct {@link module:engine/view/text~Text view text node} data.
|
|
501
|
-
*
|
|
502
|
-
* Following changes are done:
|
|
503
|
-
*
|
|
504
|
-
* * multiple whitespaces are replaced to a single space,
|
|
505
|
-
* * space at the beginning of a text node is removed if it is the first text node in its container
|
|
506
|
-
* element or if the previous text node ends with a space character,
|
|
507
|
-
* * space at the end of the text node is removed if there are two spaces at the end of a node or if next node
|
|
508
|
-
* starts with a space or if it is the last text node in its container
|
|
509
|
-
* * nbsps are converted to spaces.
|
|
510
|
-
*
|
|
511
|
-
* @param node DOM text node to process.
|
|
512
|
-
* @returns Processed data.
|
|
513
|
-
*/
|
|
514
|
-
private _processDataFromDomText;
|
|
515
|
-
/**
|
|
516
|
-
* Helper function which checks if a DOM text node, preceded by the given `prevNode` should
|
|
517
|
-
* be trimmed from the left side.
|
|
518
|
-
*
|
|
519
|
-
* @param prevNode Either DOM text or `<br>` or one of `#inlineObjectElements`.
|
|
520
|
-
*/
|
|
521
|
-
private _checkShouldLeftTrimDomText;
|
|
522
|
-
/**
|
|
523
|
-
* Helper function which checks if a DOM text node, succeeded by the given `nextNode` should
|
|
524
|
-
* be trimmed from the right side.
|
|
525
|
-
*
|
|
526
|
-
* @param nextNode Either DOM text or `<br>` or one of `#inlineObjectElements`.
|
|
527
|
-
*/
|
|
528
|
-
private _checkShouldRightTrimDomText;
|
|
529
535
|
/**
|
|
530
536
|
* Helper function. For given {@link module:engine/view/text~Text view text node}, it finds previous or next sibling
|
|
531
537
|
* that is contained in the same container element. If there is no such sibling, `null` is returned.
|
|
@@ -536,29 +542,13 @@ export default class DomConverter {
|
|
|
536
542
|
*/
|
|
537
543
|
private _getTouchingInlineViewNode;
|
|
538
544
|
/**
|
|
539
|
-
*
|
|
540
|
-
* a text, `<br>` or an {@link #inlineObjectElements inline object}.
|
|
541
|
-
*
|
|
542
|
-
* If no such node is found, `null` is returned.
|
|
543
|
-
*
|
|
544
|
-
* For instance, in the following DOM structure:
|
|
545
|
-
*
|
|
546
|
-
* ```html
|
|
547
|
-
* <p>foo<b>bar</b><br>bom</p>
|
|
548
|
-
* ```
|
|
549
|
-
*
|
|
550
|
-
* * `foo` doesn't have its previous touching inline node (`null` is returned),
|
|
551
|
-
* * `foo`'s next touching inline node is `bar`
|
|
552
|
-
* * `bar`'s next touching inline node is `<br>`
|
|
553
|
-
*
|
|
554
|
-
* This method returns text nodes and `<br>` elements because these types of nodes affect how
|
|
555
|
-
* spaces in the given text node need to be converted.
|
|
545
|
+
* Returns `true` if a DOM node belongs to {@link #blockElements}. `false` otherwise.
|
|
556
546
|
*/
|
|
557
|
-
private
|
|
547
|
+
private _isBlockDomElement;
|
|
558
548
|
/**
|
|
559
|
-
* Returns `true` if a
|
|
549
|
+
* Returns `true` if a view node belongs to {@link #blockElements}. `false` otherwise.
|
|
560
550
|
*/
|
|
561
|
-
private
|
|
551
|
+
private _isBlockViewElement;
|
|
562
552
|
/**
|
|
563
553
|
* Returns `true` if a DOM node belongs to {@link #inlineObjectElements}. `false` otherwise.
|
|
564
554
|
*/
|