@tiptap/extensions 3.30.1 → 3.30.3

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.
Files changed (73) hide show
  1. package/dist/character-count/index.cjs +84 -128
  2. package/dist/character-count/index.cjs.map +1 -1
  3. package/dist/character-count/index.d.cts +59 -58
  4. package/dist/character-count/index.d.cts.map +1 -0
  5. package/dist/character-count/index.d.ts +59 -58
  6. package/dist/character-count/index.d.ts.map +1 -0
  7. package/dist/character-count/index.js +82 -100
  8. package/dist/character-count/index.js.map +1 -1
  9. package/dist/drop-cursor/index.cjs +24 -44
  10. package/dist/drop-cursor/index.cjs.map +1 -1
  11. package/dist/drop-cursor/index.d.cts +23 -22
  12. package/dist/drop-cursor/index.d.cts.map +1 -0
  13. package/dist/drop-cursor/index.d.ts +23 -22
  14. package/dist/drop-cursor/index.d.ts.map +1 -0
  15. package/dist/drop-cursor/index.js +22 -16
  16. package/dist/drop-cursor/index.js.map +1 -1
  17. package/dist/focus/index.cjs +45 -92
  18. package/dist/focus/index.cjs.map +1 -1
  19. package/dist/focus/index.d.cts +22 -21
  20. package/dist/focus/index.d.cts.map +1 -0
  21. package/dist/focus/index.d.ts +22 -21
  22. package/dist/focus/index.d.ts.map +1 -0
  23. package/dist/focus/index.js +42 -63
  24. package/dist/focus/index.js.map +1 -1
  25. package/dist/gap-cursor/index.cjs +25 -48
  26. package/dist/gap-cursor/index.cjs.map +1 -1
  27. package/dist/gap-cursor/index.d.cts +16 -15
  28. package/dist/gap-cursor/index.d.cts.map +1 -0
  29. package/dist/gap-cursor/index.d.ts +16 -15
  30. package/dist/gap-cursor/index.d.ts.map +1 -0
  31. package/dist/gap-cursor/index.js +24 -21
  32. package/dist/gap-cursor/index.js.map +1 -1
  33. package/dist/index.cjs +666 -742
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +231 -220
  36. package/dist/index.d.cts.map +1 -0
  37. package/dist/index.d.ts +231 -220
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +653 -703
  40. package/dist/index.js.map +1 -1
  41. package/dist/placeholder/index.cjs +344 -376
  42. package/dist/placeholder/index.cjs.map +1 -1
  43. package/dist/placeholder/index.d.cts +73 -69
  44. package/dist/placeholder/index.d.cts.map +1 -0
  45. package/dist/placeholder/index.d.ts +73 -69
  46. package/dist/placeholder/index.d.ts.map +1 -0
  47. package/dist/placeholder/index.js +340 -346
  48. package/dist/placeholder/index.js.map +1 -1
  49. package/dist/selection/index.cjs +62 -86
  50. package/dist/selection/index.cjs.map +1 -1
  51. package/dist/selection/index.d.cts +11 -10
  52. package/dist/selection/index.d.cts.map +1 -0
  53. package/dist/selection/index.d.ts +11 -10
  54. package/dist/selection/index.d.ts.map +1 -0
  55. package/dist/selection/index.js +58 -56
  56. package/dist/selection/index.js.map +1 -1
  57. package/dist/trailing-node/index.cjs +59 -89
  58. package/dist/trailing-node/index.cjs.map +1 -1
  59. package/dist/trailing-node/index.d.cts +17 -16
  60. package/dist/trailing-node/index.d.cts.map +1 -0
  61. package/dist/trailing-node/index.d.ts +17 -16
  62. package/dist/trailing-node/index.d.ts.map +1 -0
  63. package/dist/trailing-node/index.js +55 -59
  64. package/dist/trailing-node/index.js.map +1 -1
  65. package/dist/undo-redo/index.cjs +45 -63
  66. package/dist/undo-redo/index.cjs.map +1 -1
  67. package/dist/undo-redo/index.d.cts +31 -30
  68. package/dist/undo-redo/index.d.cts.map +1 -0
  69. package/dist/undo-redo/index.d.ts +31 -30
  70. package/dist/undo-redo/index.d.ts.map +1 -0
  71. package/dist/undo-redo/index.js +43 -35
  72. package/dist/undo-redo/index.js.map +1 -1
  73. package/package.json +6 -6
