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