@prosekit/extensions 0.8.0 → 0.9.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 (100) hide show
  1. package/dist/commit/style.css +2 -1
  2. package/dist/commit/style.js +0 -0
  3. package/dist/enter-rule-RdhEA900.js +96 -0
  4. package/dist/gap-cursor/style.css +8 -5
  5. package/dist/gap-cursor/style.js +0 -0
  6. package/dist/input-rule-Gji4N7Oe.js +93 -0
  7. package/dist/list/style.css +7 -7
  8. package/dist/list/style.js +0 -0
  9. package/dist/loro/style.css +21 -17
  10. package/dist/loro/style.js +0 -0
  11. package/dist/mark-rule-wEOcDt6i.js +160 -0
  12. package/dist/placeholder/style.css +5 -5
  13. package/dist/placeholder/style.js +0 -0
  14. package/dist/prosekit-extensions-autocomplete.d.ts +33 -3
  15. package/dist/prosekit-extensions-autocomplete.js +122 -174
  16. package/dist/prosekit-extensions-blockquote.d.ts +51 -8
  17. package/dist/prosekit-extensions-blockquote.js +64 -78
  18. package/dist/prosekit-extensions-bold.d.ts +61 -8
  19. package/dist/prosekit-extensions-bold.js +61 -73
  20. package/dist/prosekit-extensions-code-block.d.ts +172 -20
  21. package/dist/prosekit-extensions-code-block.js +201 -184
  22. package/dist/prosekit-extensions-code.d.ts +61 -8
  23. package/dist/prosekit-extensions-code.js +44 -56
  24. package/dist/prosekit-extensions-commit.d.ts +53 -4
  25. package/dist/prosekit-extensions-commit.js +142 -183
  26. package/dist/prosekit-extensions-doc.d.ts +22 -2
  27. package/dist/prosekit-extensions-doc.js +14 -12
  28. package/dist/prosekit-extensions-drop-cursor.d.ts +34 -3
  29. package/dist/prosekit-extensions-drop-cursor.js +14 -8
  30. package/dist/prosekit-extensions-enter-rule.d.ts +106 -5
  31. package/dist/prosekit-extensions-enter-rule.js +3 -8
  32. package/dist/prosekit-extensions-file.d.ts +126 -8
  33. package/dist/prosekit-extensions-file.js +111 -132
  34. package/dist/prosekit-extensions-gap-cursor.d.ts +29 -2
  35. package/dist/prosekit-extensions-gap-cursor.js +21 -9
  36. package/dist/prosekit-extensions-hard-break.d.ts +58 -0
  37. package/dist/prosekit-extensions-hard-break.js +58 -0
  38. package/dist/prosekit-extensions-heading.d.ts +69 -9
  39. package/dist/prosekit-extensions-heading.js +121 -95
  40. package/dist/prosekit-extensions-horizontal-rule.d.ts +41 -8
  41. package/dist/prosekit-extensions-horizontal-rule.js +53 -71
  42. package/dist/prosekit-extensions-image.d.ts +53 -7
  43. package/dist/prosekit-extensions-image.js +71 -62
  44. package/dist/prosekit-extensions-input-rule.d.ts +134 -6
  45. package/dist/prosekit-extensions-input-rule.js +3 -14
  46. package/dist/prosekit-extensions-italic.d.ts +61 -8
  47. package/dist/prosekit-extensions-italic.js +51 -63
  48. package/dist/prosekit-extensions-link.d.ts +65 -10
  49. package/dist/prosekit-extensions-link.js +95 -100
  50. package/dist/prosekit-extensions-list.d.ts +114 -17
  51. package/dist/prosekit-extensions-list.js +115 -158
  52. package/dist/prosekit-extensions-loro.d.ts +78 -11
  53. package/dist/prosekit-extensions-loro.js +49 -77
  54. package/dist/prosekit-extensions-mark-rule.d.ts +41 -2
  55. package/dist/prosekit-extensions-mark-rule.js +3 -6
  56. package/dist/prosekit-extensions-mention.d.ts +40 -4
  57. package/dist/prosekit-extensions-mention.js +52 -50
  58. package/dist/prosekit-extensions-mod-click-prevention.d.ts +20 -2
  59. package/dist/prosekit-extensions-mod-click-prevention.js +20 -16
  60. package/dist/prosekit-extensions-paragraph.d.ts +65 -7
  61. package/dist/prosekit-extensions-paragraph.js +46 -45
  62. package/dist/prosekit-extensions-placeholder.d.ts +32 -2
  63. package/dist/prosekit-extensions-placeholder.js +39 -56
  64. package/dist/prosekit-extensions-readonly.d.ts +13 -1
  65. package/dist/prosekit-extensions-readonly.js +13 -14
  66. package/dist/prosekit-extensions-search.d.ts +77 -3
  67. package/dist/prosekit-extensions-search.js +48 -47
  68. package/dist/prosekit-extensions-strike.d.ts +50 -8
  69. package/dist/prosekit-extensions-strike.js +44 -49
  70. package/dist/prosekit-extensions-table.d.ts +237 -26
  71. package/dist/prosekit-extensions-table.js +3 -34
  72. package/dist/prosekit-extensions-text-align.d.ts +72 -8
  73. package/dist/prosekit-extensions-text-align.js +63 -44
  74. package/dist/prosekit-extensions-text.d.ts +22 -2
  75. package/dist/prosekit-extensions-text.js +13 -11
  76. package/dist/prosekit-extensions-underline.d.ts +46 -7
  77. package/dist/prosekit-extensions-underline.js +33 -37
  78. package/dist/prosekit-extensions-virtual-selection.d.ts +24 -2
  79. package/dist/prosekit-extensions-virtual-selection.js +49 -52
  80. package/dist/prosekit-extensions-yjs.d.ts +99 -14
  81. package/dist/prosekit-extensions-yjs.js +88 -131
  82. package/dist/prosekit-extensions.d.ts +1 -1
  83. package/dist/search/style.css +5 -5
  84. package/dist/search/style.js +0 -0
  85. package/dist/shiki-highlighter-chunk-Cd3WeOKL.d.ts +19 -0
  86. package/dist/shiki-highlighter-chunk.d.ts +2 -0
  87. package/dist/shiki-highlighter-chunk.js +32 -39
  88. package/dist/table/style.css +18 -17
  89. package/dist/table/style.js +0 -0
  90. package/dist/table-DnVliJ6E.js +287 -0
  91. package/dist/virtual-selection/style.css +2 -2
  92. package/dist/virtual-selection/style.js +0 -0
  93. package/dist/yjs/style.css +15 -17
  94. package/dist/yjs/style.js +0 -0
  95. package/package.json +80 -53
  96. package/dist/_tsup-dts-rollup.d.ts +0 -2459
  97. package/dist/chunk-6UYLCVBX.js +0 -185
  98. package/dist/chunk-D54VSLLS.js +0 -105
  99. package/dist/chunk-I2UMHK3L.js +0 -99
  100. package/dist/chunk-QVFEYPQ6.js +0 -306
