@modusoperandi/licit 1.4.7 → 1.4.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.
@@ -48,6 +48,9 @@ function insertTabSpace(state, tr, schema) {
48
48
  return tr;
49
49
  }
50
50
  var textNode = schema.text(HAIR_SPACE_CHAR);
51
+ if (paragraphHasSpacerMark(found.node)) {
52
+ return tr;
53
+ }
51
54
  tr = tr.insert(to, Fragment.from(textNode));
52
55
  var attrs = {
53
56
  size: SPACER_SIZE_TAB
@@ -57,6 +60,21 @@ function insertTabSpace(state, tr, schema) {
57
60
  tr = tr.setSelection(TextSelection.create(tr.doc, to + 1, to + 1));
58
61
  return tr;
59
62
  }
63
+ // Check if a paragraph node has a hanging indent mark applied to any of its text nodes
64
+ // if yes, return true otherwise false, to avoid strange behavior with multiple hanging indent marks
65
+ function paragraphHasSpacerMark(node) {
66
+ var found = false;
67
+ node.descendants(function (child) {
68
+ if (child.isText && child.marks.some(function (m) {
69
+ return m.type.name === 'mark-hanging-indent';
70
+ })) {
71
+ found = true;
72
+ return false; // stop traversal
73
+ }
74
+ return true;
75
+ });
76
+ return found;
77
+ }
60
78
  var TextInsertTabSpaceCommand = /*#__PURE__*/function (_UICommand) {
61
79
  function TextInsertTabSpaceCommand() {
62
80
  var _this;
@@ -47,6 +47,9 @@ function insertTabSpace(
47
47
  }
48
48
 
49
49
  const textNode = schema.text(HAIR_SPACE_CHAR);
50
+ if (paragraphHasSpacerMark(found.node)) {
51
+ return tr;
52
+ }
50
53
  tr = tr.insert(to, Fragment.from(textNode));
51
54
  const attrs = {
52
55
  size: SPACER_SIZE_TAB,
@@ -60,6 +63,19 @@ function insertTabSpace(
60
63
 
61
64
  return tr;
62
65
  }
66
+ // Check if a paragraph node has a hanging indent mark applied to any of its text nodes
67
+ // if yes, return true otherwise false, to avoid strange behavior with multiple hanging indent marks
68
+ function paragraphHasSpacerMark(node) {
69
+ let found = false;
70
+ node.descendants((child) => {
71
+ if (child.isText && child.marks.some(m => m.type.name === 'mark-hanging-indent')) {
72
+ found = true;
73
+ return false; // stop traversal
74
+ }
75
+ return true;
76
+ });
77
+ return found;
78
+ }
63
79
 
64
80
  class TextInsertTabSpaceCommand extends UICommand {
65
81
  execute = (