@kaitify/core 0.0.1-beta.14 → 0.0.1-beta.16
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/lib/kaitify-core.es.js +50 -23
- package/lib/kaitify-core.umd.js +1 -1
- package/package.json +1 -1
package/lib/kaitify-core.es.js
CHANGED
|
@@ -7930,6 +7930,26 @@ const listMergeHandler = ({ editor, node }) => {
|
|
|
7930
7930
|
const isOnlyTab = (e) => {
|
|
7931
7931
|
return e.key.toLocaleLowerCase() == "tab" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey;
|
|
7932
7932
|
};
|
|
7933
|
+
const getUnsetListItemNode = (matchNode, options) => {
|
|
7934
|
+
while (true) {
|
|
7935
|
+
if (!matchNode) {
|
|
7936
|
+
break;
|
|
7937
|
+
}
|
|
7938
|
+
const params = {
|
|
7939
|
+
tag: options.ordered ? "ol" : "ul"
|
|
7940
|
+
};
|
|
7941
|
+
if (options.listType) {
|
|
7942
|
+
params.styles = {
|
|
7943
|
+
listStyleType: options.listType
|
|
7944
|
+
};
|
|
7945
|
+
}
|
|
7946
|
+
if (matchNode.parent.isMatch(params)) {
|
|
7947
|
+
break;
|
|
7948
|
+
}
|
|
7949
|
+
matchNode = matchNode.parent.getMatchNode({ tag: "li" });
|
|
7950
|
+
}
|
|
7951
|
+
return matchNode;
|
|
7952
|
+
};
|
|
7933
7953
|
const ListExtension = () => Extension.create({
|
|
7934
7954
|
name: "list",
|
|
7935
7955
|
extraKeepTags: ["ul", "ol", "li"],
|
|
@@ -7948,6 +7968,13 @@ const ListExtension = () => Extension.create({
|
|
|
7948
7968
|
({ node }) => {
|
|
7949
7969
|
if (node.isMatch({ tag: "ol" }) || node.isMatch({ tag: "ul" })) {
|
|
7950
7970
|
node.type = "block";
|
|
7971
|
+
if (!node.hasStyles()) {
|
|
7972
|
+
node.styles = {
|
|
7973
|
+
listStyleType: node.isMatch({ tag: "ol" }) ? "decimal" : "disc"
|
|
7974
|
+
};
|
|
7975
|
+
} else if (!node.styles.listStyleType) {
|
|
7976
|
+
node.styles.listStyleType = node.isMatch({ tag: "ol" }) ? "decimal" : "disc";
|
|
7977
|
+
}
|
|
7951
7978
|
}
|
|
7952
7979
|
},
|
|
7953
7980
|
//列表项处理
|
|
@@ -8003,37 +8030,37 @@ const ListExtension = () => Extension.create({
|
|
|
8003
8030
|
},
|
|
8004
8031
|
addCommands() {
|
|
8005
8032
|
const getList = (options) => {
|
|
8033
|
+
const params = {
|
|
8034
|
+
tag: options.ordered ? "ol" : "ul"
|
|
8035
|
+
};
|
|
8006
8036
|
if (options.listType) {
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
listStyleType: options.listType
|
|
8011
|
-
}
|
|
8012
|
-
});
|
|
8037
|
+
params.styles = {
|
|
8038
|
+
listStyleType: options.listType
|
|
8039
|
+
};
|
|
8013
8040
|
}
|
|
8014
|
-
return this.getMatchNodeBySelection(
|
|
8041
|
+
return this.getMatchNodeBySelection(params);
|
|
8015
8042
|
};
|
|
8016
8043
|
const hasList = (options) => {
|
|
8044
|
+
const params = {
|
|
8045
|
+
tag: options.ordered ? "ol" : "ul"
|
|
8046
|
+
};
|
|
8017
8047
|
if (options.listType) {
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
listStyleType: options.listType
|
|
8022
|
-
}
|
|
8023
|
-
});
|
|
8048
|
+
params.styles = {
|
|
8049
|
+
listStyleType: options.listType
|
|
8050
|
+
};
|
|
8024
8051
|
}
|
|
8025
|
-
return this.isSelectionNodesSomeMatch(
|
|
8052
|
+
return this.isSelectionNodesSomeMatch(params);
|
|
8026
8053
|
};
|
|
8027
8054
|
const allList = (options) => {
|
|
8055
|
+
const params = {
|
|
8056
|
+
tag: options.ordered ? "ol" : "ul"
|
|
8057
|
+
};
|
|
8028
8058
|
if (options.listType) {
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
listStyleType: options.listType
|
|
8033
|
-
}
|
|
8034
|
-
});
|
|
8059
|
+
params.styles = {
|
|
8060
|
+
listStyleType: options.listType
|
|
8061
|
+
};
|
|
8035
8062
|
}
|
|
8036
|
-
return this.isSelectionNodesAllMatch(
|
|
8063
|
+
return this.isSelectionNodesAllMatch(params);
|
|
8037
8064
|
};
|
|
8038
8065
|
const setList = async (options) => {
|
|
8039
8066
|
if (allList(options)) {
|
|
@@ -8056,12 +8083,12 @@ const ListExtension = () => Extension.create({
|
|
|
8056
8083
|
}
|
|
8057
8084
|
if (this.selection.collapsed()) {
|
|
8058
8085
|
const blockNode = this.selection.start.node.getBlock();
|
|
8059
|
-
const matchNode = blockNode.getMatchNode({ tag: "li" });
|
|
8086
|
+
const matchNode = getUnsetListItemNode(blockNode.getMatchNode({ tag: "li" }), options);
|
|
8060
8087
|
if (matchNode) ListItemToParagraph(this, matchNode);
|
|
8061
8088
|
} else {
|
|
8062
8089
|
const blockNodes = getSelectionBlockNodes.apply(this);
|
|
8063
8090
|
blockNodes.forEach((item) => {
|
|
8064
|
-
const matchNode = item.getMatchNode({ tag: "li" });
|
|
8091
|
+
const matchNode = getUnsetListItemNode(item.getMatchNode({ tag: "li" }), options);
|
|
8065
8092
|
if (matchNode) ListItemToParagraph(this, matchNode);
|
|
8066
8093
|
});
|
|
8067
8094
|
}
|