@prosekit/extensions 0.14.2 → 0.16.0-beta.0

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 (151) hide show
  1. package/dist/commit/style.css +1 -3
  2. package/dist/{drop-indicator-DJq8pF92.js → drop-indicator.js} +2 -4
  3. package/dist/drop-indicator.js.map +1 -0
  4. package/dist/{file-upload-I9m1EJAM.js → file.js} +2 -6
  5. package/dist/file.js.map +1 -0
  6. package/dist/gap-cursor/style.css +5 -8
  7. package/dist/{file-upload-dr3IXUty.d.ts → index.d.ts} +1 -1
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/list/style.css +79 -110
  10. package/dist/loro/style.css +18 -21
  11. package/dist/{mark-rule-Bqdm49Eq.js → mark-rule.js} +2 -5
  12. package/dist/mark-rule.js.map +1 -0
  13. package/dist/page/style.css +43 -0
  14. package/dist/{mark-paste-rule--F1QPUcU.js → paste-rule.js} +2 -6
  15. package/dist/paste-rule.js.map +1 -0
  16. package/dist/placeholder/style.css +4 -7
  17. package/dist/prosekit-extensions-autocomplete.js +1 -5
  18. package/dist/prosekit-extensions-autocomplete.js.map +1 -1
  19. package/dist/prosekit-extensions-background-color.js +1 -4
  20. package/dist/prosekit-extensions-background-color.js.map +1 -1
  21. package/dist/prosekit-extensions-blockquote.js +1 -6
  22. package/dist/prosekit-extensions-blockquote.js.map +1 -1
  23. package/dist/prosekit-extensions-bold.js +1 -6
  24. package/dist/prosekit-extensions-bold.js.map +1 -1
  25. package/dist/prosekit-extensions-code-block.d.ts +4 -2
  26. package/dist/prosekit-extensions-code-block.d.ts.map +1 -1
  27. package/dist/prosekit-extensions-code-block.js +1 -10
  28. package/dist/prosekit-extensions-code-block.js.map +1 -1
  29. package/dist/prosekit-extensions-code.js +1 -6
  30. package/dist/prosekit-extensions-code.js.map +1 -1
  31. package/dist/prosekit-extensions-commit.js +1 -2
  32. package/dist/prosekit-extensions-commit.js.map +1 -1
  33. package/dist/prosekit-extensions-doc.js +1 -2
  34. package/dist/prosekit-extensions-doc.js.map +1 -1
  35. package/dist/prosekit-extensions-drop-cursor.js +1 -2
  36. package/dist/prosekit-extensions-drop-cursor.js.map +1 -1
  37. package/dist/prosekit-extensions-drop-indicator.js +2 -3
  38. package/dist/prosekit-extensions-enter-rule.js +1 -2
  39. package/dist/prosekit-extensions-enter-rule.js.map +1 -1
  40. package/dist/prosekit-extensions-file.d.ts +2 -2
  41. package/dist/prosekit-extensions-file.js +2 -3
  42. package/dist/prosekit-extensions-gap-cursor.js +1 -2
  43. package/dist/prosekit-extensions-gap-cursor.js.map +1 -1
  44. package/dist/prosekit-extensions-hard-break.js +1 -5
  45. package/dist/prosekit-extensions-hard-break.js.map +1 -1
  46. package/dist/prosekit-extensions-heading.js +1 -6
  47. package/dist/prosekit-extensions-heading.js.map +1 -1
  48. package/dist/prosekit-extensions-horizontal-rule.d.ts.map +1 -1
  49. package/dist/prosekit-extensions-horizontal-rule.js +3 -6
  50. package/dist/prosekit-extensions-horizontal-rule.js.map +1 -1
  51. package/dist/prosekit-extensions-image.d.ts +1 -2
  52. package/dist/prosekit-extensions-image.d.ts.map +1 -1
  53. package/dist/prosekit-extensions-image.js +2 -8
  54. package/dist/prosekit-extensions-image.js.map +1 -1
  55. package/dist/prosekit-extensions-input-rule.js +1 -2
  56. package/dist/prosekit-extensions-input-rule.js.map +1 -1
  57. package/dist/prosekit-extensions-italic.js +1 -6
  58. package/dist/prosekit-extensions-italic.js.map +1 -1
  59. package/dist/prosekit-extensions-link.js +3 -6
  60. package/dist/prosekit-extensions-link.js.map +1 -1
  61. package/dist/prosekit-extensions-list.js +2 -10
  62. package/dist/prosekit-extensions-list.js.map +1 -1
  63. package/dist/prosekit-extensions-loro.d.ts.map +1 -1
  64. package/dist/prosekit-extensions-loro.js +3 -9
  65. package/dist/prosekit-extensions-loro.js.map +1 -1
  66. package/dist/prosekit-extensions-mark-rule.js +2 -3
  67. package/dist/prosekit-extensions-math.js +1 -5
  68. package/dist/prosekit-extensions-math.js.map +1 -1
  69. package/dist/prosekit-extensions-mention.js +1 -2
  70. package/dist/prosekit-extensions-mention.js.map +1 -1
  71. package/dist/prosekit-extensions-mod-click-prevention.js +1 -2
  72. package/dist/prosekit-extensions-mod-click-prevention.js.map +1 -1
  73. package/dist/prosekit-extensions-page.d.ts +114 -0
  74. package/dist/prosekit-extensions-page.d.ts.map +1 -0
  75. package/dist/prosekit-extensions-page.js +324 -0
  76. package/dist/prosekit-extensions-page.js.map +1 -0
  77. package/dist/prosekit-extensions-paragraph.d.ts.map +1 -1
  78. package/dist/prosekit-extensions-paragraph.js +3 -7
  79. package/dist/prosekit-extensions-paragraph.js.map +1 -1
  80. package/dist/prosekit-extensions-paste-rule.js +2 -3
  81. package/dist/prosekit-extensions-placeholder.js +2 -3
  82. package/dist/prosekit-extensions-placeholder.js.map +1 -1
  83. package/dist/prosekit-extensions-readonly.js +1 -2
  84. package/dist/prosekit-extensions-readonly.js.map +1 -1
  85. package/dist/prosekit-extensions-search.js +1 -2
  86. package/dist/prosekit-extensions-search.js.map +1 -1
  87. package/dist/prosekit-extensions-strike.js +1 -2
  88. package/dist/prosekit-extensions-strike.js.map +1 -1
  89. package/dist/prosekit-extensions-table.js +2 -3
  90. package/dist/prosekit-extensions-text-align.js +1 -2
  91. package/dist/prosekit-extensions-text-align.js.map +1 -1
  92. package/dist/prosekit-extensions-text-color.js +1 -4
  93. package/dist/prosekit-extensions-text-color.js.map +1 -1
  94. package/dist/prosekit-extensions-text.js +1 -2
  95. package/dist/prosekit-extensions-text.js.map +1 -1
  96. package/dist/prosekit-extensions-underline.js +1 -2
  97. package/dist/prosekit-extensions-underline.js.map +1 -1
  98. package/dist/prosekit-extensions-virtual-selection.js +1 -2
  99. package/dist/prosekit-extensions-virtual-selection.js.map +1 -1
  100. package/dist/prosekit-extensions-yjs.d.ts.map +1 -1
  101. package/dist/prosekit-extensions-yjs.js +3 -9
  102. package/dist/prosekit-extensions-yjs.js.map +1 -1
  103. package/dist/prosekit-extensions.js +1 -1
  104. package/dist/search/style.css +4 -8
  105. package/dist/shiki-highlighter-chunk.js +1 -2
  106. package/dist/shiki-highlighter-chunk.js.map +1 -1
  107. package/dist/table/style.css +16 -16
  108. package/dist/{table-B81i9oH9.js → table.js} +3 -15
  109. package/dist/table.js.map +1 -0
  110. package/dist/virtual-selection/style.css +1 -4
  111. package/dist/yjs/style.css +14 -20
  112. package/package.json +27 -14
  113. package/src/horizontal-rule/horizontal-rule-commands.ts +2 -1
  114. package/src/loro/loro.ts +3 -2
  115. package/src/page/index.ts +5 -0
  116. package/src/page/page-break-commands.spec.ts +61 -0
  117. package/src/page/page-break-commands.ts +41 -0
  118. package/src/page/page-break-keymap.ts +17 -0
  119. package/src/page/page-break-spec.ts +33 -0
  120. package/src/page/page-break.ts +23 -0
  121. package/src/page/page-element.ts +246 -0
  122. package/src/page/page-rendering.ts +164 -0
  123. package/src/page/style.css +43 -0
  124. package/src/paragraph/paragraph.ts +3 -2
  125. package/src/yjs/yjs.ts +3 -2
  126. package/dist/commit/style.css.map +0 -1
  127. package/dist/commit/style.js +0 -1
  128. package/dist/drop-indicator-DJq8pF92.js.map +0 -1
  129. package/dist/file-upload-I9m1EJAM.js.map +0 -1
  130. package/dist/file-upload-dr3IXUty.d.ts.map +0 -1
  131. package/dist/gap-cursor/style.css.map +0 -1
  132. package/dist/gap-cursor/style.js +0 -1
  133. package/dist/list/style.css.map +0 -1
  134. package/dist/list/style.js +0 -1
  135. package/dist/loro/style.css.map +0 -1
  136. package/dist/loro/style.js +0 -1
  137. package/dist/mark-paste-rule--F1QPUcU.js.map +0 -1
  138. package/dist/mark-rule-Bqdm49Eq.js.map +0 -1
  139. package/dist/placeholder/style.css.map +0 -1
  140. package/dist/placeholder/style.js +0 -1
  141. package/dist/search/style.css.map +0 -1
  142. package/dist/search/style.js +0 -1
  143. package/dist/shiki-highlighter-chunk.d.ts +0 -19
  144. package/dist/shiki-highlighter-chunk.d.ts.map +0 -1
  145. package/dist/table/style.css.map +0 -1
  146. package/dist/table/style.js +0 -1
  147. package/dist/table-B81i9oH9.js.map +0 -1
  148. package/dist/virtual-selection/style.css.map +0 -1
  149. package/dist/virtual-selection/style.js +0 -1
  150. package/dist/yjs/style.css.map +0 -1
  151. package/dist/yjs/style.js +0 -1
