@tiptap/core 3.10.7 → 3.10.8
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.cjs +85 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +85 -71
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/commands/resetAttributes.ts +20 -12
- package/src/commands/updateAttributes.ts +68 -58
- package/src/helpers/getSchemaByResolvedExtensions.ts +2 -2
- package/src/types.ts +55 -1
- package/src/utilities/markdown/parseIndentedBlocks.ts +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1172,23 +1172,28 @@ var resetAttributes = (typeOrName, attributes) => ({ tr, state, dispatch }) => {
|
|
|
1172
1172
|
if (schemaType === "mark") {
|
|
1173
1173
|
markType = getMarkType(typeOrName, state.schema);
|
|
1174
1174
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1175
|
+
let canReset = false;
|
|
1176
|
+
tr.selection.ranges.forEach((range) => {
|
|
1177
|
+
state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {
|
|
1178
|
+
if (nodeType && nodeType === node.type) {
|
|
1179
|
+
canReset = true;
|
|
1180
|
+
if (dispatch) {
|
|
1179
1181
|
tr.setNodeMarkup(pos, void 0, deleteProps(node.attrs, attributes));
|
|
1180
1182
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1183
|
+
}
|
|
1184
|
+
if (markType && node.marks.length) {
|
|
1185
|
+
node.marks.forEach((mark) => {
|
|
1186
|
+
if (markType === mark.type) {
|
|
1187
|
+
canReset = true;
|
|
1188
|
+
if (dispatch) {
|
|
1184
1189
|
tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes)));
|
|
1185
1190
|
}
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1189
1194
|
});
|
|
1190
|
-
}
|
|
1191
|
-
return
|
|
1195
|
+
});
|
|
1196
|
+
return canReset;
|
|
1192
1197
|
};
|
|
1193
1198
|
|
|
1194
1199
|
// src/commands/scrollIntoView.ts
|
|
@@ -1628,12 +1633,12 @@ function cleanUpSchemaItem(data) {
|
|
|
1628
1633
|
);
|
|
1629
1634
|
}
|
|
1630
1635
|
function buildAttributeSpec(extensionAttribute) {
|
|
1631
|
-
var _a, _b
|
|
1636
|
+
var _a, _b;
|
|
1632
1637
|
const spec = {};
|
|
1633
|
-
if (!((_a = extensionAttribute == null ? void 0 : extensionAttribute.attribute) == null ? void 0 : _a.isRequired) && ((
|
|
1638
|
+
if (!((_a = extensionAttribute == null ? void 0 : extensionAttribute.attribute) == null ? void 0 : _a.isRequired) && "default" in ((extensionAttribute == null ? void 0 : extensionAttribute.attribute) || {})) {
|
|
1634
1639
|
spec.default = extensionAttribute.attribute.default;
|
|
1635
1640
|
}
|
|
1636
|
-
if (((
|
|
1641
|
+
if (((_b = extensionAttribute == null ? void 0 : extensionAttribute.attribute) == null ? void 0 : _b.validate) !== void 0) {
|
|
1637
1642
|
spec.validate = extensionAttribute.attribute.validate;
|
|
1638
1643
|
}
|
|
1639
1644
|
return [extensionAttribute.name, spec];
|
|
@@ -2831,41 +2836,48 @@ var updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }
|
|
|
2831
2836
|
if (schemaType === "mark") {
|
|
2832
2837
|
markType = getMarkType(typeOrName, state.schema);
|
|
2833
2838
|
}
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2839
|
+
let canUpdate = false;
|
|
2840
|
+
tr.selection.ranges.forEach((range) => {
|
|
2841
|
+
const from = range.$from.pos;
|
|
2842
|
+
const to = range.$to.pos;
|
|
2843
|
+
let lastPos;
|
|
2844
|
+
let lastNode;
|
|
2845
|
+
let trimmedFrom;
|
|
2846
|
+
let trimmedTo;
|
|
2847
|
+
if (tr.selection.empty) {
|
|
2848
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
2849
|
+
if (nodeType && nodeType === node.type) {
|
|
2850
|
+
canUpdate = true;
|
|
2851
|
+
trimmedFrom = Math.max(pos, from);
|
|
2852
|
+
trimmedTo = Math.min(pos + node.nodeSize, to);
|
|
2853
|
+
lastPos = pos;
|
|
2854
|
+
lastNode = node;
|
|
2855
|
+
}
|
|
2856
|
+
});
|
|
2857
|
+
} else {
|
|
2858
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
2859
|
+
if (pos < from && nodeType && nodeType === node.type) {
|
|
2860
|
+
canUpdate = true;
|
|
2861
|
+
trimmedFrom = Math.max(pos, from);
|
|
2862
|
+
trimmedTo = Math.min(pos + node.nodeSize, to);
|
|
2863
|
+
lastPos = pos;
|
|
2864
|
+
lastNode = node;
|
|
2865
|
+
}
|
|
2866
|
+
if (pos >= from && pos <= to) {
|
|
2844
2867
|
if (nodeType && nodeType === node.type) {
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
lastPos = pos;
|
|
2848
|
-
lastNode = node;
|
|
2849
|
-
}
|
|
2850
|
-
});
|
|
2851
|
-
} else {
|
|
2852
|
-
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
2853
|
-
if (pos < from && nodeType && nodeType === node.type) {
|
|
2854
|
-
trimmedFrom = Math.max(pos, from);
|
|
2855
|
-
trimmedTo = Math.min(pos + node.nodeSize, to);
|
|
2856
|
-
lastPos = pos;
|
|
2857
|
-
lastNode = node;
|
|
2858
|
-
}
|
|
2859
|
-
if (pos >= from && pos <= to) {
|
|
2860
|
-
if (nodeType && nodeType === node.type) {
|
|
2868
|
+
canUpdate = true;
|
|
2869
|
+
if (dispatch) {
|
|
2861
2870
|
tr.setNodeMarkup(pos, void 0, {
|
|
2862
2871
|
...node.attrs,
|
|
2863
2872
|
...attributes
|
|
2864
2873
|
});
|
|
2865
2874
|
}
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2875
|
+
}
|
|
2876
|
+
if (markType && node.marks.length) {
|
|
2877
|
+
node.marks.forEach((mark) => {
|
|
2878
|
+
if (markType === mark.type) {
|
|
2879
|
+
canUpdate = true;
|
|
2880
|
+
if (dispatch) {
|
|
2869
2881
|
const trimmedFrom2 = Math.max(pos, from);
|
|
2870
2882
|
const trimmedTo2 = Math.min(pos + node.nodeSize, to);
|
|
2871
2883
|
tr.addMark(
|
|
@@ -2877,36 +2889,36 @@ var updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }
|
|
|
2877
2889
|
})
|
|
2878
2890
|
);
|
|
2879
2891
|
}
|
|
2880
|
-
}
|
|
2881
|
-
}
|
|
2892
|
+
}
|
|
2893
|
+
});
|
|
2882
2894
|
}
|
|
2895
|
+
}
|
|
2896
|
+
});
|
|
2897
|
+
}
|
|
2898
|
+
if (lastNode) {
|
|
2899
|
+
if (lastPos !== void 0 && dispatch) {
|
|
2900
|
+
tr.setNodeMarkup(lastPos, void 0, {
|
|
2901
|
+
...lastNode.attrs,
|
|
2902
|
+
...attributes
|
|
2883
2903
|
});
|
|
2884
2904
|
}
|
|
2885
|
-
if (lastNode) {
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
markType.create({
|
|
2899
|
-
...mark.attrs,
|
|
2900
|
-
...attributes
|
|
2901
|
-
})
|
|
2902
|
-
);
|
|
2903
|
-
}
|
|
2904
|
-
});
|
|
2905
|
-
}
|
|
2905
|
+
if (markType && lastNode.marks.length) {
|
|
2906
|
+
lastNode.marks.forEach((mark) => {
|
|
2907
|
+
if (markType === mark.type && dispatch) {
|
|
2908
|
+
tr.addMark(
|
|
2909
|
+
trimmedFrom,
|
|
2910
|
+
trimmedTo,
|
|
2911
|
+
markType.create({
|
|
2912
|
+
...mark.attrs,
|
|
2913
|
+
...attributes
|
|
2914
|
+
})
|
|
2915
|
+
);
|
|
2916
|
+
}
|
|
2917
|
+
});
|
|
2906
2918
|
}
|
|
2907
|
-
}
|
|
2908
|
-
}
|
|
2909
|
-
return
|
|
2919
|
+
}
|
|
2920
|
+
});
|
|
2921
|
+
return canUpdate;
|
|
2910
2922
|
};
|
|
2911
2923
|
|
|
2912
2924
|
// src/commands/wrapIn.ts
|
|
@@ -6102,6 +6114,8 @@ function parseIndentedBlocks(src, config, lexer) {
|
|
|
6102
6114
|
break;
|
|
6103
6115
|
} else if (currentLine.trim() === "") {
|
|
6104
6116
|
i += 1;
|
|
6117
|
+
totalRaw = `${totalRaw}${currentLine}
|
|
6118
|
+
`;
|
|
6105
6119
|
continue;
|
|
6106
6120
|
} else {
|
|
6107
6121
|
return void 0;
|
|
@@ -6162,7 +6176,7 @@ function parseIndentedBlocks(src, config, lexer) {
|
|
|
6162
6176
|
}
|
|
6163
6177
|
return {
|
|
6164
6178
|
items,
|
|
6165
|
-
raw: totalRaw
|
|
6179
|
+
raw: totalRaw
|
|
6166
6180
|
};
|
|
6167
6181
|
}
|
|
6168
6182
|
|