@domternal/core 0.7.5 → 0.8.0
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 +10 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4132,7 +4132,7 @@ function defaultBubbleContexts(editor) {
|
|
|
4132
4132
|
var LIST_ITEM_TYPES3 = /* @__PURE__ */ new Set(["listItem", "taskItem"]);
|
|
4133
4133
|
var LIST_WRAPPER_TYPES = /* @__PURE__ */ new Set(["bulletList", "orderedList", "taskList"]);
|
|
4134
4134
|
function insertAsListItemChild(args) {
|
|
4135
|
-
const { tr, wrapperPos, targetItemPos, blockNode, sourceRange } = args;
|
|
4135
|
+
const { tr, wrapperPos, targetItemPos, blockNode, sourceRange, childIndex } = args;
|
|
4136
4136
|
if (wrapperPos < 0 || wrapperPos >= tr.doc.content.size) return { ok: false };
|
|
4137
4137
|
const wrapper = tr.doc.nodeAt(wrapperPos);
|
|
4138
4138
|
if (!wrapper || !LIST_WRAPPER_TYPES.has(wrapper.type.name)) return { ok: false };
|
|
@@ -4158,22 +4158,25 @@ function insertAsListItemChild(args) {
|
|
|
4158
4158
|
targetItem = last;
|
|
4159
4159
|
targetItemStart = pos;
|
|
4160
4160
|
}
|
|
4161
|
-
|
|
4161
|
+
const childCount = targetItem.childCount;
|
|
4162
|
+
const insertIndex = childIndex === void 0 || childIndex >= childCount ? childCount : Math.max(1, childIndex);
|
|
4163
|
+
if (!targetItem.canReplaceWith(insertIndex, insertIndex, blockNode.type)) {
|
|
4162
4164
|
return { ok: false };
|
|
4163
4165
|
}
|
|
4164
|
-
const
|
|
4166
|
+
const $item = tr.doc.resolve(targetItemStart + 1);
|
|
4167
|
+
const insertPos = $item.posAtIndex(insertIndex, $item.depth);
|
|
4165
4168
|
if (sourceRange) {
|
|
4166
4169
|
const { from, to } = sourceRange;
|
|
4167
|
-
if (
|
|
4170
|
+
if (insertPos >= from && insertPos <= to) {
|
|
4168
4171
|
return { ok: false };
|
|
4169
4172
|
}
|
|
4170
4173
|
tr.delete(from, to);
|
|
4171
|
-
const adjustedInsertPos =
|
|
4174
|
+
const adjustedInsertPos = insertPos > from ? insertPos - (to - from) : insertPos;
|
|
4172
4175
|
tr.insert(adjustedInsertPos, blockNode);
|
|
4173
4176
|
return { ok: true, insertedAt: adjustedInsertPos };
|
|
4174
4177
|
}
|
|
4175
|
-
tr.insert(
|
|
4176
|
-
return { ok: true, insertedAt:
|
|
4178
|
+
tr.insert(insertPos, blockNode);
|
|
4179
|
+
return { ok: true, insertedAt: insertPos };
|
|
4177
4180
|
}
|
|
4178
4181
|
function liftEmptyChildrenZoneParagraph(state$1, dispatch, ctx) {
|
|
4179
4182
|
if (!ctx.isInChildrenZone || !ctx.paragraphIsEmpty) return false;
|