@domternal/core 0.7.3 → 0.7.4
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 +41 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +41 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1126,7 +1126,7 @@ var markInputRulePatterns = {
|
|
|
1126
1126
|
highlight: /(?:==)([^=]+)(?:==)$/
|
|
1127
1127
|
};
|
|
1128
1128
|
function wrappingInputRule(options) {
|
|
1129
|
-
const { find: find2, type, getAttributes = null, joinPredicate, undoable, guard } = options;
|
|
1129
|
+
const { find: find2, type, getAttributes = null, joinPredicate, undoable, guard, joinForward } = options;
|
|
1130
1130
|
return new inputrules.InputRule(
|
|
1131
1131
|
find2,
|
|
1132
1132
|
(state, match, start, end) => {
|
|
@@ -1142,6 +1142,21 @@ function wrappingInputRule(options) {
|
|
|
1142
1142
|
if (before?.type === type && transform.canJoin(tr.doc, start - 1) && (!joinPredicate || joinPredicate(match, before))) {
|
|
1143
1143
|
tr.join(start - 1);
|
|
1144
1144
|
}
|
|
1145
|
+
if (joinForward) {
|
|
1146
|
+
const $cursor = tr.selection.$from;
|
|
1147
|
+
for (let d = $cursor.depth; d >= 0; d--) {
|
|
1148
|
+
if ($cursor.node(d).type === type) {
|
|
1149
|
+
const after = $cursor.after(d);
|
|
1150
|
+
if (after < tr.doc.content.size && transform.canJoin(tr.doc, after)) {
|
|
1151
|
+
const nodeAfter = tr.doc.nodeAt(after);
|
|
1152
|
+
if (nodeAfter?.type === type && (!joinPredicate || joinPredicate(match, nodeAfter))) {
|
|
1153
|
+
tr.join(after);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
break;
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1145
1160
|
return tr;
|
|
1146
1161
|
},
|
|
1147
1162
|
undoable !== void 0 ? { undoable } : {}
|
|
@@ -1962,6 +1977,7 @@ function isInListItemLabel($pos) {
|
|
|
1962
1977
|
}
|
|
1963
1978
|
|
|
1964
1979
|
// src/utils/liftCurrentListItem.ts
|
|
1980
|
+
var LIST_ITEM_TYPES = /* @__PURE__ */ new Set(["listItem", "taskItem"]);
|
|
1965
1981
|
function liftCurrentListItem(state, tr) {
|
|
1966
1982
|
if (!tr.selection.empty) return false;
|
|
1967
1983
|
if (tr.steps.length !== 0) return false;
|
|
@@ -1969,6 +1985,16 @@ function liftCurrentListItem(state, tr) {
|
|
|
1969
1985
|
const listItemDepth = findListItemAncestorDepth($from);
|
|
1970
1986
|
if (listItemDepth === -1) return false;
|
|
1971
1987
|
if ($from.index(listItemDepth) !== 0) return false;
|
|
1988
|
+
const wrapperParent = $from.node(listItemDepth - 2);
|
|
1989
|
+
const isNested = LIST_ITEM_TYPES.has(wrapperParent.type.name);
|
|
1990
|
+
if (isNested) {
|
|
1991
|
+
const range = $from.blockRange();
|
|
1992
|
+
if (!range) return false;
|
|
1993
|
+
const target = transform.liftTarget(range);
|
|
1994
|
+
if (target === null) return false;
|
|
1995
|
+
tr.lift(range, target);
|
|
1996
|
+
return true;
|
|
1997
|
+
}
|
|
1972
1998
|
const listItemType = $from.node(listItemDepth).type;
|
|
1973
1999
|
return schemaList.liftListItem(listItemType)(state, (liftTr) => {
|
|
1974
2000
|
for (const step of liftTr.steps) tr.step(step);
|
|
@@ -2176,13 +2202,13 @@ var lift = () => ({ tr, dispatch }) => {
|
|
|
2176
2202
|
};
|
|
2177
2203
|
|
|
2178
2204
|
// src/utils/listItemCursorContext.ts
|
|
2179
|
-
var
|
|
2205
|
+
var LIST_ITEM_TYPES2 = /* @__PURE__ */ new Set(["listItem", "taskItem"]);
|
|
2180
2206
|
function getListItemCursorContext($from) {
|
|
2181
2207
|
if ($from.parent.type.name !== "paragraph") return null;
|
|
2182
2208
|
const itemDepth = $from.depth - 1;
|
|
2183
2209
|
if (itemDepth < 1) return null;
|
|
2184
2210
|
const itemNode = $from.node(itemDepth);
|
|
2185
|
-
if (!
|
|
2211
|
+
if (!LIST_ITEM_TYPES2.has(itemNode.type.name)) return null;
|
|
2186
2212
|
const wrapperDepth = itemDepth - 1;
|
|
2187
2213
|
const childIndex = $from.index(itemDepth);
|
|
2188
2214
|
return {
|
|
@@ -4078,7 +4104,7 @@ function defaultBubbleContexts(editor) {
|
|
|
4078
4104
|
}
|
|
4079
4105
|
|
|
4080
4106
|
// src/utils/insertAsListItemChild.ts
|
|
4081
|
-
var
|
|
4107
|
+
var LIST_ITEM_TYPES3 = /* @__PURE__ */ new Set(["listItem", "taskItem"]);
|
|
4082
4108
|
var LIST_WRAPPER_TYPES = /* @__PURE__ */ new Set(["bulletList", "orderedList", "taskList"]);
|
|
4083
4109
|
function insertAsListItemChild(args) {
|
|
4084
4110
|
const { tr, wrapperPos, targetItemPos, blockNode, sourceRange } = args;
|
|
@@ -4091,7 +4117,7 @@ function insertAsListItemChild(args) {
|
|
|
4091
4117
|
if (targetItemPos !== void 0) {
|
|
4092
4118
|
if (targetItemPos < 0 || targetItemPos >= tr.doc.content.size) return { ok: false };
|
|
4093
4119
|
const candidate = tr.doc.nodeAt(targetItemPos);
|
|
4094
|
-
if (!candidate || !
|
|
4120
|
+
if (!candidate || !LIST_ITEM_TYPES3.has(candidate.type.name)) return { ok: false };
|
|
4095
4121
|
if (targetItemPos < wrapperPos + 1 || targetItemPos >= wrapperPos + wrapper.nodeSize) {
|
|
4096
4122
|
return { ok: false };
|
|
4097
4123
|
}
|
|
@@ -4099,7 +4125,7 @@ function insertAsListItemChild(args) {
|
|
|
4099
4125
|
targetItemStart = targetItemPos;
|
|
4100
4126
|
} else {
|
|
4101
4127
|
const last = wrapper.lastChild;
|
|
4102
|
-
if (!last || !
|
|
4128
|
+
if (!last || !LIST_ITEM_TYPES3.has(last.type.name)) return { ok: false };
|
|
4103
4129
|
let pos = wrapperPos + 1;
|
|
4104
4130
|
for (let i = 0; i < wrapper.childCount - 1; i++) {
|
|
4105
4131
|
pos += wrapper.child(i).nodeSize;
|
|
@@ -5893,11 +5919,11 @@ var BulletList = Node2.create({
|
|
|
5893
5919
|
}
|
|
5894
5920
|
return [
|
|
5895
5921
|
// - item
|
|
5896
|
-
wrappingInputRule({ find: /^\s*[-]\s$/, type: nodeType, guard: notInsideList }),
|
|
5922
|
+
wrappingInputRule({ find: /^\s*[-]\s$/, type: nodeType, guard: notInsideList, joinForward: true }),
|
|
5897
5923
|
// * item
|
|
5898
|
-
wrappingInputRule({ find: /^\s*[*]\s$/, type: nodeType, guard: notInsideList }),
|
|
5924
|
+
wrappingInputRule({ find: /^\s*[*]\s$/, type: nodeType, guard: notInsideList, joinForward: true }),
|
|
5899
5925
|
// + item
|
|
5900
|
-
wrappingInputRule({ find: /^\s*[+]\s$/, type: nodeType, guard: notInsideList })
|
|
5926
|
+
wrappingInputRule({ find: /^\s*[+]\s$/, type: nodeType, guard: notInsideList, joinForward: true })
|
|
5901
5927
|
];
|
|
5902
5928
|
}
|
|
5903
5929
|
});
|
|
@@ -5998,6 +6024,7 @@ var OrderedList = Node2.create({
|
|
|
5998
6024
|
find: /^(\d+)\.\s$/,
|
|
5999
6025
|
type: nodeType,
|
|
6000
6026
|
guard: notInsideList,
|
|
6027
|
+
joinForward: true,
|
|
6001
6028
|
getAttributes: (match) => {
|
|
6002
6029
|
const num = match[1];
|
|
6003
6030
|
return { start: num ? parseInt(num, 10) : 1 };
|
|
@@ -6527,9 +6554,9 @@ var TaskList = Node2.create({
|
|
|
6527
6554
|
}
|
|
6528
6555
|
return [
|
|
6529
6556
|
// [ ] at start of line creates unchecked task
|
|
6530
|
-
wrappingInputRule({ find: /^\s*\[\s?\]\s$/, type: nodeType, guard: notInsideList }),
|
|
6557
|
+
wrappingInputRule({ find: /^\s*\[\s?\]\s$/, type: nodeType, guard: notInsideList, joinForward: true }),
|
|
6531
6558
|
// [x] or [X] at start of line creates checked task
|
|
6532
|
-
wrappingInputRule({ find: /^\s*\[[xX]\]\s$/, type: nodeType, guard: notInsideList })
|
|
6559
|
+
wrappingInputRule({ find: /^\s*\[[xX]\]\s$/, type: nodeType, guard: notInsideList, joinForward: true })
|
|
6533
6560
|
];
|
|
6534
6561
|
}
|
|
6535
6562
|
});
|
|
@@ -7712,12 +7739,12 @@ var Placeholder = Extension.create({
|
|
|
7712
7739
|
];
|
|
7713
7740
|
}
|
|
7714
7741
|
});
|
|
7715
|
-
var
|
|
7742
|
+
var LIST_ITEM_TYPES4 = /* @__PURE__ */ new Set(["listItem", "taskItem"]);
|
|
7716
7743
|
var LIST_WRAPPER_TYPES2 = /* @__PURE__ */ new Set(["bulletList", "orderedList", "taskList"]);
|
|
7717
7744
|
function isCursorInsideListItem(state) {
|
|
7718
7745
|
const { $from } = state.selection;
|
|
7719
7746
|
for (let d = $from.depth; d > 0; d--) {
|
|
7720
|
-
if (
|
|
7747
|
+
if (LIST_ITEM_TYPES4.has($from.node(d).type.name)) return true;
|
|
7721
7748
|
}
|
|
7722
7749
|
return false;
|
|
7723
7750
|
}
|
|
@@ -7772,7 +7799,7 @@ function outdentBlockFromListItem(state$1, dispatch) {
|
|
|
7772
7799
|
const { $from } = selection;
|
|
7773
7800
|
let listItemDepth = -1;
|
|
7774
7801
|
for (let d = $from.depth; d > 0; d--) {
|
|
7775
|
-
if (
|
|
7802
|
+
if (LIST_ITEM_TYPES4.has($from.node(d).type.name)) {
|
|
7776
7803
|
listItemDepth = d;
|
|
7777
7804
|
break;
|
|
7778
7805
|
}
|