@contentful/field-editor-rich-text 2.0.0-next.10 → 2.0.0-next.11
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/CHANGELOG.md +410 -0
- package/dist/field-editor-rich-text.cjs.development.js +16 -4
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +16 -4
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/test-utils/jsx.d.ts +1 -1
- package/dist/test-utils/mockPlugin.d.ts +1 -1
- package/package.json +1 -1
|
@@ -539,7 +539,12 @@ function moveToTheNextLine(editor) {
|
|
|
539
539
|
function getElementFromCurrentSelection(editor) {
|
|
540
540
|
if (!editor.selection) return [];
|
|
541
541
|
return Array.from(Editor.nodes(editor, {
|
|
542
|
-
|
|
542
|
+
/**
|
|
543
|
+
* editor.select is a Range, which includes anchor and focus, the beginning and the end of a selection
|
|
544
|
+
* when using only editor.selection.focus, we might get only the end of the selection, or where the text cursor is
|
|
545
|
+
* and in some cases getting the next element instead of the one we want
|
|
546
|
+
**/
|
|
547
|
+
at: editor.selection,
|
|
543
548
|
match: function match(node) {
|
|
544
549
|
return Element.isElement(node);
|
|
545
550
|
}
|
|
@@ -3598,11 +3603,11 @@ var isAnchor = function isAnchor(element) {
|
|
|
3598
3603
|
};
|
|
3599
3604
|
|
|
3600
3605
|
var isEntryAnchor = function isEntryAnchor(element) {
|
|
3601
|
-
return
|
|
3606
|
+
return element.nodeName === 'A' && element.getAttribute('data-link-type') === 'Entry';
|
|
3602
3607
|
};
|
|
3603
3608
|
|
|
3604
3609
|
var isAssetAnchor = function isAssetAnchor(element) {
|
|
3605
|
-
return
|
|
3610
|
+
return element.nodeName === 'A' && element.getAttribute('data-link-type') === 'Asset';
|
|
3606
3611
|
};
|
|
3607
3612
|
|
|
3608
3613
|
var buildHyperlinkEventHandler = function buildHyperlinkEventHandler(sdk) {
|
|
@@ -4813,12 +4818,17 @@ function toggleQuote(editor) {
|
|
|
4813
4818
|
if (!editor.selection) return;
|
|
4814
4819
|
var isActive = isBlockSelected(editor, BLOCKS.QUOTE);
|
|
4815
4820
|
Editor.withoutNormalizing(editor, function () {
|
|
4821
|
+
if (!editor.selection) return;
|
|
4816
4822
|
Transforms.unwrapNodes(editor, {
|
|
4817
4823
|
match: function match(node) {
|
|
4818
4824
|
return Element.isElement(node) && node.type === BLOCKS.QUOTE;
|
|
4819
4825
|
},
|
|
4820
4826
|
split: true
|
|
4821
4827
|
});
|
|
4828
|
+
var _editor$selection = editor.selection,
|
|
4829
|
+
anchor = _editor$selection.anchor,
|
|
4830
|
+
focus = _editor$selection.focus;
|
|
4831
|
+
var isTripleSelection = anchor.path[0] !== focus.path[0] && anchor.offset === 0 && focus.offset === 0;
|
|
4822
4832
|
|
|
4823
4833
|
if (!isActive) {
|
|
4824
4834
|
var quote = {
|
|
@@ -4826,7 +4836,9 @@ function toggleQuote(editor) {
|
|
|
4826
4836
|
data: {},
|
|
4827
4837
|
children: []
|
|
4828
4838
|
};
|
|
4829
|
-
Transforms.wrapNodes(editor, quote
|
|
4839
|
+
Transforms.wrapNodes(editor, quote, {
|
|
4840
|
+
at: isTripleSelection ? editor.selection.anchor : undefined
|
|
4841
|
+
});
|
|
4830
4842
|
}
|
|
4831
4843
|
});
|
|
4832
4844
|
}
|