@trafica/editor 1.0.40 → 1.0.42
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.js +51 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1417,6 +1417,14 @@ function getActiveBlockType(doc, selection) {
|
|
|
1417
1417
|
const level = (_b = (_a = node.attrs) == null ? void 0 : _a.level) != null ? _b : 1;
|
|
1418
1418
|
return `heading-${level}`;
|
|
1419
1419
|
}
|
|
1420
|
+
if (type === "list_item" && depth > 0) {
|
|
1421
|
+
const parent = getNodeAtPath(doc, path.slice(0, depth - 1));
|
|
1422
|
+
if (parent && !isTextNode(parent)) {
|
|
1423
|
+
const pt = parent.type;
|
|
1424
|
+
if (pt === "bullet_list" || pt === "ordered_list") return pt;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
if (type === "check_list_item") return "check_list";
|
|
1420
1428
|
return type;
|
|
1421
1429
|
}
|
|
1422
1430
|
}
|
|
@@ -2507,6 +2515,30 @@ var toggleListOfType = (listType) => (engine) => {
|
|
|
2507
2515
|
engine.dispatch(tr);
|
|
2508
2516
|
return true;
|
|
2509
2517
|
}
|
|
2518
|
+
if (block.type === "list_item" && (parentType === "bullet_list" || parentType === "ordered_list")) {
|
|
2519
|
+
tr.steps.push(tr_setNodeType(parentPath, listType, {}));
|
|
2520
|
+
engine.dispatch(tr);
|
|
2521
|
+
return true;
|
|
2522
|
+
}
|
|
2523
|
+
if (block.type === "check_list_item" && parentType === "check_list") {
|
|
2524
|
+
const checkList = parent;
|
|
2525
|
+
const grandParentPath = parentPath.slice(0, -1);
|
|
2526
|
+
const listIdx = parentPath[parentPath.length - 1];
|
|
2527
|
+
const convertedList = {
|
|
2528
|
+
type: listType,
|
|
2529
|
+
attrs: {},
|
|
2530
|
+
children: checkList.children.map((item) => ({
|
|
2531
|
+
type: "list_item",
|
|
2532
|
+
attrs: {},
|
|
2533
|
+
children: item.children
|
|
2534
|
+
}))
|
|
2535
|
+
};
|
|
2536
|
+
tr.steps.push({ type: "delete_node", path: parentPath });
|
|
2537
|
+
tr.steps.push({ type: "insert_node", parentPath: grandParentPath, index: listIdx, node: convertedList });
|
|
2538
|
+
tr.steps.push(tr_setSelection(makeCollapsedSelection(makePosition([...grandParentPath, listIdx, blockIdx, 0], 0))));
|
|
2539
|
+
engine.dispatch(tr);
|
|
2540
|
+
return true;
|
|
2541
|
+
}
|
|
2510
2542
|
const listItem = {
|
|
2511
2543
|
type: "list_item",
|
|
2512
2544
|
attrs: {},
|
|
@@ -2665,6 +2697,25 @@ var toggleCheckList = (engine) => {
|
|
|
2665
2697
|
engine.dispatch(tr);
|
|
2666
2698
|
return true;
|
|
2667
2699
|
}
|
|
2700
|
+
if (block.type === "list_item" && (parentType === "bullet_list" || parentType === "ordered_list")) {
|
|
2701
|
+
const listNode = parent;
|
|
2702
|
+
const grandParentPath = parentPath.slice(0, -1);
|
|
2703
|
+
const listIdx = parentPath[parentPath.length - 1];
|
|
2704
|
+
const convertedList = {
|
|
2705
|
+
type: "check_list",
|
|
2706
|
+
attrs: {},
|
|
2707
|
+
children: listNode.children.map((item) => ({
|
|
2708
|
+
type: "check_list_item",
|
|
2709
|
+
attrs: { checked: false },
|
|
2710
|
+
children: item.children
|
|
2711
|
+
}))
|
|
2712
|
+
};
|
|
2713
|
+
tr.steps.push({ type: "delete_node", path: parentPath });
|
|
2714
|
+
tr.steps.push({ type: "insert_node", parentPath: grandParentPath, index: listIdx, node: convertedList });
|
|
2715
|
+
tr.steps.push(tr_setSelection(makeCollapsedSelection(makePosition([...grandParentPath, listIdx, blockIdx, 0], 0))));
|
|
2716
|
+
engine.dispatch(tr);
|
|
2717
|
+
return true;
|
|
2718
|
+
}
|
|
2668
2719
|
const checkListItem = { type: "check_list_item", attrs: { checked: false }, children: block.children };
|
|
2669
2720
|
const checkListNode = { type: "check_list", attrs: {}, children: [checkListItem] };
|
|
2670
2721
|
tr.steps.push({ type: "delete_node", path: blockPath });
|