@tiptap/core 3.4.5 → 3.4.6

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.d.cts CHANGED
@@ -51,6 +51,7 @@ declare class InputRule {
51
51
  chain: () => ChainedCommands;
52
52
  can: () => CanCommands;
53
53
  }) => void | null;
54
+ undoable: boolean;
54
55
  constructor(config: {
55
56
  find: InputRuleFinder;
56
57
  handler: (props: {
@@ -61,6 +62,7 @@ declare class InputRule {
61
62
  chain: () => ChainedCommands;
62
63
  can: () => CanCommands;
63
64
  }) => void | null;
65
+ undoable?: boolean;
64
66
  });
65
67
  }
66
68
  /**
@@ -3120,6 +3122,7 @@ declare class CommandManager {
3120
3122
  declare function markInputRule(config: {
3121
3123
  find: InputRuleFinder;
3122
3124
  type: MarkType$1;
3125
+ undoable?: boolean;
3123
3126
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
3124
3127
  }): InputRule;
3125
3128
 
@@ -3137,6 +3140,11 @@ declare function nodeInputRule(config: {
3137
3140
  * The node type to add.
3138
3141
  */
3139
3142
  type: NodeType$1;
3143
+ /**
3144
+ * Whether the input rule should be undoable
3145
+ * when the user presses backspace.
3146
+ */
3147
+ undoable?: boolean;
3140
3148
  /**
3141
3149
  * A function that returns the attributes for the node
3142
3150
  * can also be an object of attributes
@@ -3154,6 +3162,7 @@ declare function nodeInputRule(config: {
3154
3162
  declare function textblockTypeInputRule(config: {
3155
3163
  find: InputRuleFinder;
3156
3164
  type: NodeType$1;
3165
+ undoable?: boolean;
3157
3166
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
3158
3167
  }): InputRule;
3159
3168
 
@@ -3165,6 +3174,7 @@ declare function textblockTypeInputRule(config: {
3165
3174
  declare function textInputRule(config: {
3166
3175
  find: InputRuleFinder;
3167
3176
  replace: string;
3177
+ undoable?: boolean;
3168
3178
  }): InputRule;
3169
3179
 
3170
3180
  /**
@@ -3188,6 +3198,7 @@ declare function wrappingInputRule(config: {
3188
3198
  keepMarks?: boolean;
3189
3199
  keepAttributes?: boolean;
3190
3200
  editor?: Editor;
3201
+ undoable?: boolean;
3191
3202
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
3192
3203
  joinPredicate?: (match: ExtendedRegExpMatchArray, node: Node$1) => boolean;
3193
3204
  }): InputRule;
package/dist/index.d.ts CHANGED
@@ -51,6 +51,7 @@ declare class InputRule {
51
51
  chain: () => ChainedCommands;
52
52
  can: () => CanCommands;
53
53
  }) => void | null;
54
+ undoable: boolean;
54
55
  constructor(config: {
55
56
  find: InputRuleFinder;
56
57
  handler: (props: {
@@ -61,6 +62,7 @@ declare class InputRule {
61
62
  chain: () => ChainedCommands;
62
63
  can: () => CanCommands;
63
64
  }) => void | null;
65
+ undoable?: boolean;
64
66
  });
65
67
  }
66
68
  /**
@@ -3120,6 +3122,7 @@ declare class CommandManager {
3120
3122
  declare function markInputRule(config: {
3121
3123
  find: InputRuleFinder;
3122
3124
  type: MarkType$1;
3125
+ undoable?: boolean;
3123
3126
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
3124
3127
  }): InputRule;
3125
3128
 
@@ -3137,6 +3140,11 @@ declare function nodeInputRule(config: {
3137
3140
  * The node type to add.
3138
3141
  */
3139
3142
  type: NodeType$1;