@@ -1,148 +1,105 @@
1
- // src/yjs/yjs.ts
2
- import {
3
- Priority,
4
- union,
5
- withPriority
6
- } from "@prosekit/core";
1
+ import { Priority, defineCommands, defineKeymap, definePlugin, isApple, union, withPriority } from "@prosekit/core";
2
+ import { redoCommand, undoCommand, yCursorPlugin, ySyncPlugin, yUndoPlugin, yUndoPluginKey } from "y-prosemirror";
7
3
 
8
- // src/yjs/yjs-commands.ts
9
- import {
10
- defineCommands
11
- } from "@prosekit/core";
12
-
13
- // src/yjs/yjs-undo-plugin.ts
14
- import { definePlugin } from "@prosekit/core";
15
- import {
16
- redo as yRedo,
17
- undo as yUndo,
18
- yUndoPlugin as originalYUndoPlugin,
19
- yUndoPluginKey
20
- } from "y-prosemirror";
21
- function fixYUndoPlugin(yUndoPluginInstance) {
22
- const originalUndoPluginView = yUndoPluginInstance.spec.view;
23
- yUndoPluginInstance.spec.view = (view) => {
24
- const { undoManager } = yUndoPluginKey.getState(view.state);
25
- if (undoManager.restore) {
26
- undoManager.restore();
27
- undoManager.restore = () => {
28
- };
29
- }
30
- const viewRet = originalUndoPluginView ? originalUndoPluginView(view) : void 0;
31
- return {
32
- destroy: () => {
33
- const hasUndoManSelf = undoManager.trackedOrigins.has(undoManager);
34
- const observers = undoManager._observers;
35
- undoManager.restore = () => {
36
- if (hasUndoManSelf) {
37
- undoManager.trackedOrigins.add(undoManager);
38
- }
39
- undoManager.doc.on(
40
- "afterTransaction",
41
- undoManager.afterTransactionHandler
42
- );
43
- undoManager._observers = observers;
44
- };
45
- if (viewRet?.destroy) {
46
- viewRet.destroy();
47
- }
48
- }
49
- };
50
- };
51
- }
52
- function yUndoPlugin(options) {
53
- const yUndoPluginInstance = originalYUndoPlugin(options);
54
- fixYUndoPlugin(yUndoPluginInstance);
55
- return yUndoPluginInstance;
56
- }
57
- var undo = (state, dispatch) => {
58
- const { undoManager } = yUndoPluginKey.getState(state);
59
- if (undoManager.undoStack.length === 0) {
60
- return false;
61
- }
62
- if (!dispatch) {
63
- return true;
64
- }
65
- return yUndo(state);
66
- };
67
- var redo = (state, dispatch) => {
68
- const { undoManager } = yUndoPluginKey.getState(state);
69
- if (undoManager.redoStack.length === 0) {
70
- return false;
71
- }
72
- if (!dispatch) {
73
- return true;
74
- }
75
- return yRedo(state);
76
- };
77
- function defineYjsUndoPlugin(options) {
78
- return definePlugin(yUndoPlugin(options));
79
- }
80
-
81
- // src/yjs/yjs-commands.ts
82
- var commands = {
83
- undo: () => undo,
84
- redo: () => redo
4
+ //#region src/yjs/yjs-commands.ts
5
+ const commands = {
6
+ undo: () => undoCommand,
7
+ redo: () => redoCommand
85
8
  };
86
9
  function defineYjsCommands() {
87
- return defineCommands(commands);
10
+ return defineCommands(commands);
88
11
  }
89
12
 
90
- // src/yjs/yjs-cursor-plugin.ts
91
- import {
92
- definePlugin as definePlugin2
93
- } from "@prosekit/core";
94
- import { yCursorPlugin } from "y-prosemirror";
13
+ //#endregion
14
+ //#region src/yjs/yjs-cursor-plugin.ts
95
15
  function defineYjsCursorPlugin(options) {
96
- const { awareness, ...rest } = options;
97
- return definePlugin2(yCursorPlugin(awareness, rest));
16
+ const { awareness,...rest } = options;
17
+ return definePlugin(yCursorPlugin(awareness, rest));
98
18
  }
99
19
 
100
- // src/yjs/yjs-keymap.ts
101
- import {
102
- defineKeymap,
103
- isApple
104
- } from "@prosekit/core";
105
- var keymap = {
106
- "Mod-z": undo,
107
- "Shift-Mod-z": redo
20
+ //#endregion
21
+ //#region src/yjs/yjs-keymap.ts
22
+ const keymap = {
23
+ "Mod-z": undoCommand,
24
+ "Shift-Mod-z": redoCommand
108
25
  };
109
- if (!isApple) {
110
- keymap["Mod-y"] = redo;
111
- }
26
+ if (!isApple) keymap["Mod-y"] = redoCommand;
112
27
  function defineYjsKeymap() {
113
- return defineKeymap(keymap);
28
+ return defineKeymap(keymap);
114
29
  }
115
30
 
116
- // src/yjs/yjs-sync-plugin.ts
117
- import {
118
- definePlugin as definePlugin3
119
- } from "@prosekit/core";
120
- import { ySyncPlugin } from "y-prosemirror";
31
+ //#endregion
32
+ //#region src/yjs/yjs-sync-plugin.ts
121
33
  function defineYjsSyncPlugin(options) {
122
- const { fragment, ...rest } = options;
123
- return definePlugin3(ySyncPlugin(fragment, rest));
34
+ const { fragment,...rest } = options;
35
+ return definePlugin(ySyncPlugin(fragment, rest));
124
36
  }
125
37
 
126
- // src/yjs/yjs.ts
38
+ //#endregion
39
+ //#region src/yjs/yjs-undo-plugin.ts
40
+ /**
41
+ * @see https://github.com/yjs/y-prosemirror/issues/114 and https://github.com/yjs/y-prosemirror/issues/102
42
+ */
43
+ function fixYUndoPlugin(yUndoPluginInstance) {
44
+ const originalUndoPluginView = yUndoPluginInstance.spec.view;
45
+ yUndoPluginInstance.spec.view = (view) => {
46
+ const pluginState = yUndoPluginKey.getState(view.state);
47
+ if (!pluginState) return {};
48
+ const undoManager = pluginState.undoManager;
49
+ if (undoManager.restore) {
50
+ undoManager.restore();
51
+ undoManager.restore = () => {};
52
+ }
53
+ const viewRet = originalUndoPluginView ? originalUndoPluginView(view) : void 0;
54
+ return { destroy: () => {
55
+ const hasUndoManSelf = undoManager.trackedOrigins.has(undoManager);
56
+ const observers = undoManager._observers;
57
+ undoManager.restore = () => {
58
+ if (hasUndoManSelf) undoManager.trackedOrigins.add(undoManager);
59
+ undoManager.doc.on("afterTransaction", undoManager.afterTransactionHandler);
60
+ undoManager._observers = observers;
61
+ };
62
+ if (viewRet?.destroy) viewRet.destroy();
63
+ } };
64
+ };
65
+ }
66
+ /**
67
+ * @internal
68
+ */
69
+ function yUndoPlugin$1(options) {
70
+ const yUndoPluginInstance = yUndoPlugin(options);
71
+ fixYUndoPlugin(yUndoPluginInstance);
72
+ return yUndoPluginInstance;
73
+ }
74
+ /**
75
+ * @internal
76
+ */
77
+ function defineYjsUndoPlugin(options) {
78
+ return definePlugin(yUndoPlugin$1(options));
79
+ }
80
+
81
+ //#endregion
82
+ //#region src/yjs/yjs.ts
83
+ /**
84
+ * @public
85
+ */
127
86
  function defineYjs(options) {
128
- const { doc, awareness, sync, undo: undo2, cursor } = options;
129
- const fragment = options.fragment ?? doc.getXmlFragment("prosemirror");
130
- return withPriority(
131
- union([
132
- defineYjsKeymap(),
133
- defineYjsCommands(),
134
- defineYjsCursorPlugin({ ...cursor, awareness }),
135
- defineYjsUndoPlugin({ ...undo2 }),
136
- defineYjsSyncPlugin({ ...sync, fragment })
137
- ]),
138
- Priority.high
139
- );
87
+ const { doc, awareness, sync, undo, cursor } = options;
88
+ const fragment = options.fragment ?? doc.getXmlFragment("prosemirror");
89
+ return withPriority(union([
90
+ defineYjsKeymap(),
91
+ defineYjsCommands(),
92
+ defineYjsCursorPlugin({
93
+ ...cursor,
94
+ awareness
95
+ }),
96
+ defineYjsUndoPlugin({ ...undo }),
97
+ defineYjsSyncPlugin({
98
+ ...sync,
99
+ fragment
100
+ })
101
+ ]), Priority.high);
140
102
  }
141
- export {
142
- defineYjs,
143
- defineYjsCommands,
144
- defineYjsCursorPlugin,
145
- defineYjsKeymap,
146
- defineYjsSyncPlugin,
147
- defineYjsUndoPlugin
148
- };
103
+
104
+ //#endregion
105
+ export { defineYjs, defineYjsCommands, defineYjsCursorPlugin, defineYjsKeymap, defineYjsSyncPlugin, defineYjsUndoPlugin };
@@ -1 +1 @@
1
- export {};
1
+ export { };
@@ -1,13 +1,13 @@
1
- /* src/search/style.css */
2
1
  .ProseMirror-search-match {
3
2
  background-color: #ffff0054;
4
- box-shadow: 0 0 0 2px #ffff0054;
5
3
  border-radius: 2px;
4
+ box-shadow: 0 0 0 2px #ffff0054;
6
5
  }
7
- .ProseMirror.ProseMirror-focused .ProseMirror-active-search-match::selection,
8
- .ProseMirror:not(.ProseMirror-focused) .ProseMirror-active-search-match {
6
+
7
+ .ProseMirror.ProseMirror-focused .ProseMirror-active-search-match::selection, .ProseMirror:not(.ProseMirror-focused) .ProseMirror-active-search-match {
9
8
  background-color: #ff6a0054;
10
- box-shadow: 0 0 0 2px #ff6a0054;
11
9
  border-radius: 2px;
12
10
  scroll-margin: 8px;
11
+ box-shadow: 0 0 0 2px #ff6a0054;
13
12
  }
13
+
File without changes
@@ -0,0 +1,19 @@
1
+ import { BundledHighlighterOptions, BundledLanguage, BundledTheme, Highlighter, SpecialLanguage } from "shiki";
2
+
3
+ //#region src/code-block/shiki-highlighter-chunk.d.ts
4
+ interface ShikiHighlighterOptions extends BundledHighlighterOptions<BundledLanguage, BundledTheme> {}
5
+ interface HighlighterOptions extends Omit<ShikiHighlighterOptions, "langs" | "themes"> {
6
+ themes: BundledTheme[];
7
+ langs: (BundledLanguage | SpecialLanguage)[];
8
+ }
9
+ type HighlighterResult = {
10
+ highlighter: Highlighter;
11
+ promise?: undefined;
12
+ } | {
13
+ highlighter?: undefined;
14
+ promise: Promise<void>;
15
+ };
16
+ declare function createOrGetHighlighter(options: HighlighterOptions): HighlighterResult;
17
+
18
+ //#endregion
19
+ export { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter };
@@ -0,0 +1,2 @@
1
+ import { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter } from "./shiki-highlighter-chunk-Cd3WeOKL.js";
2
+ export { HighlighterOptions, HighlighterResult, ShikiHighlighterOptions, createOrGetHighlighter };
@@ -1,48 +1,41 @@
1
- // src/code-block/shiki-highlighter-chunk.ts
2
1
  import { createHighlighter } from "shiki/bundle/full";
3
2
  import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
4
- var highlighter;
5
- var loadedLangs = /* @__PURE__ */ new Set();
6
- var loadedThemes = /* @__PURE__ */ new Set();
7
- async function createAndCacheHighlighter({
8
- ...options
9
- }) {
10
- if (!highlighter) {
11
- if (!options.engine) {
12
- const engine = createJavaScriptRegexEngine({ forgiving: true });
13
- options.engine = engine;
14
- }
15
- highlighter = await createHighlighter(options);
16
- }
3
+
4
+ //#region src/code-block/shiki-highlighter-chunk.ts
5
+ let highlighter;
6
+ const loadedLangs = new Set();
7
+ const loadedThemes = new Set();
8
+ async function createAndCacheHighlighter({ ...options }) {
9
+ if (!highlighter) {
10
+ if (!options.engine) {
11
+ const engine = createJavaScriptRegexEngine({ forgiving: true });
12
+ options.engine = engine;
13
+ }
14
+ highlighter = await createHighlighter(options);
15
+ }
17
16
  }
18
17
  async function loadLanguages(langs) {
19
- for (const lang of langs) {
20
- if (!highlighter) break;
21
- await highlighter.loadLanguage(lang);
22
- loadedLangs.add(lang);
23
- }
18
+ for (const lang of langs) {
19
+ if (!highlighter) break;
20
+ await highlighter.loadLanguage(lang);
21
+ loadedLangs.add(lang);
22
+ }
24
23
  }
25
24
  async function loadThemes(themes) {
26
- for (const theme of themes) {
27
- if (!highlighter) break;
28
- await highlighter.loadTheme(theme);
29
- loadedThemes.add(theme);
30
- }
25
+ for (const theme of themes) {
26
+ if (!highlighter) break;
27
+ await highlighter.loadTheme(theme);
28
+ loadedThemes.add(theme);
29
+ }
31
30
  }
32
31
  function createOrGetHighlighter(options) {
33
- if (!highlighter) {
34
- return { promise: createAndCacheHighlighter(options) };
35
- }
36
- const langs = options.langs.filter((lang) => !loadedLangs.has(lang));
37
- if (langs.length > 0) {
38
- return { promise: loadLanguages(langs) };
39
- }
40
- const themes = options.themes.filter((theme) => !loadedThemes.has(theme));
41
- if (themes.length > 0) {
42
- return { promise: loadThemes(themes) };
43
- }
44
- return { highlighter };
32
+ if (!highlighter) return { promise: createAndCacheHighlighter(options) };
33
+ const langs = options.langs.filter((lang) => !loadedLangs.has(lang));
34
+ if (langs.length > 0) return { promise: loadLanguages(langs) };
35
+ const themes = options.themes.filter((theme) => !loadedThemes.has(theme));
36
+ if (themes.length > 0) return { promise: loadThemes(themes) };
37
+ return { highlighter };
45
38
  }
46
- export {
47
- createOrGetHighlighter
48
- };
39
+
40
+ //#endregion
41
+ export { createOrGetHighlighter };
@@ -1,41 +1,42 @@
1
- /* src/table/style.css */
2
1
  .ProseMirror .tableWrapper {
3
2
  overflow-x: auto;
4
3
  }
4
+
5
5
  .ProseMirror table {
6
6
  border-collapse: collapse;
7
7
  table-layout: fixed;
8
8
  width: 100%;
9
9
  overflow: hidden;
10
10
  }
11
- .ProseMirror td,
12
- .ProseMirror th {
13
- vertical-align: top;
11
+
12
+ .ProseMirror td, .ProseMirror th {
14
13
  box-sizing: border-box;
15
- position: relative;
14
+ vertical-align: top;
16
15
  border-width: 1px;
17
- padding-left: 0.75rem;
18
- padding-right: 0.75rem;
16
+ padding-left: .75rem;
17
+ padding-right: .75rem;
18
+ position: relative;
19
19
  }
20
+
20
21
  .ProseMirror .column-resize-handle {
22
+ z-index: 20;
23
+ pointer-events: none;
24
+ background-color: highlighttext;
25
+ width: 4px;
21
26
  position: absolute;
22
- right: -2px;
23
27
  top: 0;
24
28
  bottom: 0;
25
- width: 4px;
26
- z-index: 20;
27
- background-color: HighlightText;
28
- pointer-events: none;
29
+ right: -2px;
29
30
  }
31
+
30
32
  .ProseMirror.resize-cursor {
31
33
  cursor: ew-resize;
32
34
  cursor: col-resize;
33
35
  }
36
+
34
37
  .ProseMirror .selectedCell {
35
- --color:
36
- 210,
37
- 100%,
38
- 56%;
39
- background-color: hsla(var(--color), 20%);
38
+ --color: 210, 100%, 56%;
40
39
  border: 1px double hsl(var(--color));
40
+ background-color: hsla(var(--color), 20%);
41
41
  }
42
+
File without changes