@contentful/field-editor-rich-text 2.0.0-next.25 → 2.0.0-next.26
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/field-editor-rich-text.cjs.development.js +38 -25
- 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 +38 -25
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -3868,37 +3868,44 @@ var moveListItems = function moveListItems(editor, _temp) {
|
|
|
3868
3868
|
* Credit: Modified version of Plate's list plugin
|
|
3869
3869
|
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
3870
3870
|
*/
|
|
3871
|
-
|
|
3871
|
+
|
|
3872
|
+
function hasUnliftedListItems(editor, at) {
|
|
3873
|
+
return slate.Editor.nodes(editor, {
|
|
3874
|
+
at: at,
|
|
3875
|
+
match: function match(node, path) {
|
|
3876
|
+
return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.LIST_ITEM && path.length >= 2;
|
|
3877
|
+
}
|
|
3878
|
+
}).next().done;
|
|
3879
|
+
}
|
|
3880
|
+
|
|
3872
3881
|
var unwrapList = function unwrapList(editor, _temp) {
|
|
3873
3882
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
3874
3883
|
at = _ref.at;
|
|
3875
3884
|
|
|
3876
3885
|
slate.Editor.withoutNormalizing(editor, function () {
|
|
3877
3886
|
do {
|
|
3878
|
-
|
|
3887
|
+
// lift list items to the root level
|
|
3888
|
+
slate.Transforms.liftNodes(editor, {
|
|
3879
3889
|
at: at,
|
|
3880
|
-
match: {
|
|
3881
|
-
type
|
|
3882
|
-
},
|
|
3883
|
-
split: true
|
|
3884
|
-
});
|
|
3885
|
-
plateCore.unwrapNodes(editor, {
|
|
3886
|
-
at: at,
|
|
3887
|
-
match: {
|
|
3888
|
-
type: listTypes
|
|
3890
|
+
match: function match(node) {
|
|
3891
|
+
return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.LIST_ITEM;
|
|
3889
3892
|
},
|
|
3890
|
-
|
|
3893
|
+
mode: 'lowest'
|
|
3891
3894
|
});
|
|
3892
|
-
} while (
|
|
3895
|
+
} while (!hasUnliftedListItems(editor, at)); // finally unwrap all lifted items
|
|
3896
|
+
|
|
3897
|
+
|
|
3898
|
+
plateCore.unwrapNodes(editor, {
|
|
3899
|
+
at: at,
|
|
3893
3900
|
match: {
|
|
3894
|
-
type:
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
})
|
|
3901
|
+
type: Contentful.BLOCKS.LIST_ITEM
|
|
3902
|
+
},
|
|
3903
|
+
split: false
|
|
3904
|
+
});
|
|
3898
3905
|
});
|
|
3899
3906
|
};
|
|
3900
3907
|
|
|
3901
|
-
var listTypes
|
|
3908
|
+
var listTypes = [Contentful.BLOCKS.UL_LIST, Contentful.BLOCKS.OL_LIST];
|
|
3902
3909
|
var toggleList = function toggleList(editor, _ref) {
|
|
3903
3910
|
var type = _ref.type;
|
|
3904
3911
|
return slate.Editor.withoutNormalizing(editor, function () {
|
|
@@ -3919,7 +3926,7 @@ var toggleList = function toggleList(editor, _ref) {
|
|
|
3919
3926
|
}, {
|
|
3920
3927
|
at: editor.selection,
|
|
3921
3928
|
match: function match(n) {
|
|
3922
|
-
return listTypes
|
|
3929
|
+
return listTypes.includes(n.type);
|
|
3923
3930
|
},
|
|
3924
3931
|
mode: 'lowest'
|
|
3925
3932
|
});
|
|
@@ -3960,19 +3967,25 @@ var toggleList = function toggleList(editor, _ref) {
|
|
|
3960
3967
|
|
|
3961
3968
|
var commonEntry = slate.Node.common(editor, startPoint.path, endPoint.path);
|
|
3962
3969
|
|
|
3963
|
-
if (listTypes
|
|
3964
|
-
|
|
3970
|
+
if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === Contentful.BLOCKS.LIST_ITEM) {
|
|
3971
|
+
var listType = commonEntry[0].type;
|
|
3972
|
+
|
|
3973
|
+
if (commonEntry[0].type === Contentful.BLOCKS.LIST_ITEM) {
|
|
3974
|
+
listType = slate.Editor.parent(editor, commonEntry[1])[0].type;
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3977
|
+
if (listType !== type) {
|
|
3965
3978
|
var startList = plateCore.findNode(editor, {
|
|
3966
3979
|
at: slate.Range.start(editor.selection),
|
|
3967
3980
|
match: {
|
|
3968
|
-
type: listTypes
|
|
3981
|
+
type: listTypes
|
|
3969
3982
|
},
|
|
3970
3983
|
mode: 'lowest'
|
|
3971
3984
|
});
|
|
3972
3985
|
var endList = plateCore.findNode(editor, {
|
|
3973
3986
|
at: slate.Range.end(editor.selection),
|
|
3974
3987
|
match: {
|
|
3975
|
-
type: listTypes
|
|
3988
|
+
type: listTypes
|
|
3976
3989
|
},
|
|
3977
3990
|
mode: 'lowest'
|
|
3978
3991
|
});
|
|
@@ -3987,7 +4000,7 @@ var toggleList = function toggleList(editor, _ref) {
|
|
|
3987
4000
|
}, {
|
|
3988
4001
|
at: editor.selection,
|
|
3989
4002
|
match: function match(n, path) {
|
|
3990
|
-
return listTypes
|
|
4003
|
+
return listTypes.includes(n.type) && path.length >= rangeLength;
|
|
3991
4004
|
},
|
|
3992
4005
|
mode: 'all'
|
|
3993
4006
|
});
|
|
@@ -4005,7 +4018,7 @@ var toggleList = function toggleList(editor, _ref) {
|
|
|
4005
4018
|
}).reverse();
|
|
4006
4019
|
|
|
4007
4020
|
_nodes.forEach(function (n) {
|
|
4008
|
-
if (listTypes
|
|
4021
|
+
if (listTypes.includes(n[0].type)) {
|
|
4009
4022
|
plateCore.setNodes(editor, {
|
|
4010
4023
|
type: type
|
|
4011
4024
|
}, {
|