3143
+ /**
3144
+ * Whether the input rule should be undoable
3145
+ * when the user presses backspace.
3146
+ */
3147
+ undoable?: boolean;
3140
3148
  /**
3141
3149
  * A function that returns the attributes for the node
3142
3150
  * can also be an object of attributes
@@ -3154,6 +3162,7 @@ declare function nodeInputRule(config: {
3154
3162
  declare function textblockTypeInputRule(config: {
3155
3163
  find: InputRuleFinder;
3156
3164
  type: NodeType$1;
3165
+ undoable?: boolean;
3157
3166
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
3158
3167
  }): InputRule;
3159
3168
 
@@ -3165,6 +3174,7 @@ declare function textblockTypeInputRule(config: {
3165
3174
  declare function textInputRule(config: {
3166
3175
  find: InputRuleFinder;
3167
3176
  replace: string;
3177
+ undoable?: boolean;
3168
3178
  }): InputRule;
3169
3179
 
3170
3180
  /**
@@ -3188,6 +3198,7 @@ declare function wrappingInputRule(config: {
3188
3198
  keepMarks?: boolean;
3189
3199
  keepAttributes?: boolean;
3190
3200
  editor?: Editor;
3201
+ undoable?: boolean;
3191
3202
  getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
3192
3203
  joinPredicate?: (match: ExtendedRegExpMatchArray, node: Node$1) => boolean;
3193
3204
  }): InputRule;
package/dist/index.js CHANGED
@@ -1568,8 +1568,10 @@ import { Fragment as Fragment2 } from "@tiptap/pm/model";
1568
1568
  import { Plugin } from "@tiptap/pm/state";
1569
1569
  var InputRule = class {
1570
1570
  constructor(config) {
1571
+ var _a;
1571
1572
  this.find = config.find;
1572
1573
  this.handler = config.handler;
1574
+ this.undoable = (_a = config.undoable) != null ? _a : true;
1573
1575
  }
1574
1576
  };
1575
1577
  var inputRuleMatcherHandler = (text, find) => {
@@ -1641,12 +1643,14 @@ function run(config) {
1641
1643
  if (handler === null || !tr.steps.length) {
1642
1644
  return;
1643
1645
  }
1644
- tr.setMeta(plugin, {
1645
- transform: tr,
1646
- from,
1647
- to,
1648
- text
1649
- });
1646
+ if (rule.undoable) {
1647
+ tr.setMeta(plugin, {
1648
+ transform: tr,
1649
+ from,
1650
+ to,
1651
+ text
1652
+ });
1653
+ }
1650
1654
  view.dispatch(tr);
1651
1655
  matched = true;
1652
1656
  });
@@ -4862,7 +4866,8 @@ function markInputRule(config) {
4862
4866
  tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
4863
4867
  tr.removeStoredMark(config.type);
4864
4868
  }
4865
- }
4869
+ },
4870
+ undoable: config.undoable
4866
4871
  });
4867
4872
  }
4868
4873
 
@@ -4892,7 +4897,8 @@ function nodeInputRule(config) {
4892
4897
  tr.insert(insertionStart, config.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end));
4893
4898
  }
4894
4899
  tr.scrollIntoView();
4895
- }
4900
+ },
4901
+ undoable: config.undoable
4896
4902
  });
4897
4903
  }
4898
4904
 
@@ -4907,7 +4913,8 @@ function textblockTypeInputRule(config) {
4907
4913
  return null;
4908
4914
  }
4909
4915
  state.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
4910
- }
4916
+ },
4917
+ undoable: config.undoable
4911
4918
  });
4912
4919
  }
4913
4920
 
@@ -4930,7 +4937,8 @@ function textInputRule(config) {
4930
4937
  }
4931
4938
  }
4932
4939
  state.tr.insertText(insert, start, end);
4933
- }
4940
+ },
4941
+ undoable: config.undoable
4934
4942
  });
4935
4943
  }
4936
4944
 
@@ -4966,7 +4974,8 @@ function wrappingInputRule(config) {
4966
4974
  if (before && before.type === config.type && canJoin2(tr.doc, range.from - 1) && (!config.joinPredicate || config.joinPredicate(match, before))) {
4967
4975
  tr.join(range.from - 1);
4968
4976
  }
4969
- }
4977
+ },
4978
+ undoable: config.undoable
4970
4979
  });
4971
4980
  }
4972
4981