@@ -1,92 +1,62 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/trailing-node/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- TrailingNode: () => TrailingNode,
24
- skipTrailingNodeMeta: () => skipTrailingNodeMeta
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
- // src/trailing-node/trailing-node.ts
29
- var import_core = require("@tiptap/core");
30
- var import_state = require("@tiptap/pm/state");
31
- var skipTrailingNodeMeta = "skipTrailingNode";
32
- function nodeEqualsType({
33
- types,
34
- node
35
- }) {
36
- return node && Array.isArray(types) && types.includes(node.type) || (node == null ? void 0 : node.type) === types;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _tiptap_core = require("@tiptap/core");
3
+ let _tiptap_pm_state = require("@tiptap/pm/state");
4
+ //#region src/trailing-node/trailing-node.ts
5
+ const skipTrailingNodeMeta = "skipTrailingNode";
6
+ function nodeEqualsType({ types, node }) {
7
+ return node && Array.isArray(types) && types.includes(node.type) || (node === null || node === void 0 ? void 0 : node.type) === types;
37
8
  }
38
- var TrailingNode = import_core.Extension.create({
39
- name: "trailingNode",
40
- addOptions() {
41
- return {
42
- node: void 0,
43
- notAfter: []
44
- };
45
- },
46
- addProseMirrorPlugins() {
47
- var _a;
48
- const plugin = new import_state.PluginKey(this.name);
49
- const defaultNode = this.options.node || ((_a = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : _a.name) || "paragraph";
50
- const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));
51
- return [
52
- new import_state.Plugin({
53
- key: plugin,
54
- appendTransaction: (transactions, __, state) => {
55
- const { doc, tr, schema } = state;
56
- const shouldInsertNodeAtEnd = plugin.getState(state);
57
- const endPosition = doc.content.size;
58
- const type = schema.nodes[defaultNode];
59
- if (transactions.some((transaction) => transaction.getMeta(skipTrailingNodeMeta))) {
60
- return;
61
- }
62
- if (!shouldInsertNodeAtEnd) {
63
- return;
64
- }
65
- return tr.insert(endPosition, type.create());
66
- },
67
- state: {
68
- init: (_, state) => {
69
- const lastNode = state.tr.doc.lastChild;
70
- return !nodeEqualsType({ node: lastNode, types: disabledNodes });
71
- },
72
- apply: (tr, value) => {
73
- if (!tr.docChanged) {
74
- return value;
75
- }
76
- if (tr.getMeta("__uniqueIDTransaction")) {
77
- return value;
78
- }
79
- const lastNode = tr.doc.lastChild;
80
- return !nodeEqualsType({ node: lastNode, types: disabledNodes });
81
- }
82
- }
83
- })
84
- ];
85
- }
86
- });
87
- // Annotate the CommonJS export names for ESM import in node:
88
- 0 && (module.exports = {
89
- TrailingNode,
90
- skipTrailingNodeMeta
9
+ /**
10
+ * This extension allows you to add an extra node at the end of the document.
11
+ * @see https://www.tiptap.dev/api/extensions/trailing-node
12
+ */
13
+ const TrailingNode = _tiptap_core.Extension.create({
14
+ name: "trailingNode",
15
+ addOptions() {
16
+ return {
17
+ node: void 0,
18
+ notAfter: []
19
+ };
20
+ },
21
+ addProseMirrorPlugins() {
22
+ var _this$editor$schema$t;
23
+ const plugin = new _tiptap_pm_state.PluginKey(this.name);
24
+ const defaultNode = this.options.node || ((_this$editor$schema$t = this.editor.schema.topNodeType.contentMatch.defaultType) === null || _this$editor$schema$t === void 0 ? void 0 : _this$editor$schema$t.name) || "paragraph";
25
+ const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));
26
+ return [new _tiptap_pm_state.Plugin({
27
+ key: plugin,
28
+ appendTransaction: (transactions, __, state) => {
29
+ const { doc, tr, schema } = state;
30
+ const shouldInsertNodeAtEnd = plugin.getState(state);
31
+ const endPosition = doc.content.size;
32
+ const type = schema.nodes[defaultNode];
33
+ if (transactions.some((transaction) => transaction.getMeta("skipTrailingNode"))) return;
34
+ if (!shouldInsertNodeAtEnd) return;
35
+ return tr.insert(endPosition, type.create());
36
+ },
37
+ state: {
38
+ init: (_, state) => {
39
+ const lastNode = state.tr.doc.lastChild;
40
+ return !nodeEqualsType({
41
+ node: lastNode,
42
+ types: disabledNodes
43
+ });
44
+ },
45
+ apply: (tr, value) => {
46
+ if (!tr.docChanged) return value;
47
+ if (tr.getMeta("__uniqueIDTransaction")) return value;
48
+ const lastNode = tr.doc.lastChild;
49
+ return !nodeEqualsType({
50
+ node: lastNode,
51
+ types: disabledNodes
52
+ });
53
+ }
54
+ }
55
+ })];
56
+ }
91
57
  });