@@ -2,9 +2,7 @@
2
2
  background-color: #e5534b80;
3
3
  text-decoration: line-through;
4
4
  }
5
+
5
6
  .prosekit-commit-addition {
6
7
  background-color: #53e54b80;
7
8
  }
8
-
9
-
10
- /*# sourceMappingURL=style.css.map*/
@@ -1,7 +1,6 @@
1
1
  import { defineFacet, defineFacetPayload, pluginFacet } from "@prosekit/core";
2
2
  import { isNotNullish } from "@ocavue/utils";
3
3
  import { createDropIndicatorPlugin } from "prosemirror-drop-indicator";
4
-
5
4
  //#region src/drop-indicator/drop-indicator-facet.ts
6
5
  /**
7
6
  * @internal
@@ -34,7 +33,6 @@ const dropIndicatorFacet = defineFacet({
34
33
  });
35
34
  }
36
35
  });
37
-
38
36
  //#endregion
39
37
  //#region src/drop-indicator/drop-indicator.ts
40
38
  /**
@@ -53,7 +51,7 @@ const dropIndicatorFacet = defineFacet({
53
51
  function defineDropIndicator(options) {
54
52
  return defineDropIndicatorPayload(options ?? {});
55
53
  }
56
-
57
54
  //#endregion
58
55
  export { defineDropIndicator as t };
59
- //# sourceMappingURL=drop-indicator-DJq8pF92.js.map
56
+
57
+ //# sourceMappingURL=drop-indicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drop-indicator.js","names":[],"sources":["../src/drop-indicator/drop-indicator-facet.ts","../src/drop-indicator/drop-indicator.ts"],"sourcesContent":["import { isNotNullish } from '@ocavue/utils'\nimport { defineFacet, defineFacetPayload, pluginFacet, type PlainExtension, type PluginPayload } from '@prosekit/core'\nimport type { DragEventHandler, DropIndicatorPluginOptions, ShowHandler } from 'prosemirror-drop-indicator'\nimport { createDropIndicatorPlugin } from 'prosemirror-drop-indicator'\n\n/**\n * @internal\n */\nexport function defineDropIndicatorPayload(\n payload: DropIndicatorPluginOptions,\n): PlainExtension {\n return defineFacetPayload(dropIndicatorFacet, [payload]) as PlainExtension\n}\n\nconst dropIndicatorFacet = defineFacet<DropIndicatorPluginOptions, PluginPayload>({\n parent: pluginFacet,\n singleton: true,\n reducer: (payloads: DropIndicatorPluginOptions[]): PluginPayload => {\n const showHandlers = payloads.map(p => p.onShow).filter(isNotNullish)\n const hideHandlers = payloads.map(p => p.onHide).filter(isNotNullish)\n const dragHandlers = payloads.map(p => p.onDrag).filter(isNotNullish)\n\n const showHandler: ShowHandler = (options) => {\n for (const fn of showHandlers) {\n fn(options)\n }\n }\n\n const hideHandler: VoidFunction = () => {\n for (const fn of hideHandlers) {\n fn()\n }\n }\n\n const dragHandler: DragEventHandler = (options): boolean => {\n for (const fn of dragHandlers) {\n if (fn(options) === false) return false\n }\n return true\n }\n\n if (showHandlers.length === 0) {\n // No `onShow` event handler, so we don't need to create a plugin.\n return []\n }\n\n return createDropIndicatorPlugin({\n onDrag: dragHandler,\n onShow: showHandler,\n onHide: hideHandler,\n })\n },\n})\n","import type { PlainExtension } from '@prosekit/core'\nimport type { DropIndicatorPluginOptions } from 'prosemirror-drop-indicator'\n\nimport { defineDropIndicatorPayload } from './drop-indicator-facet.ts'\n\n/**\n * @internal\n */\nexport type DropIndicatorExtension = PlainExtension\n\n/**\n * Defines an extension that controls the behavior of the drop indicator.\n *\n * This extension itself doesn't draw the drop indicator, but it provides the\n * necessary callbacks to do so. You probably don't want to use this extension\n * directly, but rather use the `<DropIndicator>` component.\n *\n * You can add this extension multiple times. If any extension has `onDrag`\n * callback defined, and it returns `false`, then the drop point will be\n * discarded.\n *\n * @public\n */\nexport function defineDropIndicator(\n options?: DropIndicatorOptions,\n): DropIndicatorExtension {\n return defineDropIndicatorPayload(options ?? {})\n}\n\n/**\n * Options for {@link defineDropIndicator}.\n *\n * @public\n */\nexport interface DropIndicatorOptions extends DropIndicatorPluginOptions {}\n"],"mappings":";;;;;;;AAQA,SAAgB,2BACd,SACgB;AAChB,QAAO,mBAAmB,oBAAoB,CAAC,QAAQ,CAAC;;AAG1D,MAAM,qBAAqB,YAAuD;CAChF,QAAQ;CACR,WAAW;CACX,UAAU,aAA0D;EAClE,MAAM,eAAe,SAAS,KAAI,MAAK,EAAE,OAAO,CAAC,OAAO,aAAa;EACrE,MAAM,eAAe,SAAS,KAAI,MAAK,EAAE,OAAO,CAAC,OAAO,aAAa;EACrE,MAAM,eAAe,SAAS,KAAI,MAAK,EAAE,OAAO,CAAC,OAAO,aAAa;EAErE,MAAM,eAA4B,YAAY;AAC5C,QAAK,MAAM,MAAM,aACf,IAAG,QAAQ;;EAIf,MAAM,oBAAkC;AACtC,QAAK,MAAM,MAAM,aACf,KAAI;;EAIR,MAAM,eAAiC,YAAqB;AAC1D,QAAK,MAAM,MAAM,aACf,KAAI,GAAG,QAAQ,KAAK,MAAO,QAAO;AAEpC,UAAO;;AAGT,MAAI,aAAa,WAAW,EAE1B,QAAO,EAAE;AAGX,SAAO,0BAA0B;GAC/B,QAAQ;GACR,QAAQ;GACR,QAAQ;GACT,CAAC;;CAEL,CAAC;;;;;;;;;;;;;;;;AC7BF,SAAgB,oBACd,SACwB;AACxB,QAAO,2BAA2B,WAAW,EAAE,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { ProseKitError, defineFacet, defineFacetPayload, editorEventFacet } from "@prosekit/core";
2
-
3
2
  //#region src/file/helpers.ts
4
3
  function handleFile(view, event, file, handlers) {
5
4
  for (let i = handlers.length - 1; i >= 0; i--) {
@@ -18,7 +17,6 @@ function handleEvent(view, event, handlers, getFiles) {
18
17
  for (const file of files) if (handleFile(view, event, file, handlers)) handled = true;
19
18
  return handled;
20
19
  }
21
-
22
20
  //#endregion
23
21
  //#region src/file/file-drop-handler.ts
24
22
  function defineFileDropHandler(handler) {
@@ -46,7 +44,6 @@ const facet$1 = defineFacet({
46
44
  return ["drop", dropHandler];
47
45
  }
48
46
  });
49
-
50
47
  //#endregion
51
48
  //#region src/file/file-paste-handler.ts
52
49
  function defineFilePasteHandler(handler) {
@@ -65,7 +62,6 @@ const facet = defineFacet({
65
62
  return ["paste", pasteHandler];
66
63
  }
67
64
  });
68
-
69
65
  //#endregion
70
66
  //#region src/file/file-upload.ts
71
67
  /**
@@ -126,7 +122,7 @@ var UploadTask = class {
126
122
  }
127
123
  };
128
124
  const store = /* @__PURE__ */ new Map();
129
-
130
125
  //#endregion
131
126
  export { defineFilePasteHandler as n, defineFileDropHandler as r, UploadTask as t };
132
- //# sourceMappingURL=file-upload-I9m1EJAM.js.map
127
+
128
+ //# sourceMappingURL=file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.js","names":["facet","getFiles"],"sources":["../src/file/helpers.ts","../src/file/file-drop-handler.ts","../src/file/file-paste-handler.ts","../src/file/file-upload.ts"],"sourcesContent":["import type { EditorView } from '@prosekit/pm/view'\n\ntype FileHandler<E extends Event> = (options: {\n view: EditorView\n event: E\n file: File\n}) => boolean | void\n\nfunction handleFile<E extends Event>(\n view: EditorView,\n event: E,\n file: File,\n handlers: FileHandler<E>[],\n) {\n // The last item in `handlers` should has the highest priority.\n for (let i = handlers.length - 1; i >= 0; i--) {\n const handler = handlers[i]\n if (handler({ view, event, file })) {\n return true\n }\n }\n return false\n}\n\nexport function handleEvent<E extends Event>(\n view: EditorView,\n event: E,\n handlers: FileHandler<E>[],\n getFiles: (event: E) => File[],\n): boolean {\n const files = getFiles(event)\n let handled = false\n for (const file of files) {\n if (handleFile(view, event, file, handlers)) {\n handled = true\n }\n }\n return handled\n}\n","import {\n defineFacet,\n defineFacetPayload,\n editorEventFacet,\n type DropHandler,\n type EditorEventPayload,\n type PlainExtension,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { handleEvent } from './helpers.ts'\n\nexport interface FileDropHandlerOptions {\n /**\n * The editor view.\n */\n view: EditorView\n\n /**\n * The event that triggered the drop.\n */\n event: DragEvent\n\n /**\n * The file that was dropped.\n */\n file: File\n\n /**\n * The position of the document where the file was dropped.\n */\n pos: number\n}\n\n/**\n * A function that handles one of the files in a drop event.\n *\n * Returns `true` if the file was handled and thus should not be handled by\n * other handlers.\n */\nexport type FileDropHandler = (\n options: FileDropHandlerOptions,\n) => boolean | void\n\nexport function defineFileDropHandler(\n handler: FileDropHandler,\n): PlainExtension {\n return defineFacetPayload(facet, [handler]) as PlainExtension\n}\n\nfunction getFiles(event: DragEvent) {\n return Array.from(event.dataTransfer?.files ?? [])\n}\n\nconst facet = defineFacet<FileDropHandler, EditorEventPayload>({\n parent: editorEventFacet,\n singleton: true,\n reducer: (handlers: FileDropHandler[]): EditorEventPayload => {\n const dropHandler: DropHandler = (view, event): boolean => {\n const position = view.posAtCoords({ left: event.x, top: event.y })\n if (!position) {\n return false\n }\n const pos = position.inside > 0 ? position.inside : position.pos\n\n return handleEvent<DragEvent>(\n view,\n event,\n handlers.map((handler) => (options) => handler({ ...options, pos })),\n getFiles,\n )\n }\n return ['drop', dropHandler]\n },\n})\n","import {\n defineFacet,\n defineFacetPayload,\n editorEventFacet,\n type EditorEventPayload,\n type PasteHandler,\n type PlainExtension,\n} from '@prosekit/core'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { handleEvent } from './helpers.ts'\n\nexport interface FilePasteHandlerOptions {\n /**\n * The editor view.\n */\n view: EditorView\n\n /**\n * The event that triggered the paste.\n */\n event: ClipboardEvent\n\n /**\n * The file that was pasted.\n */\n file: File\n}\n\n/**\n * A function that handles one of the files in a paste event.\n *\n * Returns `true` if the file was handled and thus should not be handled by\n * other handlers.\n */\nexport type FilePasteHandler = (\n options: FilePasteHandlerOptions,\n) => boolean | void\n\nexport function defineFilePasteHandler(\n handler: FilePasteHandler,\n): PlainExtension {\n return defineFacetPayload(facet, [handler]) as PlainExtension\n}\n\nfunction getFiles(event: ClipboardEvent) {\n return Array.from(event.clipboardData?.files ?? [])\n}\n\nconst facet = defineFacet<FilePasteHandler, EditorEventPayload>({\n parent: editorEventFacet,\n singleton: true,\n reducer: (handlers: FilePasteHandler[]): EditorEventPayload => {\n const pasteHandler: PasteHandler = (view, event): boolean => {\n return handleEvent<ClipboardEvent>(view, event, handlers, getFiles)\n }\n return ['paste', pasteHandler]\n },\n})\n","import { ProseKitError } from '@prosekit/core'\n\n/**\n * An interface representing the upload progress.\n */\nexport interface UploadProgress {\n // A number representing the amount of work already performed by the\n // underlying process.\n loaded: number\n // A number representing the total amount of work that the underlying\n // process is in the progress of performing.\n total: number\n}\n\nexport interface UploaderOptions {\n /**\n * The file to be uploaded.\n */\n file: File\n\n /**\n * A callback function that should be called with the upload progress updates.\n */\n onProgress: (progress: UploadProgress) => void\n}\n\n/**\n * The implementation of the actual upload function. You need to implement this\n * function to upload files to your desired destination.\n */\nexport type Uploader<Result> = (options: UploaderOptions) => Promise<Result>\n\n/**\n * A class that represents a upload task.\n */\nexport class UploadTask<Result> {\n /**\n * An [object URL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL)\n * representing the file to be uploaded. This URL will be revoked once the\n * upload is complete successfully.\n */\n readonly objectURL: string\n\n /**\n * A boolean indicating whether the upload is complete (either successfully or with an error).\n */\n protected done = false\n\n /**\n * If the upload is complete successfully, this will be the result of the upload.\n */\n protected result: Result | undefined\n\n /**\n * If the upload is complete with an error, this will be the error that occurred.\n */\n protected error: Error | undefined\n\n /**\n * A promise that fulfills once the upload is complete, or rejects if an error occurs.\n */\n readonly finished: Promise<Result>\n\n private subscribers: ((progress: UploadProgress) => void)[] = []\n\n /**\n * Creates a new upload task. You can find the upload task by its object URL\n * later using `UploadTask.get()`.\n *\n * @param options - The options for the upload task.\n */\n constructor({ file, uploader }: { file: File; uploader: Uploader<Result> }) {\n this.objectURL = URL.createObjectURL(file)\n this.finished = new Promise((resolve, reject) => {\n const maybePromise = uploader({\n file,\n onProgress: (progress) => {\n for (const subscriber of this.subscribers) {\n subscriber(progress)\n }\n },\n })\n Promise.resolve(maybePromise).then(\n (result) => {\n this.done = true\n URL.revokeObjectURL(this.objectURL)\n this.result = result\n resolve(result)\n },\n (err) => {\n this.done = true\n const error = new ProseKitError('[prosekit] Failed to upload file', { cause: err })\n this.error = error\n reject(error)\n },\n )\n })\n store.set(this.objectURL, this)\n }\n\n /**\n * Subscribes to progress updates. Returns a function to unsubscribe.\n */\n public subscribeProgress(\n callback: (progress: UploadProgress) => void,\n ): VoidFunction {\n this.subscribers.push(callback)\n return () => {\n this.subscribers = this.subscribers.filter(\n (subscriber) => subscriber !== callback,\n )\n }\n }\n\n /**\n * Finds an upload task from the global store by its object URL.\n */\n static get<Result = unknown>(\n objectURL: string,\n ): UploadTask<Result> | undefined {\n return store.get(objectURL) as UploadTask<Result> | undefined\n }\n\n /**\n * Deletes an upload task from the global store by its object URL.\n */\n static delete(objectURL: string): void {\n store.delete(objectURL)\n }\n}\n\nconst store = new Map<string, UploadTask<unknown>>()\n"],"mappings":";;AAQA,SAAS,WACP,MACA,OACA,MACA,UACA;AAEA,MAAK,IAAI,IAAI,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK;EAC7C,MAAM,UAAU,SAAS;AACzB,MAAI,QAAQ;GAAE;GAAM;GAAO;GAAM,CAAC,CAChC,QAAO;;AAGX,QAAO;;AAGT,SAAgB,YACd,MACA,OACA,UACA,UACS;CACT,MAAM,QAAQ,SAAS,MAAM;CAC7B,IAAI,UAAU;AACd,MAAK,MAAM,QAAQ,MACjB,KAAI,WAAW,MAAM,OAAO,MAAM,SAAS,CACzC,WAAU;AAGd,QAAO;;;;ACOT,SAAgB,sBACd,SACgB;AAChB,QAAO,mBAAmBA,SAAO,CAAC,QAAQ,CAAC;;AAG7C,SAASC,WAAS,OAAkB;AAClC,QAAO,MAAM,KAAK,MAAM,cAAc,SAAS,EAAE,CAAC;;AAGpD,MAAMD,UAAQ,YAAiD;CAC7D,QAAQ;CACR,WAAW;CACX,UAAU,aAAoD;EAC5D,MAAM,eAA4B,MAAM,UAAmB;GACzD,MAAM,WAAW,KAAK,YAAY;IAAE,MAA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;;CAMjC,kBACE,UACc;AACd,OAAK,YAAY,KAAK,SAAS;AAC/B,eAAa;AACX,QAAK,cAAc,KAAK,YAAY,QACjC,eAAe,eAAe,SAChC;;;;;;CAOL,OAAO,IACL,WACgC;AAChC,SAAO,MAAM,IAAI,UAAU;;;;;CAM7B,OAAO,OAAO,WAAyB;AACrC,QAAM,OAAO,UAAU;;;AAI3B,MAAM,wBAAQ,IAAI,KAAkC"}
@@ -1,17 +1,17 @@
1
1
  .ProseMirror-gapcursor {
2
+ pointer-events: none;
2
3
  display: none;
3
4
  position: relative;
4
- pointer-events: none;
5
5
  }
6
6
 
7
7
  .ProseMirror-gapcursor:after {
8
+ content: "";
9
+ border-top: 1px solid;
10
+ width: 20px;
11
+ animation: 1.1s steps(2, start) infinite ProseMirror-cursor-blink;
8
12
  display: block;
9
13
  position: absolute;
10
14
  top: -2px;
11
- width: 20px;
12
- border-top: 1px solid currentColor;
13
- content: "";
14
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
15
15
  }
16
16
 
17
17
  @keyframes ProseMirror-cursor-blink {
@@ -23,6 +23,3 @@
23
23
  .ProseMirror-focused .ProseMirror-gapcursor {
24
24
  display: block;
25
25
  }
26
-
27
-
28
- /*# sourceMappingURL=style.css.map*/
@@ -131,4 +131,4 @@ declare class UploadTask<Result> {
131
131
  }
132
132
  //#endregion
133
133
  export { FilePasteHandler as a, FileDropHandler as c, UploaderOptions as i, FileDropHandlerOptions as l, UploadTask as n, FilePasteHandlerOptions as o, Uploader as r, defineFilePasteHandler as s, UploadProgress as t, defineFileDropHandler as u };
134
- //# sourceMappingURL=file-upload-dr3IXUty.d.ts.map
134
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/file/file-drop-handler.ts","../src/file/file-paste-handler.ts","../src/file/file-upload.ts"],"mappings":";;;;UAYiB,sBAAA;;AAAjB;;EAIE,IAAA,EAAM,UAAA;EAAA;;;EAKN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;
12
- list-style: none;
13
- }
8
+ margin: 0;
9
+ padding: 0;
10
+ list-style: none;
11
+ position: relative;
12
+ }
14
13
 
15
- & > .list-marker {
16
- position: absolute;
17
- width: 1.5em;
18
- width: 1lh;
19
- height: 1.5em;
20
- height: 1lh;
21
- inset-inline-start: 0;
22
- text-align: center;
23
- }
14
+ .prosemirror-flat-list > .list-marker {
15
+ width: 1.5em;
16
+ width: 1lh;
17
+ height: 1.5em;
18
+ text-align: center;
19
+ height: 1lh;
20
+ position: absolute;
21
+ inset-inline-start: 0;
22
+ }
24
23
 
25
- & > .list-content {
26
- margin-inline-start: 1.5em;
27
- margin-inline-start: 1lh;
28
- }
24
+ .prosemirror-flat-list > .list-content {
25
+ margin-inline-start: 1.5em;
26
+ margin-inline-start: 1lh;
27
+ }
29
28
 
30
- &[data-list-kind="bullet"] > .list-marker,
31
- &[data-list-kind="toggle"] > .list-marker {
32
- background-color: currentColor;
33
- mask-position: center;
34
- mask-repeat: no-repeat;
35
- mask-size: contain;
36
- }
29
+ .prosemirror-flat-list[data-list-kind="bullet"] > .list-marker, .prosemirror-flat-list[data-list-kind="toggle"] > .list-marker {
30
+ background-color: currentColor;
31
+ mask-position: center;
32
+ mask-size: contain;
33
+ mask-repeat: no-repeat;
34
+ }
37
35
 
38
- &[data-list-kind="bullet"] {
39
- & > .list-marker {
40
- mask-image: var(--prosekit-list-bullet-icon);
41
- }
42
- }
36
+ .prosemirror-flat-list[data-list-kind="bullet"] > .list-marker {
37
+ mask-image: var(--prosekit-list-bullet-icon);
38
+ }
43
39
 
44
- &[data-list-kind="toggle"] {
45
- & > .list-marker {
46
- mask-image: var(--prosekit-list-toggle-open-icon);
47
- }
40
+ .prosemirror-flat-list[data-list-kind="toggle"] > .list-marker {
41
+ mask-image: var(--prosekit-list-toggle-open-icon);
42
+ }
48
43
 
49
- &[data-list-collapsable][data-list-collapsed] > .list-marker {
50
- mask-image: var(--prosekit-list-toggle-closed-icon);
51
- }
52
- }
44
+ .prosemirror-flat-list[data-list-kind="toggle"][data-list-collapsable][data-list-collapsed] > .list-marker {
45
+ mask-image: var(--prosekit-list-toggle-closed-icon);
46
+ }
53
47
 
54
- &[data-list-kind="ordered"] {
55
- /*
56
- Ensure that the counters in children don't escape, so that the sub lists
57
- won't affect the counter of the parent list.
58
-
59
- See also https://github.com/ocavue/prosemirror-flat-list/issues/23
60
- */
61
- & > * {
62
- contain: style;
63
- }
64
-
65
- &::before {
66
- position: absolute;
67
- inset-inline-end: calc(100% - 1.5em);
68
- inset-inline-end: calc(100% - 1lh);
69
- content: counter(prosemirror-flat-list-counter, decimal) ". ";
70
- font-variant-numeric: tabular-nums;
71
- }
72
- counter-increment: prosemirror-flat-list-counter;
73
-
74
- /*
75
- Reset the counter for the first list node in the sequence.
76
- */
77
- &:first-child,
78
- :not(&) + & {
79
- counter-reset: prosemirror-flat-list-counter;
80
-
81
- /*
82
- If the first list node has a custom order number, set the counter to that value.
83
- */
84
- &[data-list-order] {
85
- @supports (counter-set: prosemirror-flat-list-counter 1) {
86
- counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
87
- }
88
-
89
- /*
90
- Safari older than version 17.2 doesn't support `counter-set`
91
- */
92
- @supports not (counter-set: prosemirror-flat-list-counter 1) {
93
- counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
94
- }
95
- }
96
- }
97
- }
48
+ .prosemirror-flat-list[data-list-kind="ordered"] > * {
49
+ contain: style;
50
+ }
51
+
52
+ .prosemirror-flat-list[data-list-kind="ordered"]:before {
53
+ inset-inline-end: calc(100% - 1.5em);
54
+ content: counter(prosemirror-flat-list-counter, decimal) ". ";
55
+ font-variant-numeric: tabular-nums;
56
+ position: absolute;
57
+ inset-inline-end: calc(100% - 1lh);
58
+ }
59
+
60
+ .prosemirror-flat-list[data-list-kind="ordered"] {
61
+ counter-increment: prosemirror-flat-list-counter;
62
+ }
63
+
64
+ .prosemirror-flat-list[data-list-kind="ordered"]:first-child, :not(.prosemirror-flat-list[data-list-kind="ordered"]) + .prosemirror-flat-list[data-list-kind="ordered"] {
65
+ counter-reset: prosemirror-flat-list-counter;
66
+ }
98
67
 
99
- &[data-list-kind="task"] {
100
- & > .list-marker {
101
- &,
102
- & * {
103
- /* Make sure that the checkbox is at the center */
104
- display: flex;
105
- align-items: center;
106
- justify-content: center;
107
- margin: 0;
108
- padding: 0;
109
- cursor: pointer;
110
- }
111
- }
68
+ @supports (counter-set: prosemirror-flat-list-counter 1) {
69
+ :is(.prosemirror-flat-list[data-list-kind="ordered"]:first-child, :not(.prosemirror-flat-list[data-list-kind="ordered"]) + .prosemirror-flat-list[data-list-kind="ordered"])[data-list-order] {
70
+ counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
112
71
  }
72
+ }
113
73
 
114
- &[data-list-kind="toggle"] {
115
- &[data-list-collapsable] > .list-marker {
116
- cursor: pointer;
117
- }
118
- &:not([data-list-collapsable]) > .list-marker {
119
- opacity: 40%;
120
- pointer-events: none;
121
- }
122
-
123
- /* If collapsed, hide the second and futher children */
124
- &[data-list-collapsable][data-list-collapsed] > .list-content > *:nth-child(n+2) {
125
- display: none;
126
- }
74
+ @supports not (counter-set: prosemirror-flat-list-counter 1) {
75
+ :is(.prosemirror-flat-list[data-list-kind="ordered"]:first-child, :not(.prosemirror-flat-list[data-list-kind="ordered"]) + .prosemirror-flat-list[data-list-kind="ordered"])[data-list-order] {
76
+ counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
127
77
  }
128
78
  }
129
79
 
80
+ .prosemirror-flat-list[data-list-kind="task"] > .list-marker, .prosemirror-flat-list[data-list-kind="task"] > .list-marker * {
81
+ cursor: pointer;
82
+ justify-content: center;
83
+ align-items: center;
84
+ margin: 0;
85
+ padding: 0;
86
+ display: flex;
87
+ }
88
+
89
+ .prosemirror-flat-list[data-list-kind="toggle"][data-list-collapsable] > .list-marker {
90
+ cursor: pointer;
91
+ }
130
92
 
131
- /*# sourceMappingURL=style.css.map*/
93
+ .prosemirror-flat-list[data-list-kind="toggle"]:not([data-list-collapsable]) > .list-marker {
94
+ opacity: .4;
95
+ pointer-events: none;
96
+ }
97
+
98
+ .prosemirror-flat-list[data-list-kind="toggle"][data-list-collapsable][data-list-collapsed] > .list-content > :nth-child(n+2) {
99
+ display: none;
100
+ }
@@ -2,35 +2,32 @@
2
2
  margin-top: 16px;
3
3
  }
4
4
 
5
- /* This gives the remote user caret. The colors are automatically overwritten */
6
5
  .ProseMirror-loro-cursor {
7
- position: relative;
8
- margin-right: -1px;
9
- margin-left: -1px;
10
- border-right: 1px solid black;
11
- border-left: 1px solid black;
12
- border-color: orange;
13
6
  word-break: normal;
14
7
  pointer-events: none;
8
+ border-color: orange;
9
+ border-left-style: solid;
10
+ border-left-width: 1px;
11
+ border-right-style: solid;
12
+ border-right-width: 1px;
13
+ margin-left: -1px;
14
+ margin-right: -1px;
15
+ position: relative;
15
16
  }
16
17
 
17
- /* This renders the username above the caret */
18
18
  .ProseMirror-loro-cursor > div {
19
- position: absolute;
20
- top: -1.05em;
21
- left: -1px;
22
- padding-right: 2px;
19
+ color: #fff;
20
+ white-space: nowrap;
21
+ user-select: none;
22
+ background-color: #fa8100;
23
23
  padding-left: 2px;
24
- background-color: rgb(250, 129, 0);
25
- color: white;
24
+ padding-right: 2px;
25
+ font-family: serif;
26
+ font-size: 13px;
26
27
  font-style: normal;
27
28
  font-weight: normal;
28
- font-size: 13px;
29
29
  line-height: normal;
30
- font-family: serif;
31
- white-space: nowrap;
32
- user-select: none;
30
+ position: absolute;
31
+ top: -1.05em;
32
+ left: -1px;
33
33
  }
34
-
35
-
36
- /*# sourceMappingURL=style.css.map*/
@@ -1,6 +1,5 @@
1
1
  import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
2
2
  import { OBJECT_REPLACEMENT_CHARACTER, defineFacet, defineFacetPayload, getMarkType, maybeRun, pluginFacet } from "@prosekit/core";
3
-
4
3
  //#region src/mark-rule/range.ts
5
4
  function getSpanTextRanges($from, $to) {
6
5
  const nodeRange = $from.blockRange($to);
@@ -57,7 +56,6 @@ function getCheckRanges(transactions, oldState, newState) {
57
56
  const [from, to] = getMapRange(transactions, oldState, newState);
58
57
  return getTextRanges(newState.doc, from, to);
59
58
  }
60
-
61
59
  //#endregion
62
60
  //#region src/mark-rule/apply.ts
63
61
  function getExpectedMarkings(rules, doc, from, to) {
@@ -128,7 +126,6 @@ function applyMarkRules(rules, transactions, oldState, newState) {
128
126
  for (const [from, to, mark] of toCreate) tr.addMark(from, to, mark);
129
127
  return tr;
130
128
  }
131
-
132
129
  //#endregion
133
130
  //#region src/mark-rule/mark-rule.ts
134
131
  /**
@@ -154,7 +151,7 @@ const markRuleFacet = defineFacet({
154
151
  },
155
152
  parent: pluginFacet
156
153
  });
157
-
158
154
  //#endregion
159
155
  export { defineMarkRule as t };
160
- //# sourceMappingURL=mark-rule-Bqdm49Eq.js.map
156
+
157
+ //# sourceMappingURL=mark-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mark-rule.js","names":[],"sources":["../src/mark-rule/range.ts","../src/mark-rule/apply.ts","../src/mark-rule/mark-rule.ts"],"sourcesContent":["import type { ProseMirrorNode, ResolvedPos } from '@prosekit/pm/model'\nimport type { EditorState, Transaction } from '@prosekit/pm/state'\nimport type { ProsemirrorNode } from 'prosemirror-flat-list'\n\nfunction getSpanTextRanges($from: ResolvedPos, $to: ResolvedPos) {\n const nodeRange = $from.blockRange($to)\n if (!nodeRange) {\n return []\n }\n\n const stack: Array<[start: number, node: ProseMirrorNode]> = []\n let start = nodeRange.start\n\n for (let i = nodeRange.startIndex; i < nodeRange.endIndex; i++) {\n const child = nodeRange.parent.child(i)\n stack.push([start, child])\n start += child.nodeSize\n }\n\n const ranges: Array<[number, number]> = []\n\n while (stack.length > 0) {\n const [start, node] = stack.pop()!\n if (node.type.spec.code) {\n continue\n }\n\n if (node.type.isTextblock) {\n ranges.push([start + 1, start + 1 + node.content.size])\n continue\n }\n\n node.forEach((child, offset) => {\n stack.push([start + offset + 1, child])\n })\n }\n\n return ranges\n}\n\nfunction getInlineTextRange(\n $from: ResolvedPos,\n $to: ResolvedPos,\n): [number, number] {\n return [$from.start(), $to.end()]\n}\n\nfunction getTextRanges(\n doc: ProsemirrorNode,\n from: number,\n to: number,\n): Array<[number, number]> {\n const $from = doc.resolve(from)\n const $to = doc.resolve(to)\n\n if ($from.sameParent($to) && $from.parent.isTextblock) {\n return [getInlineTextRange($from, $to)]\n } else {\n const nodeRange = $from.blockRange($to)\n if (!nodeRange) {\n return []\n }\n\n return getSpanTextRanges($from, $to)\n }\n}\n\nfunction getMapRange(\n transactions: readonly Transaction[],\n oldState: EditorState,\n newState: EditorState,\n) {\n let lo = oldState.selection.from\n let hi = oldState.selection.to\n\n for (const tr of transactions) {\n for (const map of tr.mapping.maps) {\n lo = map.map(lo)\n hi = map.map(hi)\n\n map.forEach((_oldStart, _oldEnd, newStart, newEnd) => {\n lo = Math.min(lo, hi, newStart)\n hi = Math.max(lo, hi, newEnd)\n })\n }\n }\n\n lo = Math.min(lo, hi, newState.selection.from)\n hi = Math.min(lo, hi, newState.selection.to)\n\n return [lo, hi] as const\n}\n\nexport function getCheckRanges(\n transactions: readonly Transaction[],\n oldState: EditorState,\n newState: EditorState,\n): Array<[number, number]> {\n const [from, to] = getMapRange(transactions, oldState, newState)\n return getTextRanges(newState.doc, from, to)\n}\n","import { getMarkType, maybeRun, OBJECT_REPLACEMENT_CHARACTER } from '@prosekit/core'\nimport type { Mark, ProseMirrorNode } from '@prosekit/pm/model'\nimport type { EditorState, Transaction } from '@prosekit/pm/state'\n\nimport { getCheckRanges } from './range.ts'\nimport type { MarkRuleOptions } from './types.ts'\n\ntype MarkRange = [from: number, to: number, mark: Mark]\n\nfunction getExpectedMarkings(\n rules: MarkRuleOptions[],\n doc: ProseMirrorNode,\n from: number,\n to: number,\n): MarkRange[] {\n const text = doc.textBetween(from, to, null, OBJECT_REPLACEMENT_CHARACTER)\n const ranges: MarkRange[] = []\n\n for (const rule of rules) {\n rule.regex.lastIndex = 0\n const matches = text.matchAll(rule.regex)\n const markType = getMarkType(doc.type.schema, rule.type)\n\n for (const match of matches) {\n const index = match.index\n if (index == null) continue\n const attrs = maybeRun(rule.attrs, match)\n const mark = markType.create(attrs)\n ranges.push([from + index, from + index + match[0].length, mark])\n }\n }\n\n // Sort by start position. If start positions are equal, the longer match\n // should be prioritized.\n ranges.sort((a, b) => a[0] - b[0] || b[1] - a[1])\n\n // Remove overlapped marks.\n const result: MarkRange[] = []\n let freeIndex = 0\n\n for (const range of ranges) {\n if (range[0] >= freeIndex) {\n result.push(range)\n freeIndex = range[1]\n }\n }\n\n return result\n}\n\nfunction getReceivedMarkings(\n rules: MarkRuleOptions[],\n doc: ProseMirrorNode,\n from: number,\n to: number,\n): MarkRange[] {\n const result: MarkRange[] = []\n const schema = doc.type.schema\n const markTypes = rules.map((rule) => getMarkType(schema, rule.type))\n\n doc.nodesBetween(from, to, (node, pos) => {\n if (!node.isInline) {\n return\n }\n\n for (const markType of markTypes) {\n const mark = node.marks.find((mark) => mark.type === markType)\n if (mark) {\n result.push([pos, pos + node.nodeSize, mark])\n }\n }\n })\n return result\n}\n\nfunction markRangeEquals(a: MarkRange, b: MarkRange): boolean {\n return a[0] === b[0] && a[1] === b[1] && a[2].eq(b[2])\n}\n\nfunction markRangeDiffs(a: MarkRange[], b: MarkRange[]): MarkRange[] {\n return a.filter((x) => !b.some((y) => markRangeEquals(x, y)))\n}\n\nexport function applyMarkRules(\n rules: MarkRuleOptions[],\n transactions: readonly Transaction[],\n oldState: EditorState,\n newState: EditorState,\n): Transaction | null {\n if (transactions.length === 0 || transactions.every((tr) => !tr.docChanged)) {\n return null\n }\n\n const ranges = getCheckRanges(transactions, oldState, newState)\n\n const toRemove: MarkRange[] = []\n const toCreate: MarkRange[] = []\n\n for (const [from, to] of ranges) {\n const expected = getExpectedMarkings(rules, newState.doc, from, to)\n const received = getReceivedMarkings(rules, newState.doc, from, to)\n\n toRemove.push(...markRangeDiffs(received, expected))\n toCreate.push(...markRangeDiffs(expected, received))\n }\n\n if (toCreate.length === 0 && toRemove.length === 0) {\n return null\n }\n\n const tr = newState.tr\n for (const [from, to, mark] of toRemove) {\n tr.removeMark(from, to, mark)\n }\n for (const [from, to, mark] of toCreate) {\n tr.addMark(from, to, mark)\n }\n return tr\n}\n","import { defineFacet, defineFacetPayload, pluginFacet, type PlainExtension, type PluginPayload } from '@prosekit/core'\nimport { PluginKey, ProseMirrorPlugin, type EditorState, type Transaction } from '@prosekit/pm/state'\n\nimport { applyMarkRules } from './apply.ts'\nimport type { MarkRuleOptions } from './types.ts'\n\n/**\n * A mark rule is something that can automatically apply marks to text if it\n * matches a certain pattern, and remove them if it doesn't match anymore.\n */\nexport function defineMarkRule(options: MarkRuleOptions): PlainExtension {\n return defineFacetPayload(markRuleFacet, [options]) as PlainExtension\n}\n\nconst markRuleFacet = defineFacet<MarkRuleOptions, PluginPayload>({\n reduce: () => {\n let rules: MarkRuleOptions[] = []\n\n const plugin = new ProseMirrorPlugin({\n key: new PluginKey('prosekit-mark-rule'),\n appendTransaction: (\n transactions: readonly Transaction[],\n oldState: EditorState,\n newState: EditorState,\n ) => {\n return applyMarkRules(rules, transactions, oldState, newState)\n },\n })\n\n return function reducer(input) {\n rules = input\n return plugin\n }\n },\n\n parent: pluginFacet,\n})\n"],"mappings":";;;AAIA,SAAS,kBAAkB,OAAoB,KAAkB;CAC/D,MAAM,YAAY,MAAM,WAAW,IAAI;AACvC,KAAI,CAAC,UACH,QAAO,EAAE;CAGX,MAAM,QAAuD,EAAE;CAC/D,IAAI,QAAQ,UAAU;AAEtB,MAAK,IAAI,IAAI,UAAU,YAAY,IAAI,UAAU,UAAU,KAAK;EAC9D,MAAM,QAAQ,UAAU,OAAO,MAAM,EAAE;AACvC,QAAM,KAAK,CAAC,OAAO,MAAM,CAAC;AAC1B,WAAS,MAAM;;CAGjB,MAAM,SAAkC,EAAE;AAE1C,QAAO,MAAM,SAAS,GAAG;EACvB,MAA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H,WAAO,eAAe,OAAO,cAAc,UAAU,SAAS;;GAEjE,CAAC;AAEF,SAAO,SAAS,QAAQ,OAAO;AAC7B,WAAQ;AACR,UAAO;;;CAIX,QAAQ;CACT,CAAC"}
@@ -0,0 +1,43 @@
1
+ .ProseMirror pm-page-chunk {
2
+ box-sizing: border-box;
3
+ width: var(--page-width, 100%);
4
+ padding-top: 0;
5
+ padding-right: var(--page-margin-right, 0);
6
+ padding-bottom: 0;
7
+ padding-left: var(--page-margin-left, 0);
8
+ margin: 0;
9
+ display: flow-root;
10
+ position: relative;
11
+ }
12
+
13
+ .ProseMirror pm-page-chunk ~ pm-page-chunk[data-page-head] {
14
+ margin-top: 50px;
15
+ }
16
+
17
+ @media print {
18
+ .ProseMirror pm-page-chunk ~ pm-page-chunk[data-page-head] {
19
+ margin-top: 0;
20
+ }
21
+ }
22
+
23
+ .ProseMirror pm-page-chunk[data-page-head]:before {
24
+ box-sizing: border-box;
25
+ width: 100%;
26
+ height: var(--page-height);
27
+ content: "";
28
+ pointer-events: none;
29
+ outline: 1px solid canvastext;
30
+ position: absolute;
31
+ top: 0;
32
+ left: 0;
33
+ }
34
+
35
+ @media print {
36
+ .ProseMirror pm-page-chunk[data-page-head]:before {
37
+ outline-color: #0000;
38
+ }
39
+ }
40
+
41
+ .ProseMirror pm-page-chunk[data-page-tail] {
42
+ break-after: page;
43
+ }
@@ -1,7 +1,6 @@
1
1
  import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
2
2
  import { defineFacet, defineFacetPayload, getMarkType, pluginFacet } from "@prosekit/core";
3
3
  import { Fragment, Slice } from "@prosekit/pm/model";
4
-
5
4
  //#region src/paste-rule/paste-rule-plugin.ts
6
5
  /**
7
6
  * @internal
@@ -35,7 +34,6 @@ const pasteRuleFacet = defineFacet({
35
34
  function definePasteRulePlugin(payload) {
36
35
  return defineFacetPayload(pasteRuleFacet, [payload]);
37
36
  }
38
-
39
37
  //#endregion
40
38
  //#region src/paste-rule/paste-rule.ts
41
39
  /**
@@ -49,7 +47,6 @@ function definePasteRulePlugin(payload) {
49
47
  function definePasteRule({ handler }) {
50
48
  return definePasteRulePlugin(handler);
51
49
  }
52
-
53
50
  //#endregion
54
51
  //#region src/paste-rule/split-text-by-regex.ts
55
52
  /**
@@ -76,7 +73,6 @@ function splitTextByRegex(text, regex) {
76
73
  regex.lastIndex = 0;
77
74
  return matched ? chunks : void 0;
78
75
  }
79
-
80
76
  //#endregion
81
77
  //#region src/paste-rule/mark-paste-rule.ts
82
78
  /**
@@ -156,7 +152,7 @@ function replaceMarkInInlineNode(options, node) {
156
152
  }
157
153
  return nodes;
158
154
  }
159
-
160
155
  //#endregion
161
156
  export { definePasteRule as n, defineMarkPasteRule as t };
162
- //# sourceMappingURL=mark-paste-rule--F1QPUcU.js.map
157
+
158
+ //# sourceMappingURL=paste-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-rule.js","names":[],"sources":["../src/paste-rule/paste-rule-plugin.ts","../src/paste-rule/paste-rule.ts","../src/paste-rule/split-text-by-regex.ts","../src/paste-rule/mark-paste-rule.ts"],"sourcesContent":["import { defineFacet, defineFacetPayload, pluginFacet, type PlainExtension, type PluginPayload } from '@prosekit/core'\nimport type { Slice } from '@prosekit/pm/model'\nimport { PluginKey, ProseMirrorPlugin } from '@prosekit/pm/state'\nimport type { EditorView } from '@prosekit/pm/view'\n\ntype PasteRulePayload = (options: { slice: Slice; view: EditorView; plain: boolean }) => Slice\n\n/**\n * @internal\n */\nconst pasteRuleFacet = defineFacet<PasteRulePayload, PluginPayload>({\n reduce: () => {\n let handlers: PasteRulePayload[] = []\n\n const transformPasted = (slice: Slice, view: EditorView, plain: boolean): Slice => {\n for (const handler of handlers) {\n slice = handler({ slice, view, plain })\n }\n return slice\n }\n\n const plugin = new ProseMirrorPlugin({\n key: new PluginKey('prosekit-paste-rule'),\n props: {\n transformPasted,\n },\n })\n\n return (inputs: PasteRulePayload[]) => {\n // Last added rule (highest priority) is applied first\n handlers = [...inputs].reverse()\n return plugin\n }\n },\n singleton: true,\n parent: pluginFacet,\n})\n\n/**\n * @internal\n */\nexport function definePasteRulePlugin(payload: PasteRulePayload): PlainExtension {\n return defineFacetPayload(pasteRuleFacet, [payload]) as PlainExtension\n}\n","import type { PlainExtension } from '@prosekit/core'\nimport type { Slice } from '@prosekit/pm/model'\nimport type { EditorView } from '@prosekit/pm/view'\n\nimport { definePasteRulePlugin } from './paste-rule-plugin.ts'\n\n/**\n * @public\n *\n * Options for {@link PasteRuleHandler}.\n */\nexport interface PasteRuleHandlerOptions {\n /**\n * The slice to be pasted.\n */\n slice: Slice\n\n /**\n * The editor view.\n */\n view: EditorView\n\n /**\n * Whether the pasted content is treated as plain text. This is true when the\n * `Shift` key is held when pasting.\n */\n plain: boolean\n}\n\n/**\n * @public\n *\n * Can be used to transform pasted or dragged-and-dropped content before it is\n * applied to the document.\n */\nexport type PasteRuleHandler = (options: PasteRuleHandlerOptions) => Slice\n\n/**\n * Options for {@link definePasteRule}.\n *\n * @public\n */\nexport interface PasteRuleOptions {\n /**\n * A function to be called when a paste rule is triggered.\n */\n handler: PasteRuleHandler\n}\n\n/**\n * Defines a paste rule. This rule allows you to modify pasted or dragged\n * content before it is inserted into the document.\n *\n * @param options\n *\n * @public\n */\nexport function definePasteRule({ handler }: PasteRuleOptions): PlainExtension {\n return definePasteRulePlugin(handler)\n}\n","/**\n * Splits text into chunks based on regex matches, preserving both matched and unmatched segments.\n * Returns an array of tuples where each tuple contains a text segment and either the match data\n * (for matched segments) or undefined (for unmatched segments).\n */\nexport function splitTextByRegex(\n text: string,\n regex: RegExp,\n): Array<[string, RegExpExecArray | undefined]> | undefined {\n regex.lastIndex = 0\n\n const chunks: Array<[string, RegExpExecArray | undefined]> = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n let matched = false\n\n while ((match = regex.exec(text))) {\n const start = match.index\n const end = regex.lastIndex\n\n // Push the unmatched prefix, if any.\n if (start > lastIndex) {\n chunks.push([text.slice(lastIndex, start), undefined])\n }\n\n // Push the matched segment.\n chunks.push([text.slice(start, end), match])\n matched = true\n\n if (lastIndex === end) {\n // Safeguard against zero-width matches that would otherwise cause an infinite loop.\n return\n }\n lastIndex = end\n }\n\n if (matched && lastIndex < text.length) {\n chunks.push([text.slice(lastIndex), undefined])\n }\n\n regex.lastIndex = 0\n\n return matched ? chunks : undefined\n}\n","import { getMarkType, type PlainExtension } from '@prosekit/core'\nimport type { Attrs, MarkType, ProseMirrorNode } from '@prosekit/pm/model'\nimport { Fragment, Slice } from '@prosekit/pm/model'\n\nimport { definePasteRule } from './paste-rule.ts'\nimport { splitTextByRegex } from './split-text-by-regex.ts'\n\n/**\n * The options for {@link defineMarkPasteRule}.\n *\n * @public\n */\nexport interface MarkPasteRuleOptions {\n /**\n * The regular expression to match against. It must have a `g` flag to match\n * all instances of the mark.\n */\n regex: RegExp\n\n /**\n * The mark type to apply to the matched text.\n */\n type: string | MarkType\n\n /**\n * A function used to compute attributes to set on the mark created by this\n * rule. When it returns `false`, the rule won't match. When it returns `null`\n * or `undefined`, that is interpreted as an empty/default set of attributes.\n * @default null\n */\n getAttrs?: (match: RegExpExecArray) => Attrs | null | undefined | false\n\n /**\n * Optional function to determine if a text node should be skipped.\n * Default behavior: skip code nodes and nodes that already have the target mark.\n */\n shouldSkip?: (node: ProseMirrorNode) => boolean\n}\n\n/**\n * Defines a paste rule that applies marks based on regex patterns.\n *\n * @public\n */\nexport function defineMarkPasteRule(options: MarkPasteRuleOptions): PlainExtension {\n return definePasteRule({\n handler: ({ slice, view, plain }) => {\n if (plain) {\n return slice\n }\n\n const markType = getMarkType(view.state.schema, options.type)\n\n return replaceMarkInSlice({\n markType,\n regex: options.regex,\n getAttrs: options.getAttrs,\n shouldSkip: options.shouldSkip,\n }, slice)\n },\n })\n}\n\ninterface MarkPasteRuleHandlerOptions {\n markType: MarkType\n regex: RegExp\n getAttrs?: (match: RegExpExecArray) => Attrs | null | undefined | false\n shouldSkip?: (node: ProseMirrorNode) => boolean\n}\n\nfunction replaceMarkInSlice(options: MarkPasteRuleHandlerOptions, slice: Slice): Slice {\n const newFragment = replaceMarkInFragment(options, slice.content)\n if (!newFragment) {\n return slice\n }\n return new Slice(newFragment, slice.openStart, slice.openEnd)\n}\n\nfunction replaceMarkInFragment(options: MarkPasteRuleHandlerOptions, fragment: Fragment): Fragment | undefined {\n let changed = false\n const children: ProseMirrorNode[] = []\n\n for (const child of fragment.content) {\n const newChild = replaceMarkInNode(options, child)\n if (newChild) {\n changed = true\n }\n children.push(newChild || child)\n }\n\n if (changed) {\n return Fragment.from(children)\n }\n\n return\n}\n\nfunction replaceMarkInNode(options: MarkPasteRuleHandlerOptions, node: ProseMirrorNode): ProseMirrorNode | undefined {\n if (node.type.spec.code) {\n return\n }\n if (node.type.isInline) {\n return\n }\n if (node.type.isTextblock) {\n return replaceMarkInTextblockNode(options, node)\n }\n\n const newChildren = replaceMarkInFragment(options, node.content)\n if (!newChildren) {\n return\n }\n return node.copy(newChildren)\n}\n\nfunction replaceMarkInTextblockNode(options: MarkPasteRuleHandlerOptions, node: ProseMirrorNode): ProseMirrorNode | undefined {\n const newChildren: ProseMirrorNode[] = []\n let changed = false\n\n for (const inlineNode of node.content.content) {\n const newInlineNodes = replaceMarkInInlineNode(options, inlineNode)\n if (newInlineNodes) {\n changed = true\n newChildren.push(...newInlineNodes)\n } else {\n newChildren.push(inlineNode)\n }\n }\n if (changed) {\n return node.copy(Fragment.from(newChildren))\n }\n return\n}\n\nfunction replaceMarkInInlineNode(options: MarkPasteRuleHandlerOptions, node: ProseMirrorNode): ProseMirrorNode[] | undefined {\n const text = node.text\n if (!text) {\n return\n }\n\n const { markType, shouldSkip } = options\n\n // Use custom skip logic if provided, otherwise use default\n if (shouldSkip) {\n if (shouldSkip(node)) {\n return\n }\n } else {\n // Default skip logic: skip if already has the target mark or has code mark\n if (node.marks.some((mark) => mark.type === markType)) {\n return\n }\n if (node.marks.some((mark) => mark.type.spec.code)) {\n return\n }\n }\n\n const chunks = splitTextByRegex(text, options.regex)\n if (!chunks) {\n return\n }\n\n const schema = node.type.schema\n const nodes: ProseMirrorNode[] = []\n\n for (const [text, match] of chunks) {\n if (!text) {\n continue\n }\n if (match) {\n const attrs = options.getAttrs?.(match) ?? null\n if (attrs !== false) {\n const mark = markType.create(attrs)\n nodes.push(schema.text(text, [...node.marks, mark]))\n } else {\n nodes.push(schema.text(text, node.marks))\n }\n } else {\n nodes.push(schema.text(text, node.marks))\n }\n }\n\n return nodes\n}\n"],"mappings":";;;;;;;AAUA,MAAM,iBAAiB,YAA6C;CAClE,cAAc;EACZ,IAAI,WAA+B,EAAE;EAErC,MAAM,mBAAmB,OAAc,MAAkB,UAA0B;AACjF,QAAK,MAAM,WAAW,SACpB,SAAQ,QAAQ;IAAE;IAAO;IAAM;IAAO,CAAC;AAEzC,UAAO;;EAGT,MAAM,SAAS,IAAI,kBAAkB;GACnC,KAAK,IAAI,UAAU,sBAAsB;GACzC,OAAO,EACL,iBACD;GACF,CAAC;AAEF,UAAQ,WAA+B;AAErC,cAAW,CAAC,GAAG,OAAO,CAAC,SAAS;AAChC,UAAO;;;CAGX,WAAW;CACX,QAAQ;CACT,CAAC;;;;AAKF,SAAgB,sBAAsB,SAA2C;AAC/E,QAAO,mBAAmB,gBAAgB,CAAC,QAAQ,CAAC;;;;;;;;;;;;ACetD,SAAgB,gBAAgB,EAAE,WAA6C;AAC7E,QAAO,sBAAsB,QAAQ;;;;;;;;;ACrDvC,SAAgB,iBACd,MACA,OAC0D;AAC1D,OAAM,YAAY;CAElB,MAAM,SAAuD,EAAE;CAC/D,IAAI,YAAY;CAChB,IAAI;CACJ,IAAI,UAAU;AAEd,QAAQ,QAAQ,MAAM,KAAK,KAAK,EAAG;EACjC,MAAM,QAAQ,MAAM;EACpB,MAAM,MAAM,MAAM;AAGlB,MAAI,QAAQ,UACV,QAAO,KAAK,CAAC,KAAK,MAAM,WAAW,MAAM,EAAE,KAAA,EAAU,CAAC;AAIxD,SAAO,KAAK,CA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  pointer-events: none;
5
+ height: 0;
6
+ position: absolute;
7
7
  }
8
-
9
-
10
- /*# sourceMappingURL=style.css.map*/
@@ -1,7 +1,6 @@
1
1
  import { Plugin, PluginKey } from "@prosekit/pm/state";
2
2
  import { OBJECT_REPLACEMENT_CHARACTER, defineFacet, defineFacetPayload, pluginFacet } from "@prosekit/core";
3
3
  import { Decoration, DecorationSet } from "@prosekit/pm/view";
4
-
5
4
  //#region src/autocomplete/autocomplete-helpers.ts
6
5
  function defaultCanMatch({ state }) {
7
6
  const $pos = state.selection.$from;
@@ -25,7 +24,6 @@ function setTrMeta(tr, meta) {
25
24
  return tr.setMeta(pluginKey, meta);
26
25
  }
27
26
  const pluginKey = new PluginKey("prosekit-autocomplete");
28
-
29
27
  //#endregion
30
28
  //#region src/autocomplete/autocomplete-rule.ts
31
29
  /**
@@ -41,7 +39,6 @@ var AutocompleteRule = class {
41
39
  this.canMatch = options.canMatch ?? defaultCanMatch;
42
40
  }
43
41
  };
44
-
45
42
  //#endregion
46
43
  //#region src/autocomplete/autocomplete-plugin.ts
47
44
  /**
@@ -226,7 +223,6 @@ function mapMatching(matching, mapping) {
226
223
  to: mapping.map(matching.to, -1)
227
224
  };
228
225
  }
229
-
230
226
  //#endregion
231
227
  //#region src/autocomplete/autocomplete.ts
232
228
  /**
@@ -253,7 +249,7 @@ const autocompleteFacet = defineFacet({
253
249
  parent: pluginFacet,
254
250
  singleton: true
255
251
  });
256
-
257
252
  //#endregion
258
253
  export { AutocompleteRule, defineAutocomplete };
254
+
259
255
  //# sourceMappingURL=prosekit-extensions-autocomplete.js.map