58
+ //#endregion
59
+ exports.TrailingNode = TrailingNode;
60
+ exports.skipTrailingNodeMeta = skipTrailingNodeMeta;
61
+
92
62
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/trailing-node/index.ts","../../src/trailing-node/trailing-node.ts"],"sourcesContent":["export * from './trailing-node.js'\n","import { Extension } from '@tiptap/core'\nimport type { Node, NodeType } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nexport const skipTrailingNodeMeta = 'skipTrailingNode'\n\nfunction nodeEqualsType({\n types,\n node,\n}: {\n types: NodeType | NodeType[]\n node: Node | null | undefined\n}) {\n return (node && Array.isArray(types) && types.includes(node.type)) || node?.type === types\n}\n\n/**\n * Extension based on:\n * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js\n * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts\n */\n\nexport interface TrailingNodeOptions {\n /**\n * The node type that should be inserted at the end of the document.\n * @note the node will always be added to the `notAfter` lists to\n * prevent an infinite loop.\n * @default undefined\n */\n node?: string\n /**\n * The node types after which the trailing node should not be inserted.\n * @default ['paragraph']\n */\n notAfter?: string | string[]\n}\n\n/**\n * This extension allows you to add an extra node at the end of the document.\n * @see https://www.tiptap.dev/api/extensions/trailing-node\n */\nexport const TrailingNode = Extension.create<TrailingNodeOptions>({\n name: 'trailingNode',\n\n addOptions() {\n return {\n node: undefined,\n notAfter: [],\n }\n },\n\n addProseMirrorPlugins() {\n const plugin = new PluginKey(this.name)\n const defaultNode =\n this.options.node ||\n this.editor.schema.topNodeType.contentMatch.defaultType?.name ||\n 'paragraph'\n\n const disabledNodes = Object.entries(this.editor.schema.nodes)\n .map(([, value]) => value)\n .filter(node => (this.options.notAfter || []).concat(defaultNode).includes(node.name))\n\n return [\n new Plugin({\n key: plugin,\n appendTransaction: (transactions, __, state) => {\n const { doc, tr, schema } = state\n const shouldInsertNodeAtEnd = plugin.getState(state)\n const endPosition = doc.content.size\n const type = schema.nodes[defaultNode]\n\n if (transactions.some(transaction => transaction.getMeta(skipTrailingNodeMeta))) {\n return\n }\n\n if (!shouldInsertNodeAtEnd) {\n return\n }\n\n return tr.insert(endPosition, type.create())\n },\n state: {\n init: (_, state) => {\n const lastNode = state.tr.doc.lastChild\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes })\n },\n apply: (tr, value) => {\n if (!tr.docChanged) {\n return value\n }\n\n // Ignore transactions from UniqueID extension to prevent infinite loops\n // when UniqueID adds IDs to newly inserted trailing nodes\n if (tr.getMeta('__uniqueIDTransaction')) {\n return value\n }\n\n const lastNode = tr.doc.lastChild\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes })\n },\n },\n }),\n ]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA0B;AAE1B,mBAAkC;AAE3B,IAAM,uBAAuB;AAEpC,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AACF,GAGG;AACD,SAAQ,QAAQ,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,KAAK,IAAI,MAAM,6BAAM,UAAS;AACvF;AA2BO,IAAM,eAAe,sBAAU,OAA4B;AAAA,EAChE,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU,CAAC;AAAA,IACb;AAAA,EACF;AAAA,EAEA,wBAAwB;AAnD1B;AAoDI,UAAM,SAAS,IAAI,uBAAU,KAAK,IAAI;AACtC,UAAM,cACJ,KAAK,QAAQ,UACb,UAAK,OAAO,OAAO,YAAY,aAAa,gBAA5C,mBAAyD,SACzD;AAEF,UAAM,gBAAgB,OAAO,QAAQ,KAAK,OAAO,OAAO,KAAK,EAC1D,IAAI,CAAC,CAAC,EAAE,KAAK,MAAM,KAAK,EACxB,OAAO,WAAS,KAAK,QAAQ,YAAY,CAAC,GAAG,OAAO,WAAW,EAAE,SAAS,KAAK,IAAI,CAAC;AAEvF,WAAO;AAAA,MACL,IAAI,oBAAO;AAAA,QACT,KAAK;AAAA,QACL,mBAAmB,CAAC,cAAc,IAAI,UAAU;AAC9C,gBAAM,EAAE,KAAK,IAAI,OAAO,IAAI;AAC5B,gBAAM,wBAAwB,OAAO,SAAS,KAAK;AACnD,gBAAM,cAAc,IAAI,QAAQ;AAChC,gBAAM,OAAO,OAAO,MAAM,WAAW;AAErC,cAAI,aAAa,KAAK,iBAAe,YAAY,QAAQ,oBAAoB,CAAC,GAAG;AAC/E;AAAA,UACF;AAEA,cAAI,CAAC,uBAAuB;AAC1B;AAAA,UACF;AAEA,iBAAO,GAAG,OAAO,aAAa,KAAK,OAAO,CAAC;AAAA,QAC7C;AAAA,QACA,OAAO;AAAA,UACL,MAAM,CAAC,GAAG,UAAU;AAClB,kBAAM,WAAW,MAAM,GAAG,IAAI;AAE9B,mBAAO,CAAC,eAAe,EAAE,MAAM,UAAU,OAAO,cAAc,CAAC;AAAA,UACjE;AAAA,UACA,OAAO,CAAC,IAAI,UAAU;AACpB,gBAAI,CAAC,GAAG,YAAY;AAClB,qBAAO;AAAA,YACT;AAIA,gBAAI,GAAG,QAAQ,uBAAuB,GAAG;AACvC,qBAAO;AAAA,YACT;AAEA,kBAAM,WAAW,GAAG,IAAI;AAExB,mBAAO,CAAC,eAAe,EAAE,MAAM,UAAU,OAAO,cAAc,CAAC;AAAA,UACjE;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"file":"index.cjs","names":["Extension","PluginKey","Plugin"],"sources":["../../src/trailing-node/trailing-node.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport type { Node, NodeType } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nexport const skipTrailingNodeMeta = 'skipTrailingNode'\n\nfunction nodeEqualsType({\n types,\n node,\n}: {\n types: NodeType | NodeType[]\n node: Node | null | undefined\n}) {\n return (node && Array.isArray(types) && types.includes(node.type)) || node?.type === types\n}\n\n/**\n * Extension based on:\n * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js\n * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts\n */\n\nexport interface TrailingNodeOptions {\n /**\n * The node type that should be inserted at the end of the document.\n * @note the node will always be added to the `notAfter` lists to\n * prevent an infinite loop.\n * @default undefined\n */\n node?: string\n /**\n * The node types after which the trailing node should not be inserted.\n * @default ['paragraph']\n */\n notAfter?: string | string[]\n}\n\n/**\n * This extension allows you to add an extra node at the end of the document.\n * @see https://www.tiptap.dev/api/extensions/trailing-node\n */\nexport const TrailingNode = Extension.create<TrailingNodeOptions>({\n name: 'trailingNode',\n\n addOptions() {\n return {\n node: undefined,\n notAfter: [],\n }\n },\n\n addProseMirrorPlugins() {\n const plugin = new PluginKey(this.name)\n const defaultNode =\n this.options.node ||\n this.editor.schema.topNodeType.contentMatch.defaultType?.name ||\n 'paragraph'\n\n const disabledNodes = Object.entries(this.editor.schema.nodes)\n .map(([, value]) => value)\n .filter(node => (this.options.notAfter || []).concat(defaultNode).includes(node.name))\n\n return [\n new Plugin({\n key: plugin,\n appendTransaction: (transactions, __, state) => {\n const { doc, tr, schema } = state\n const shouldInsertNodeAtEnd = plugin.getState(state)\n const endPosition = doc.content.size\n const type = schema.nodes[defaultNode]\n\n if (transactions.some(transaction => transaction.getMeta(skipTrailingNodeMeta))) {\n return\n }\n\n if (!shouldInsertNodeAtEnd) {\n return\n }\n\n return tr.insert(endPosition, type.create())\n },\n state: {\n init: (_, state) => {\n const lastNode = state.tr.doc.lastChild\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes })\n },\n apply: (tr, value) => {\n if (!tr.docChanged) {\n return value\n }\n\n // Ignore transactions from UniqueID extension to prevent infinite loops\n // when UniqueID adds IDs to newly inserted trailing nodes\n if (tr.getMeta('__uniqueIDTransaction')) {\n return value\n }\n\n const lastNode = tr.doc.lastChild\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes })\n },\n },\n }),\n ]\n },\n})\n"],"mappings":";;;;AAIA,MAAa,uBAAuB;AAEpC,SAAS,eAAe,EACtB,OACA,QAIC;CACD,OAAQ,QAAQ,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,KAAK,IAAI,MAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAM,KAAM,UAAS;AACvF;;;;;AA2BA,MAAa,eAAeA,aAAAA,UAAU,OAA4B;CAChE,MAAM;CAEN,aAAa;EACX,OAAO;GACL,MAAM,KAAA;GACN,UAAU,CAAC;EACb;CACF;CAEA,wBAAwB;;EACtB,MAAM,SAAS,IAAIC,iBAAAA,UAAU,KAAK,IAAI;EACtC,MAAM,cACJ,KAAK,QAAQ,UAAA,wBACb,KAAK,OAAO,OAAO,YAAY,aAAa,iBAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAa,SACzD;EAEF,MAAM,gBAAgB,OAAO,QAAQ,KAAK,OAAO,OAAO,KAAK,CAAC,CAC3D,KAAK,GAAG,WAAW,KAAK,CAAC,CACzB,QAAO,UAAS,KAAK,QAAQ,YAAY,CAAC,EAAA,CAAG,OAAO,WAAW,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC;EAEvF,OAAO,CACL,IAAIC,iBAAAA,OAAO;GACT,KAAK;GACL,oBAAoB,cAAc,IAAI,UAAU;IAC9C,MAAM,EAAE,KAAK,IAAI,WAAW;IAC5B,MAAM,wBAAwB,OAAO,SAAS,KAAK;IACnD,MAAM,cAAc,IAAI,QAAQ;IAChC,MAAM,OAAO,OAAO,MAAM;IAE1B,IAAI,aAAa,MAAK,gBAAe,YAAY,QAAA,kBAA4B,CAAC,GAC5E;IAGF,IAAI,CAAC,uBACH;IAGF,OAAO,GAAG,OAAO,aAAa,KAAK,OAAO,CAAC;GAC7C;GACA,OAAO;IACL,OAAO,GAAG,UAAU;KAClB,MAAM,WAAW,MAAM,GAAG,IAAI;KAE9B,OAAO,CAAC,eAAe;MAAE,MAAM;MAAU,OAAO;KAAc,CAAC;IACjE;IACA,QAAQ,IAAI,UAAU;KACpB,IAAI,CAAC,GAAG,YACN,OAAO;KAKT,IAAI,GAAG,QAAQ,uBAAuB,GACpC,OAAO;KAGT,MAAM,WAAW,GAAG,IAAI;KAExB,OAAO,CAAC,eAAe;MAAE,MAAM;MAAU,OAAO;KAAc,CAAC;IACjE;GACF;EACF,CAAC,CACH;CACF;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
- import { Extension } from '@tiptap/core';
2
-
1
+ import { Extension } from "@tiptap/core";
2
+ //#region src/trailing-node/trailing-node.d.ts
3
3
  declare const skipTrailingNodeMeta = "skipTrailingNode";
4
4
  /**
5
5
  * Extension based on:
@@ -7,23 +7,24 @@ declare const skipTrailingNodeMeta = "skipTrailingNode";
7
7
  * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
8
8
  */
9
9
  interface TrailingNodeOptions {
10
- /**
11
- * The node type that should be inserted at the end of the document.
12
- * @note the node will always be added to the `notAfter` lists to
13
- * prevent an infinite loop.
14
- * @default undefined
15
- */
16
- node?: string;
17
- /**
18
- * The node types after which the trailing node should not be inserted.
19
- * @default ['paragraph']
20
- */
21
- notAfter?: string | string[];
10
+ /**
11
+ * The node type that should be inserted at the end of the document.
12
+ * @note the node will always be added to the `notAfter` lists to
13
+ * prevent an infinite loop.
14
+ * @default undefined
15
+ */
16
+ node?: string;
17
+ /**
18
+ * The node types after which the trailing node should not be inserted.
19
+ * @default ['paragraph']
20
+ */
21
+ notAfter?: string | string[];
22
22
  }
23
23
  /**
24
24
  * This extension allows you to add an extra node at the end of the document.
25
25
  * @see https://www.tiptap.dev/api/extensions/trailing-node
26
26
  */
27
27
  declare const TrailingNode: Extension<TrailingNodeOptions, any>;
28
-
29
- export { TrailingNode, type TrailingNodeOptions, skipTrailingNodeMeta };
28
+ //#endregion
29
+ export { TrailingNode, TrailingNodeOptions, skipTrailingNodeMeta };
30
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/trailing-node/trailing-node.ts"],"mappings":";;cAIa;;;;;;UAkBI;;;;;;;EAOf;;;;;EAKA;;;;;;cAOW,cAAY,UAAA"}
@@ -1,5 +1,5 @@
1
- import { Extension } from '@tiptap/core';
2
-
1
+ import { Extension } from "@tiptap/core";
2
+ //#region src/trailing-node/trailing-node.d.ts
3
3
  declare const skipTrailingNodeMeta = "skipTrailingNode";
4
4
  /**
5
5
  * Extension based on:
@@ -7,23 +7,24 @@ declare const skipTrailingNodeMeta = "skipTrailingNode";
7
7
  * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
8
8
  */
9
9
  interface TrailingNodeOptions {
10
- /**
11
- * The node type that should be inserted at the end of the document.
12
- * @note the node will always be added to the `notAfter` lists to
13
- * prevent an infinite loop.
14
- * @default undefined
15
- */
16
- node?: string;
17
- /**
18
- * The node types after which the trailing node should not be inserted.
19
- * @default ['paragraph']
20
- */
21
- notAfter?: string | string[];
10
+ /**
11
+ * The node type that should be inserted at the end of the document.
12
+ * @note the node will always be added to the `notAfter` lists to
13
+ * prevent an infinite loop.
14
+ * @default undefined
15
+ */
16
+ node?: string;
17
+ /**
18
+ * The node types after which the trailing node should not be inserted.
19
+ * @default ['paragraph']
20
+ */
21
+ notAfter?: string | string[];
22
22
  }
23
23
  /**
24
24
  * This extension allows you to add an extra node at the end of the document.
25
25
  * @see https://www.tiptap.dev/api/extensions/trailing-node
26
26
  */
27
27
  declare const TrailingNode: Extension<TrailingNodeOptions, any>;
28
-
29
- export { TrailingNode, type TrailingNodeOptions, skipTrailingNodeMeta };
28
+ //#endregion
29
+ export { TrailingNode, TrailingNodeOptions, skipTrailingNodeMeta };
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/trailing-node/trailing-node.ts"],"mappings":";;cAIa;;;;;;UAkBI;;;;;;;EAOf;;;;;EAKA;;;;;;cAOW,cAAY,UAAA"}
@@ -1,64 +1,60 @@
1
- // src/trailing-node/trailing-node.ts
2
1
  import { Extension } from "@tiptap/core";
3
2
  import { Plugin, PluginKey } from "@tiptap/pm/state";
4
- var skipTrailingNodeMeta = "skipTrailingNode";
5
- function nodeEqualsType({
6
- types,
7
- node
8
- }) {
9
- return node && Array.isArray(types) && types.includes(node.type) || (node == null ? void 0 : node.type) === types;
3
+ //#region src/trailing-node/trailing-node.ts
4
+ const skipTrailingNodeMeta = "skipTrailingNode";
5
+ function nodeEqualsType({ types, node }) {
6
+ return node && Array.isArray(types) && types.includes(node.type) || (node === null || node === void 0 ? void 0 : node.type) === types;
10
7
  }
11
- var TrailingNode = Extension.create({
12
- name: "trailingNode",
13
- addOptions() {
14
- return {
15
- node: void 0,
16
- notAfter: []
17
- };
18
- },
19
- addProseMirrorPlugins() {
20
- var _a;
21
- const plugin = new PluginKey(this.name);
22
- const defaultNode = this.options.node || ((_a = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : _a.name) || "paragraph";
23
- const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));
24
- return [
25
- new Plugin({
26
- key: plugin,
27
- appendTransaction: (transactions, __, state) => {
28
- const { doc, tr, schema } = state;
29
- const shouldInsertNodeAtEnd = plugin.getState(state);
30
- const endPosition = doc.content.size;
31
- const type = schema.nodes[defaultNode];
32
- if (transactions.some((transaction) => transaction.getMeta(skipTrailingNodeMeta))) {
33
- return;
34
- }
35
- if (!shouldInsertNodeAtEnd) {
36
- return;
37
- }
38
- return tr.insert(endPosition, type.create());
39
- },
40
- state: {
41
- init: (_, state) => {
42
- const lastNode = state.tr.doc.lastChild;
43
- return !nodeEqualsType({ node: lastNode, types: disabledNodes });
44
- },
45
- apply: (tr, value) => {
46
- if (!tr.docChanged) {
47
- return value;
48
- }
49
- if (tr.getMeta("__uniqueIDTransaction")) {
50
- return value;
51
- }
52
- const lastNode = tr.doc.lastChild;
53
- return !nodeEqualsType({ node: lastNode, types: disabledNodes });
54
- }
55
- }
56
- })
57
- ];
58
- }
8
+ /**
9
+ * This extension allows you to add an extra node at the end of the document.
10
+ * @see https://www.tiptap.dev/api/extensions/trailing-node
11
+ */
12
+ const TrailingNode = Extension.create({
13
+ name: "trailingNode",
14
+ addOptions() {
15
+ return {
16
+ node: void 0,
17
+ notAfter: []
18
+ };
19
+ },
20
+ addProseMirrorPlugins() {
21
+ var _this$editor$schema$t;
22
+ const plugin = new PluginKey(this.name);
23
+ const defaultNode = this.options.node || ((_this$editor$schema$t = this.editor.schema.topNodeType.contentMatch.defaultType) === null || _this$editor$schema$t === void 0 ? void 0 : _this$editor$schema$t.name) || "paragraph";
24
+ const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));
25
+ return [new Plugin({
26
+ key: plugin,
27
+ appendTransaction: (transactions, __, state) => {
28
+ const { doc, tr, schema } = state;
29
+ const shouldInsertNodeAtEnd = plugin.getState(state);
30
+ const endPosition = doc.content.size;
31
+ const type = schema.nodes[defaultNode];
32
+ if (transactions.some((transaction) => transaction.getMeta("skipTrailingNode"))) return;
33
+ if (!shouldInsertNodeAtEnd) return;
34
+ return tr.insert(endPosition, type.create());
35
+ },
36
+ state: {
37
+ init: (_, state) => {
38
+ const lastNode = state.tr.doc.lastChild;
39
+ return !nodeEqualsType({
40
+ node: lastNode,
41
+ types: disabledNodes
42
+ });
43
+ },
44
+ apply: (tr, value) => {
45
+ if (!tr.docChanged) return value;
46
+ if (tr.getMeta("__uniqueIDTransaction")) return value;
47
+ const lastNode = tr.doc.lastChild;
48
+ return !nodeEqualsType({
49
+ node: lastNode,
50
+ types: disabledNodes
51
+ });
52
+ }
53
+ }
54
+ })];
55
+ }
59
56
  });
60
- export {
61
- TrailingNode,
62
- skipTrailingNodeMeta
63
- };
57
+ //#endregion
58
+ export { TrailingNode, skipTrailingNodeMeta };
59
+
64
60
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/trailing-node/trailing-node.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport type { Node, NodeType } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nexport const skipTrailingNodeMeta = 'skipTrailingNode'\n\nfunction nodeEqualsType({\n types,\n node,\n}: {\n types: NodeType | NodeType[]\n node: Node | null | undefined\n}) {\n return (node && Array.isArray(types) && types.includes(node.type)) || node?.type === types\n}\n\n/**\n * Extension based on:\n * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js\n * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts\n */\n\nexport interface TrailingNodeOptions {\n /**\n * The node type that should be inserted at the end of the document.\n * @note the node will always be added to the `notAfter` lists to\n * prevent an infinite loop.\n * @default undefined\n */\n node?: string\n /**\n * The node types after which the trailing node should not be inserted.\n * @default ['paragraph']\n */\n notAfter?: string | string[]\n}\n\n/**\n * This extension allows you to add an extra node at the end of the document.\n * @see https://www.tiptap.dev/api/extensions/trailing-node\n */\nexport const TrailingNode = Extension.create<TrailingNodeOptions>({\n name: 'trailingNode',\n\n addOptions() {\n return {\n node: undefined,\n notAfter: [],\n }\n },\n\n addProseMirrorPlugins() {\n const plugin = new PluginKey(this.name)\n const defaultNode =\n this.options.node ||\n this.editor.schema.topNodeType.contentMatch.defaultType?.name ||\n 'paragraph'\n\n const disabledNodes = Object.entries(this.editor.schema.nodes)\n .map(([, value]) => value)\n .filter(node => (this.options.notAfter || []).concat(defaultNode).includes(node.name))\n\n return [\n new Plugin({\n key: plugin,\n appendTransaction: (transactions, __, state) => {\n const { doc, tr, schema } = state\n const shouldInsertNodeAtEnd = plugin.getState(state)\n const endPosition = doc.content.size\n const type = schema.nodes[defaultNode]\n\n if (transactions.some(transaction => transaction.getMeta(skipTrailingNodeMeta))) {\n return\n }\n\n if (!shouldInsertNodeAtEnd) {\n return\n }\n\n return tr.insert(endPosition, type.create())\n },\n state: {\n init: (_, state) => {\n const lastNode = state.tr.doc.lastChild\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes })\n },\n apply: (tr, value) => {\n if (!tr.docChanged) {\n return value\n }\n\n // Ignore transactions from UniqueID extension to prevent infinite loops\n // when UniqueID adds IDs to newly inserted trailing nodes\n if (tr.getMeta('__uniqueIDTransaction')) {\n return value\n }\n\n const lastNode = tr.doc.lastChild\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes })\n },\n },\n }),\n ]\n },\n})\n"],"mappings":";AAAA,SAAS,iBAAiB;AAE1B,SAAS,QAAQ,iBAAiB;AAE3B,IAAM,uBAAuB;AAEpC,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AACF,GAGG;AACD,SAAQ,QAAQ,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,KAAK,IAAI,MAAM,6BAAM,UAAS;AACvF;AA2BO,IAAM,eAAe,UAAU,OAA4B;AAAA,EAChE,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU,CAAC;AAAA,IACb;AAAA,EACF;AAAA,EAEA,wBAAwB;AAnD1B;AAoDI,UAAM,SAAS,IAAI,UAAU,KAAK,IAAI;AACtC,UAAM,cACJ,KAAK,QAAQ,UACb,UAAK,OAAO,OAAO,YAAY,aAAa,gBAA5C,mBAAyD,SACzD;AAEF,UAAM,gBAAgB,OAAO,QAAQ,KAAK,OAAO,OAAO,KAAK,EAC1D,IAAI,CAAC,CAAC,EAAE,KAAK,MAAM,KAAK,EACxB,OAAO,WAAS,KAAK,QAAQ,YAAY,CAAC,GAAG,OAAO,WAAW,EAAE,SAAS,KAAK,IAAI,CAAC;AAEvF,WAAO;AAAA,MACL,IAAI,OAAO;AAAA,QACT,KAAK;AAAA,QACL,mBAAmB,CAAC,cAAc,IAAI,UAAU;AAC9C,gBAAM,EAAE,KAAK,IAAI,OAAO,IAAI;AAC5B,gBAAM,wBAAwB,OAAO,SAAS,KAAK;AACnD,gBAAM,cAAc,IAAI,QAAQ;AAChC,gBAAM,OAAO,OAAO,MAAM,WAAW;AAErC,cAAI,aAAa,KAAK,iBAAe,YAAY,QAAQ,oBAAoB,CAAC,GAAG;AAC/E;AAAA,UACF;AAEA,cAAI,CAAC,uBAAuB;AAC1B;AAAA,UACF;AAEA,iBAAO,GAAG,OAAO,aAAa,KAAK,OAAO,CAAC;AAAA,QAC7C;AAAA,QACA,OAAO;AAAA,UACL,MAAM,CAAC,GAAG,UAAU;AAClB,kBAAM,WAAW,MAAM,GAAG,IAAI;AAE9B,mBAAO,CAAC,eAAe,EAAE,MAAM,UAAU,OAAO,cAAc,CAAC;AAAA,UACjE;AAAA,UACA,OAAO,CAAC,IAAI,UAAU;AACpB,gBAAI,CAAC,GAAG,YAAY;AAClB,qBAAO;AAAA,YACT;AAIA,gBAAI,GAAG,QAAQ,uBAAuB,GAAG;AACvC,qBAAO;AAAA,YACT;AAEA,kBAAM,WAAW,GAAG,IAAI;AAExB,mBAAO,CAAC,eAAe,EAAE,MAAM,UAAU,OAAO,cAAc,CAAC;AAAA,UACjE;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/trailing-node/trailing-node.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport type { Node, NodeType } from '@tiptap/pm/model'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nexport const skipTrailingNodeMeta = 'skipTrailingNode'\n\nfunction nodeEqualsType({\n types,\n node,\n}: {\n types: NodeType | NodeType[]\n node: Node | null | undefined\n}) {\n return (node && Array.isArray(types) && types.includes(node.type)) || node?.type === types\n}\n\n/**\n * Extension based on:\n * - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js\n * - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts\n */\n\nexport interface TrailingNodeOptions {\n /**\n * The node type that should be inserted at the end of the document.\n * @note the node will always be added to the `notAfter` lists to\n * prevent an infinite loop.\n * @default undefined\n */\n node?: string\n /**\n * The node types after which the trailing node should not be inserted.\n * @default ['paragraph']\n */\n notAfter?: string | string[]\n}\n\n/**\n * This extension allows you to add an extra node at the end of the document.\n * @see https://www.tiptap.dev/api/extensions/trailing-node\n */\nexport const TrailingNode = Extension.create<TrailingNodeOptions>({\n name: 'trailingNode',\n\n addOptions() {\n return {\n node: undefined,\n notAfter: [],\n }\n },\n\n addProseMirrorPlugins() {\n const plugin = new PluginKey(this.name)\n const defaultNode =\n this.options.node ||\n this.editor.schema.topNodeType.contentMatch.defaultType?.name ||\n 'paragraph'\n\n const disabledNodes = Object.entries(this.editor.schema.nodes)\n .map(([, value]) => value)\n .filter(node => (this.options.notAfter || []).concat(defaultNode).includes(node.name))\n\n return [\n new Plugin({\n key: plugin,\n appendTransaction: (transactions, __, state) => {\n const { doc, tr, schema } = state\n const shouldInsertNodeAtEnd = plugin.getState(state)\n const endPosition = doc.content.size\n const type = schema.nodes[defaultNode]\n\n if (transactions.some(transaction => transaction.getMeta(skipTrailingNodeMeta))) {\n return\n }\n\n if (!shouldInsertNodeAtEnd) {\n return\n }\n\n return tr.insert(endPosition, type.create())\n },\n state: {\n init: (_, state) => {\n const lastNode = state.tr.doc.lastChild\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes })\n },\n apply: (tr, value) => {\n if (!tr.docChanged) {\n return value\n }\n\n // Ignore transactions from UniqueID extension to prevent infinite loops\n // when UniqueID adds IDs to newly inserted trailing nodes\n if (tr.getMeta('__uniqueIDTransaction')) {\n return value\n }\n\n const lastNode = tr.doc.lastChild\n\n return !nodeEqualsType({ node: lastNode, types: disabledNodes })\n },\n },\n }),\n ]\n },\n})\n"],"mappings":";;;AAIA,MAAa,uBAAuB;AAEpC,SAAS,eAAe,EACtB,OACA,QAIC;CACD,OAAQ,QAAQ,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,KAAK,IAAI,MAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAM,KAAM,UAAS;AACvF;;;;;AA2BA,MAAa,eAAe,UAAU,OAA4B;CAChE,MAAM;CAEN,aAAa;EACX,OAAO;GACL,MAAM,KAAA;GACN,UAAU,CAAC;EACb;CACF;CAEA,wBAAwB;;EACtB,MAAM,SAAS,IAAI,UAAU,KAAK,IAAI;EACtC,MAAM,cACJ,KAAK,QAAQ,UAAA,wBACb,KAAK,OAAO,OAAO,YAAY,aAAa,iBAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAa,SACzD;EAEF,MAAM,gBAAgB,OAAO,QAAQ,KAAK,OAAO,OAAO,KAAK,CAAC,CAC3D,KAAK,GAAG,WAAW,KAAK,CAAC,CACzB,QAAO,UAAS,KAAK,QAAQ,YAAY,CAAC,EAAA,CAAG,OAAO,WAAW,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC;EAEvF,OAAO,CACL,IAAI,OAAO;GACT,KAAK;GACL,oBAAoB,cAAc,IAAI,UAAU;IAC9C,MAAM,EAAE,KAAK,IAAI,WAAW;IAC5B,MAAM,wBAAwB,OAAO,SAAS,KAAK;IACnD,MAAM,cAAc,IAAI,QAAQ;IAChC,MAAM,OAAO,OAAO,MAAM;IAE1B,IAAI,aAAa,MAAK,gBAAe,YAAY,QAAA,kBAA4B,CAAC,GAC5E;IAGF,IAAI,CAAC,uBACH;IAGF,OAAO,GAAG,OAAO,aAAa,KAAK,OAAO,CAAC;GAC7C;GACA,OAAO;IACL,OAAO,GAAG,UAAU;KAClB,MAAM,WAAW,MAAM,GAAG,IAAI;KAE9B,OAAO,CAAC,eAAe;MAAE,MAAM;MAAU,OAAO;KAAc,CAAC;IACjE;IACA,QAAQ,IAAI,UAAU;KACpB,IAAI,CAAC,GAAG,YACN,OAAO;KAKT,IAAI,GAAG,QAAQ,uBAAuB,GACpC,OAAO;KAGT,MAAM,WAAW,GAAG,IAAI;KAExB,OAAO,CAAC,eAAe;MAAE,MAAM;MAAU,OAAO;KAAc,CAAC;IACjE;GACF;EACF,CAAC,CACH;CACF;AACF,CAAC"}
@@ -1,66 +1,48 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/undo-redo/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- UndoRedo: () => UndoRedo
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _tiptap_core = require("@tiptap/core");
3
+ let _tiptap_pm_history = require("@tiptap/pm/history");
4
+ //#region src/undo-redo/undo-redo.ts
5
+ /**
6
+ * This extension allows you to undo and redo recent changes.
7
+ * @see https://www.tiptap.dev/api/extensions/undo-redo
8
+ *
9
+ * **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove
10
+ * the `undo-redo` extension, as it is not compatible with the `collaboration` extension.
11
+ *
12
+ * `@tiptap/extension-collaboration` uses its own history implementation.
13
+ */
14
+ const UndoRedo = _tiptap_core.Extension.create({
15
+ name: "undoRedo",
16
+ addOptions() {
17
+ return {
18
+ depth: 100,
19
+ newGroupDelay: 500
20
+ };
21
+ },
22
+ addCommands() {
23
+ return {
24
+ undo: () => ({ state, dispatch }) => {
25
+ return (0, _tiptap_pm_history.undo)(state, dispatch);
26
+ },
27
+ redo: () => ({ state, dispatch }) => {
28
+ return (0, _tiptap_pm_history.redo)(state, dispatch);
29
+ }
30
+ };
31
+ },
32
+ addProseMirrorPlugins() {
33
+ return [(0, _tiptap_pm_history.history)(this.options)];
34
+ },
35
+ addKeyboardShortcuts() {
36
+ return {
37
+ "Mod-z": () => this.editor.commands.undo(),
38
+ "Shift-Mod-z": () => this.editor.commands.redo(),
39
+ "Mod-y": () => this.editor.commands.redo(),
40
+ "Mod-я": () => this.editor.commands.undo(),
41
+ "Shift-Mod-я": () => this.editor.commands.redo()
42
+ };
43
+ }
24
44
  });
25
- module.exports = __toCommonJS(index_exports);
45
+ //#endregion
46
+ exports.UndoRedo = UndoRedo;
26
47
 
27
- // src/undo-redo/undo-redo.ts
28
- var import_core = require("@tiptap/core");
29
- var import_history = require("@tiptap/pm/history");
30
- var UndoRedo = import_core.Extension.create({
31
- name: "undoRedo",
32
- addOptions() {
33
- return {
34
- depth: 100,
35
- newGroupDelay: 500
36
- };
37
- },
38
- addCommands() {
39
- return {
40
- undo: () => ({ state, dispatch }) => {
41
- return (0, import_history.undo)(state, dispatch);
42
- },
43
- redo: () => ({ state, dispatch }) => {
44
- return (0, import_history.redo)(state, dispatch);
45
- }
46
- };
47
- },
48
- addProseMirrorPlugins() {
49
- return [(0, import_history.history)(this.options)];
50
- },
51
- addKeyboardShortcuts() {
52
- return {
53
- "Mod-z": () => this.editor.commands.undo(),
54
- "Shift-Mod-z": () => this.editor.commands.redo(),
55
- "Mod-y": () => this.editor.commands.redo(),
56
- // Russian keyboard layouts
57
- "Mod-\u044F": () => this.editor.commands.undo(),
58
- "Shift-Mod-\u044F": () => this.editor.commands.redo()
59
- };
60
- }
61
- });
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
64
- UndoRedo
65
- });
66
48
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/undo-redo/index.ts","../../src/undo-redo/undo-redo.ts"],"sourcesContent":["export * from './undo-redo.js'\n","import { Extension } from '@tiptap/core'\nimport { history, redo, undo } from '@tiptap/pm/history'\n\nexport interface UndoRedoOptions {\n /**\n * The amount of history events that are collected before the oldest events are discarded.\n * @default 100\n * @example 50\n */\n depth: number\n\n /**\n * The delay (in milliseconds) between changes after which a new group should be started.\n * @default 500\n * @example 1000\n */\n newGroupDelay: number\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n undoRedo: {\n /**\n * Undo recent changes\n * @example editor.commands.undo()\n */\n undo: () => ReturnType\n /**\n * Reapply reverted changes\n * @example editor.commands.redo()\n */\n redo: () => ReturnType\n }\n }\n}\n\n/**\n * This extension allows you to undo and redo recent changes.\n * @see https://www.tiptap.dev/api/extensions/undo-redo\n *\n * **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove\n * the `undo-redo` extension, as it is not compatible with the `collaboration` extension.\n *\n * `@tiptap/extension-collaboration` uses its own history implementation.\n */\nexport const UndoRedo = Extension.create<UndoRedoOptions>({\n name: 'undoRedo',\n\n addOptions() {\n return {\n depth: 100,\n newGroupDelay: 500,\n }\n },\n\n addCommands() {\n return {\n undo:\n () =>\n ({ state, dispatch }) => {\n return undo(state, dispatch)\n },\n redo:\n () =>\n ({ state, dispatch }) => {\n return redo(state, dispatch)\n },\n }\n },\n\n addProseMirrorPlugins() {\n return [history(this.options)]\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-z': () => this.editor.commands.undo(),\n 'Shift-Mod-z': () => this.editor.commands.redo(),\n 'Mod-y': () => this.editor.commands.redo(),\n\n // Russian keyboard layouts\n 'Mod-я': () => this.editor.commands.undo(),\n 'Shift-Mod-я': () => this.editor.commands.redo(),\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAA0B;AAC1B,qBAAoC;AA4C7B,IAAM,WAAW,sBAAU,OAAwB;AAAA,EACxD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,OAAO;AAAA,MACP,eAAe;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,MACE,MACA,CAAC,EAAE,OAAO,SAAS,MAAM;AACvB,mBAAO,qBAAK,OAAO,QAAQ;AAAA,MAC7B;AAAA,MACF,MACE,MACA,CAAC,EAAE,OAAO,SAAS,MAAM;AACvB,mBAAO,qBAAK,OAAO,QAAQ;AAAA,MAC7B;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,wBAAwB;AACtB,WAAO,KAAC,wBAAQ,KAAK,OAAO,CAAC;AAAA,EAC/B;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,SAAS,MAAM,KAAK,OAAO,SAAS,KAAK;AAAA,MACzC,eAAe,MAAM,KAAK,OAAO,SAAS,KAAK;AAAA,MAC/C,SAAS,MAAM,KAAK,OAAO,SAAS,KAAK;AAAA;AAAA,MAGzC,cAAS,MAAM,KAAK,OAAO,SAAS,KAAK;AAAA,MACzC,oBAAe,MAAM,KAAK,OAAO,SAAS,KAAK;AAAA,IACjD;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"file":"index.cjs","names":["Extension"],"sources":["../../src/undo-redo/undo-redo.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport { history, redo, undo } from '@tiptap/pm/history'\n\nexport interface UndoRedoOptions {\n /**\n * The amount of history events that are collected before the oldest events are discarded.\n * @default 100\n * @example 50\n */\n depth: number\n\n /**\n * The delay (in milliseconds) between changes after which a new group should be started.\n * @default 500\n * @example 1000\n */\n newGroupDelay: number\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n undoRedo: {\n /**\n * Undo recent changes\n * @example editor.commands.undo()\n */\n undo: () => ReturnType\n /**\n * Reapply reverted changes\n * @example editor.commands.redo()\n */\n redo: () => ReturnType\n }\n }\n}\n\n/**\n * This extension allows you to undo and redo recent changes.\n * @see https://www.tiptap.dev/api/extensions/undo-redo\n *\n * **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove\n * the `undo-redo` extension, as it is not compatible with the `collaboration` extension.\n *\n * `@tiptap/extension-collaboration` uses its own history implementation.\n */\nexport const UndoRedo = Extension.create<UndoRedoOptions>({\n name: 'undoRedo',\n\n addOptions() {\n return {\n depth: 100,\n newGroupDelay: 500,\n }\n },\n\n addCommands() {\n return {\n undo:\n () =>\n ({ state, dispatch }) => {\n return undo(state, dispatch)\n },\n redo:\n () =>\n ({ state, dispatch }) => {\n return redo(state, dispatch)\n },\n }\n },\n\n addProseMirrorPlugins() {\n return [history(this.options)]\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-z': () => this.editor.commands.undo(),\n 'Shift-Mod-z': () => this.editor.commands.redo(),\n 'Mod-y': () => this.editor.commands.redo(),\n\n // Russian keyboard layouts\n 'Mod-я': () => this.editor.commands.undo(),\n 'Shift-Mod-я': () => this.editor.commands.redo(),\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;AA6CA,MAAa,WAAWA,aAAAA,UAAU,OAAwB;CACxD,MAAM;CAEN,aAAa;EACX,OAAO;GACL,OAAO;GACP,eAAe;EACjB;CACF;CAEA,cAAc;EACZ,OAAO;GACL,aAEG,EAAE,OAAO,eAAe;IACvB,QAAA,GAAA,mBAAA,KAAA,CAAY,OAAO,QAAQ;GAC7B;GACF,aAEG,EAAE,OAAO,eAAe;IACvB,QAAA,GAAA,mBAAA,KAAA,CAAY,OAAO,QAAQ;GAC7B;EACJ;CACF;CAEA,wBAAwB;EACtB,OAAO,EAAA,GAAA,mBAAA,QAAA,CAAS,KAAK,OAAO,CAAC;CAC/B;CAEA,uBAAuB;EACrB,OAAO;GACL,eAAe,KAAK,OAAO,SAAS,KAAK;GACzC,qBAAqB,KAAK,OAAO,SAAS,KAAK;GAC/C,eAAe,KAAK,OAAO,SAAS,KAAK;GAGzC,eAAe,KAAK,OAAO,SAAS,KAAK;GACzC,qBAAqB,KAAK,OAAO,SAAS,KAAK;EACjD;CACF;AACF,CAAC"}