@prosekit/extensions 0.0.0-next-20230709094459 → 0.0.0-next-20240421132240

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 (52) hide show
  1. package/dist/_tsup-dts-rollup.d.ts +889 -0
  2. package/dist/chunk-ASTUC4KT.js +111 -0
  3. package/dist/chunk-DYFRBXUX.js +56 -0
  4. package/dist/list/style.css +18 -13
  5. package/dist/prosekit-extensions-autocomplete.d.ts +3 -0
  6. package/dist/prosekit-extensions-autocomplete.js +194 -0
  7. package/dist/prosekit-extensions-blockquote.d.ts +3 -11
  8. package/dist/prosekit-extensions-blockquote.js +24 -15
  9. package/dist/prosekit-extensions-bold.d.ts +4 -20
  10. package/dist/prosekit-extensions-bold.js +35 -37
  11. package/dist/prosekit-extensions-code-block.d.ts +15 -0
  12. package/dist/prosekit-extensions-code-block.js +214 -0
  13. package/dist/prosekit-extensions-code.d.ts +4 -16
  14. package/dist/prosekit-extensions-code.js +28 -12
  15. package/dist/prosekit-extensions-drop-cursor.d.ts +2 -0
  16. package/dist/prosekit-extensions-drop-cursor.js +9 -0
  17. package/dist/prosekit-extensions-enter-rule.d.ts +5 -0
  18. package/dist/prosekit-extensions-enter-rule.js +8 -0
  19. package/dist/prosekit-extensions-heading.d.ts +6 -15
  20. package/dist/prosekit-extensions-heading.js +75 -41
  21. package/dist/prosekit-extensions-image.d.ts +4 -0
  22. package/dist/prosekit-extensions-image.js +49 -0
  23. package/dist/prosekit-extensions-input-rule.d.ts +3 -0
  24. package/dist/prosekit-extensions-input-rule.js +10 -0
  25. package/dist/prosekit-extensions-italic.d.ts +4 -20
  26. package/dist/prosekit-extensions-italic.js +29 -31
  27. package/dist/prosekit-extensions-link.d.ts +6 -0
  28. package/dist/prosekit-extensions-link.js +102 -0
  29. package/dist/prosekit-extensions-list.d.ts +7 -14
  30. package/dist/prosekit-extensions-list.js +59 -24
  31. package/dist/prosekit-extensions-mention.d.ts +4 -0
  32. package/dist/prosekit-extensions-mention.js +56 -0
  33. package/dist/prosekit-extensions-placeholder.d.ts +2 -23
  34. package/dist/prosekit-extensions-placeholder.js +11 -7
  35. package/dist/prosekit-extensions-readonly.d.ts +1 -0
  36. package/dist/prosekit-extensions-readonly.js +16 -0
  37. package/dist/prosekit-extensions-strike.d.ts +4 -0
  38. package/dist/prosekit-extensions-strike.js +47 -0
  39. package/dist/prosekit-extensions-table.d.ts +7 -0
  40. package/dist/prosekit-extensions-table.js +197 -0
  41. package/dist/prosekit-extensions-underline.d.ts +4 -0
  42. package/dist/prosekit-extensions-underline.js +45 -0
  43. package/dist/prosekit-extensions-virtual-selection.d.ts +1 -0
  44. package/dist/prosekit-extensions-virtual-selection.js +58 -0
  45. package/dist/prosekit-extensions.d.ts +1 -2
  46. package/dist/shiki-import-25BJYIO2.js +5 -0
  47. package/dist/table/style.css +34 -0
  48. package/dist/virtual-selection/style.css +6 -0
  49. package/package.json +119 -13
  50. package/dist/prosekit-extensions-suggestion.d.ts +0 -37
  51. package/dist/prosekit-extensions-suggestion.js +0 -159
  52. package/src/index.ts +0 -1
@@ -0,0 +1,102 @@
1
+ import {
2
+ defineInputRule
3
+ } from "./chunk-DYFRBXUX.js";
4
+ import {
5
+ defineEnterRule
6
+ } from "./chunk-ASTUC4KT.js";
7
+
8
+ // src/link/index.ts
9
+ import {
10
+ addMark,
11
+ defineCommands,
12
+ defineMarkSpec,
13
+ expandMark,
14
+ removeMark,
15
+ toggleMark,
16
+ union
17
+ } from "@prosekit/core";
18
+ import { InputRule } from "@prosekit/pm/inputrules";
19
+
20
+ // src/link/link-regex.ts
21
+ var TLD_RE_PATTERN = "a(?:a(?:a|rp)|b(?:arth|b(?:ott|vie)?|c|le|ogado|udhabi)|c(?:ademy|c(?:enture|ountants?)|o|tor)?|d(?:s|ult)?|e(?:g|ro|tna)?|f(?:l|rica)?|g(?:akhan|ency)?|i(?:g|r(?:bus|force|tel))?|kdn|l(?:faromeo|i(?:baba|pay)|l(?:finanz|state|y)|s(?:ace|tom))?|m(?:azon|e(?:rican(?:express|family)|x)|fam|ica|sterdam)?|n(?:alytics|droid|quan|z)|ol?|p(?:artments|p(?:le)?)|q(?:uarelle)?|r(?:a(?:b|mco)|chi|my|pa|te?)?|s(?:da|ia|sociates)?|t(?:hleta|torney)?|u(?:ction|di(?:ble|o)?|spost|t(?:hor|os?))?|vianca|ws?|xa?|z(?:ure)?)|b(?:a(?:by|idu|n(?:a(?:mex|narepublic)|d|k)|r(?:c(?:elona|lay(?:card|s))|efoot|gains)?|s(?:eball|ketball)|uhaus|yern)?|b(?:c|t|va)?|c[gn]|d|e(?:a(?:ts|uty)|er|ntley|rlin|st(?:buy)?|t)?|f|g|h(?:arti)?|i(?:ble|d|ke|ngo?|o|z)?|j|l(?:ack(?:friday)?|o(?:ckbuster|g|omberg)|ue)|m[sw]?|n(?:pparibas)?|o(?:ats|ehringer|fa|m|nd|o(?:k(?:ing)?)?|s(?:ch|t(?:ik|on))|t|utique|x)?|r(?:adesco|idgestone|o(?:adway|ker|ther)|ussels)?|s|t|u(?:ild(?:ers)?|siness|y|zz)|v|w|y|zh?)|c(?:a(?:b|fe|l(?:l|vinklein)?|m(?:era|p)?|non|p(?:etown|ital(?:one)?)|r(?:avan|ds|e(?:ers?)?|s)?|s(?:a|e|h|ino)|t(?:ering|holic)?)?|b(?:a|n|re|s)|c|d|e(?:nter|o|rn)|f[ad]?|g|h(?:a(?:n(?:el|nel)|rity|se|t)|eap|intai|r(?:istmas|ome)|urch)?|i(?:priani|rcle|sco|t(?:adel|ic?|y(?:eats)?))?|k|l(?:aims|eaning|i(?:ck|ni(?:c|que))|o(?:thing|ud)|ub(?:med)?)?|m|n|o(?:ach|des|ffee|l(?:lege|ogne)|m(?:cast|m(?:bank|unity)|p(?:a(?:ny|re)|uter)|sec)?|n(?:dos|s(?:truction|ulting)|t(?:act|ractors))|o(?:king(?:channel)?|l|p)|rsica|u(?:ntry|pons?|rses))?|pa|r(?:edit(?:card|union)?|icket|own|s|uises?)?|u(?:isinella)?|v|w|x|y(?:mru|ou)?|z)|d(?:a(?:bur|d|nce|t(?:a|e|ing|sun)|y)|clk|ds|e(?:al(?:er|s)?|gree|l(?:ivery|l|oitte|ta)|mocrat|nt(?:al|ist)|si(?:gn)?|v)?|hl|i(?:amonds|et|gital|rect(?:ory)?|s(?:co(?:unt|ver)|h)|y)|j|k|m|np|o(?:c(?:s|tor)|g|mains|t|wnload)?|rive|tv|u(?:bai|nlop|pont|rban)|v(?:ag|r)|z)|e(?:a(?:rth|t)|co?|d(?:eka|u(?:cation)?)|e|g|m(?:ail|erck)|n(?:ergy|gineer(?:ing)?|terprises)|pson|quipment|r(?:icsson|ni)?|s(?:q|tate)?|t(?:isalat)?|u(?:rovision|s)?|vents|x(?:change|p(?:ert|osed|ress)|traspace))|f(?:a(?:ge|i(?:l|rwinds|th)|mily|ns?|rm(?:ers)?|s(?:hion|t))|e(?:dex|edback|rr(?:ari|ero))|i(?:at|d(?:elity|o)|lm|na(?:l|nc(?:e|ial))|r(?:e(?:stone)?|mdale)|sh(?:ing)?|t(?:ness)?)?|j|k|l(?:i(?:ckr|ghts|r)|o(?:rist|wers)|y)|m|o(?:o(?:d(?:network)?|tball)?|r(?:d|ex|sale|um)|undation|x)?|r(?:e(?:e|senius)|l|o(?:gans|nt(?:door|ier)))?|tr|u(?:jitsu|nd?|rniture|tbol)|yi)|g(?:a(?:l(?:l(?:ery|o|up))?|mes?|p|rden|y)?|b(?:iz)?|dn?|e(?:a|nt(?:ing)?|orge)?|f|g(?:ee)?|h|i(?:fts?|v(?:es|ing))?|l(?:ass|e|ob(?:al|o))?|m(?:ail|bh|o|x)?|n|o(?:daddy|l(?:d(?:point)?|f)|o(?:dyear|g(?:le)?)?|p|t|v)|p|q|r(?:a(?:inger|phics|tis)|een|ipe|o(?:cery|up))?|s|t|u(?:ardian|cci|ge|i(?:de|tars)|ru)?|w|y)|h(?:a(?:ir|mburg|ngout|us)|bo|dfc(?:bank)?|e(?:alth(?:care)?|l(?:p|sinki)|r(?:e|mes))|gtv|i(?:phop|samitsu|tachi|v)|kt?|m|n|o(?:ckey|l(?:dings|iday)|me(?:depot|goods|s(?:ense)?)|nda|rse|s(?:pital|t(?:ing)?)|t(?:el(?:es|s)|mail)?|use|w)|r|sbc|t|u(?:ghes)?|y(?:att|undai))|i(?:bm|c(?:bc|e|u)|d|e(?:ee)?|fm|kano|l|m(?:amat|db|mo(?:bilien)?)?|n(?:c|dustries|f(?:initi|o)|g|k|s(?:titute|ur(?:ance|e))|t(?:ernational|uit)?|vestments)?|o|piranga|q|r(?:ish)?|s(?:maili|t(?:anbul)?)?|t(?:au|v)?)|j(?:a(?:guar|va)|cb|e(?:ep|tzt|welry)?|io|ll|mp?|nj|o(?:b(?:s|urg)|t|y)?|p(?:morgan|rs)?|u(?:egos|niper))|k(?:aufen|ddi|e(?:rry(?:hotels|logistics|properties))?|fh|g|h|i(?:a|ds|m|nd(?:er|le)|tchen|wi)?|m|n|o(?:eln|matsu|sher)|p(?:mg|n)?|r(?:d|ed)?|uokgroup|w|y(?:oto)?|z)|l(?:a(?:caixa|m(?:borghini|er)|n(?:c(?:aster|ia)|d(?:rover)?|xess)|salle|t(?:ino|robe)?|w(?:yer)?)?|b|c|ds|e(?:ase|clerc|frak|g(?:al|o)|xus)|gbt|i(?:dl|fe(?:insurance|style)?|ghting|ke|lly|m(?:ited|o)|n(?:coln|de|k)|psy|v(?:e|ing))?|k|l[cp]|o(?:ans?|c(?:ker|us)|l|ndon|tt[eo]|ve)|pl(?:financial)?|r|s|t(?:da?)?|u(?:ndbeck|x(?:e|ury))?|v|y)|m(?:a(?:cys|drid|i(?:f|son)|keup|n(?:agement|go)?|p|r(?:ket(?:ing|s)?|riott|shalls)|serati|ttel)?|ba|c(?:kinsey)?|d|e(?:d(?:ia)?|et|lbourne|m(?:e|orial)|nu?|rckmsd)?|g|h|i(?:ami|crosoft|l|n[it]|t(?:subishi)?)|k|l[bs]?|ma?|n|o(?:bi(?:le)?|da|e|i|m|n(?:ash|ey|ster)|r(?:mon|tgage)|scow|to(?:rcycles)?|v(?:ie)?)?|p|q|r|sd?|t[nr]?|u(?:s(?:eum|ic)|tual)?|v|w|x|y|z)|n(?:a(?:b|goya|me|tura|vy)?|ba|c|e(?:c|t(?:bank|flix|work)?|ustar|ws?|x(?:t(?:direct)?|us))?|fl?|go?|hk|i(?:co|k(?:e|on)|nja|ssa[ny])?|l|o(?:kia|rt(?:hwesternmutual|on)|w(?:ruz|tv)?)?|p|r[aw]?|tt|u|yc|z)|o(?:b(?:i|server)|ffice|kinawa|l(?:ayan(?:group)?|dnavy|lo)|m(?:ega)?|n(?:e|g|l(?:ine)?)|oo|pen|r(?:a(?:cle|nge)|g(?:anic)?|igins)|saka|t(?:suka|t)|vh)|p(?:a(?:ge|nasonic|r(?:is|s|t(?:ners|s|y))|ssagens|y)?|ccw|et?|f(?:izer)?|g|h(?:armacy|d|ilips|o(?:ne|to(?:graphy|s)?)|ysio)?|i(?:c(?:s|t(?:et|ures))|d|n[gk]?|oneer|zza)|k|l(?:a(?:ce|y(?:station)?)|u(?:mbing|s))?|m|nc?|o(?:hl|ker|litie|rn|st)|r(?:a(?:merica|xi)|ess|ime|o(?:d(?:uctions)?|f|gressive|mo|pert(?:ies|y)|tection)?|u(?:dential)?)?|s|t|ub|wc?|y)|q(?:a|pon|ue(?:bec|st))|r(?:a(?:cing|dio)|e(?:a(?:d|l(?:estate|t(?:or|y)))|cipes|d(?:stone|umbrella)?|hab|i(?:sen?|t)|liance|n(?:t(?:als)?)?|p(?:air|ort|ublican)|st(?:aurant)?|views?|xroth)?|i(?:c(?:h(?:ardli)?|oh)|l|o|p)|o(?:c(?:her|ks)|deo|gers|om)?|s(?:vp)?|u(?:gby|hr|n)?|we?|yukyu)|s(?:a(?:arland|fe(?:ty)?|kura|l(?:e|on)|ms(?:club|ung)|n(?:dvik(?:coromant)?|ofi)|p|rl|s|ve|xo)?|b[is]?|c(?:a|b|h(?:aeffler|midt|o(?:larships|ol)|ule|warz)|ience|ot)?|d|e(?:a(?:rch|t)|cur(?:e|ity)|ek|lect|ner|rvices|ven|w|xy?)?|fr|g|h(?:a(?:ngrila|rp|w)|ell|i(?:a|ksha)|o(?:es|p(?:ping)?|uji|w(?:time)?))?|i(?:lk|n(?:a|gles)|te)?|j|k(?:in?|y(?:pe)?)?|l(?:ing)?|m(?:art|ile)?|n(?:cf)?|o(?:c(?:cer|ial)|ft(?:bank|ware)|hu|l(?:ar|utions)|n[gy]|y)?|p(?:a(?:ce)?|o(?:rt|t))|rl?|s|t(?:a(?:da|ples|r|te(?:bank|farm))|c(?:group)?|o(?:ckholm|r(?:age|e))|ream|ud(?:io|y)|yle)?|u(?:cks|pp(?:l(?:ies|y)|ort)|r(?:f|gery)|zuki)?|v|w(?:atch|iss)|x|y(?:dney|stems)?|z)|t(?:a(?:b|ipei|lk|obao|rget|t(?:a(?:motors|r)|too)|xi?)|ci?|dk?|e(?:am|ch(?:nology)?|l|masek|nnis|va)|f|g|h(?:d|eat(?:er|re))?|i(?:aa|ckets|enda|ffany|ps|r(?:es|ol))|j(?:maxx|x)?|k(?:maxx)?|l|m(?:all)?|n|o(?:day|kyo|ols|p|ray|shiba|tal|urs|wn|y(?:ota|s))?|r(?:a(?:d(?:e|ing)|ining|vel(?:channel|ers(?:insurance)?)?)|ust|v)?|t|u(?:be|i|nes|shu)|vs?|w|z)|u(?:a|b(?:ank|s)|g|k|n(?:i(?:com|versity)|o)|ol|ps|s|y|z)|v(?:a(?:cations|n(?:a|guard))?|c|e(?:gas|ntures|r(?:isign|sicherung)|t)?|g|i(?:ajes|deo|g|king|llas|n|p|rgin|s(?:a|ion)|v[ao])?|laanderen|n|o(?:dka|l(?:kswagen|vo)|t(?:e|ing|o)|yage)|u(?:elos)?)|w(?:a(?:l(?:es|mart|ter)|ng(?:gou)?|tch(?:es)?)|e(?:ather(?:channel)?|b(?:cam|er|site)|d(?:ding)?|i(?:bo|r))|f|hoswho|i(?:en|ki|lliamhill|n(?:dows|e|ners)?)|me|o(?:lterskluwer|odside|r(?:ks?|ld)|w)|s|t[cf])|x(?:box|erox|finity|i(?:huan|n)|xx|yz)|y(?:a(?:chts|hoo|maxun|ndex)|e|o(?:dobashi|ga|kohama|u(?:tube)?)|t|un)|z(?:a(?:ppos|ra)?|ero|ip|m|one|uerich|w)";
22
+ var LINK_RE_BASE_PATTERN = (
23
+ // start of the link group
24
+ "((?:(?:(?:https?:)?\\/\\/)?(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:" + TLD_RE_PATTERN + "))(?::\\d{2,5})?(?:[/?#]\\S*)?)"
25
+ );
26
+ var LINK_STOP_PATTERN = "(?:\\.|\\,|\\;\\!)?";
27
+ var LINK_RE_PATTERN = LINK_RE_BASE_PATTERN + LINK_STOP_PATTERN + "$";
28
+ var LINK_SPACE_RE_PATTERN = LINK_RE_BASE_PATTERN + LINK_STOP_PATTERN + "\\s$";
29
+ var LINK_RE = new RegExp(LINK_RE_PATTERN, "gi");
30
+ var LINK_SPACE_RE = new RegExp(LINK_SPACE_RE_PATTERN, "gi");
31
+
32
+ // src/link/index.ts
33
+ function defineLinkSpec() {
34
+ return defineMarkSpec({
35
+ name: "link",
36
+ inclusive: false,
37
+ parseDOM: [
38
+ {
39
+ tag: "a[href]",
40
+ getAttrs: (dom) => {
41
+ return {
42
+ href: dom.getAttribute("href")
43
+ };
44
+ }
45
+ }
46
+ ],
47
+ attrs: {
48
+ href: {}
49
+ },
50
+ toDOM(node) {
51
+ const { href } = node.attrs;
52
+ return ["a", { href }, 0];
53
+ }
54
+ });
55
+ }
56
+ function defineLinkCommands() {
57
+ return defineCommands({
58
+ addLink: (attrs) => addMark({ type: "link", attrs }),
59
+ removeLink: () => removeMark({ type: "link" }),
60
+ toggleLink: (attrs) => toggleMark({ type: "link", attrs }),
61
+ expandLink: () => expandMark({ type: "link" })
62
+ });
63
+ }
64
+ function defineLinkInputRule() {
65
+ return defineInputRule(
66
+ new InputRule(LINK_SPACE_RE, (state, match, from) => {
67
+ const href = match[1];
68
+ if (!href)
69
+ return null;
70
+ const mark = state.schema.marks.link.create({ href });
71
+ return state.tr.addMark(from, from + href.length, mark).insertText(" ");
72
+ })
73
+ );
74
+ }
75
+ function defineLinkEnterRule() {
76
+ return defineEnterRule({
77
+ regex: LINK_RE,
78
+ handler: ({ state, from, match }) => {
79
+ const href = match[1];
80
+ if (!href)
81
+ return null;
82
+ const mark = state.schema.marks.link.create({ href });
83
+ const tr = state.tr.addMark(from, from + href.length, mark);
84
+ return tr.docChanged ? tr : null;
85
+ }
86
+ });
87
+ }
88
+ function defineLink() {
89
+ return union([
90
+ defineLinkSpec(),
91
+ defineLinkCommands(),
92
+ defineLinkInputRule(),
93
+ defineLinkEnterRule()
94
+ ]);
95
+ }
96
+ export {
97
+ defineLink,
98
+ defineLinkCommands,
99
+ defineLinkEnterRule,
100
+ defineLinkInputRule,
101
+ defineLinkSpec
102
+ };
@@ -1,14 +1,7 @@
1
- import * as _prosekit_core from '@prosekit/core';
2
-
3
- declare function addListSpec(): _prosekit_core.Extension<{
4
- NODES: "list";
5
- }>;
6
- declare function addListPlugins(): _prosekit_core.Extension<_prosekit_core.ExtensionTyping<string, string, _prosekit_core.CommandArgs>>;
7
- declare function addListKeymap(): _prosekit_core.Extension<_prosekit_core.ExtensionTyping<string, string, _prosekit_core.CommandArgs>>;
8
- declare function addListInputRules(): _prosekit_core.Extension<_prosekit_core.ExtensionTyping<string, string, _prosekit_core.CommandArgs>>;
9
- /** @public */
10
- declare function addList(): _prosekit_core.Extension<{
11
- NODES: "list";
12
- }>;
13
-
14
- export { addList, addListInputRules, addListKeymap, addListPlugins, addListSpec };
1
+ export { defineListSpec } from './_tsup-dts-rollup';
2
+ export { defineListPlugins } from './_tsup-dts-rollup';
3
+ export { defineListKeymap } from './_tsup-dts-rollup';
4
+ export { defineListInputRules } from './_tsup-dts-rollup';
5
+ export { defineListCommands } from './_tsup-dts-rollup';
6
+ export { defineList } from './_tsup-dts-rollup';
7
+ export { ListDOMSerializer } from './_tsup-dts-rollup';
@@ -1,41 +1,76 @@
1
+ import {
2
+ defineInputRule
3
+ } from "./chunk-DYFRBXUX.js";
4
+
1
5
  // src/list/index.ts
2
6
  import {
3
- addInputRule,
4
- addKeymap,
5
- addNodeSpec,
6
- addPlugin,
7
- defineExtension
7
+ Priority,
8
+ defineCommands,
9
+ defineKeymap,
10
+ defineNodeSpec,
11
+ definePlugin,
12
+ insertNode,
13
+ union,
14
+ withPriority
8
15
  } from "@prosekit/core";
9
16
  import {
17
+ createDedentListCommand,
18
+ createIndentListCommand,
10
19
  createListPlugins,
11
20
  createListSpec,
21
+ createMoveListCommand,
22
+ createSplitListCommand,
23
+ createToggleCollapsedCommand,
24
+ createToggleListCommand,
25
+ createUnwrapListCommand,
26
+ createWrapInListCommand,
12
27
  listInputRules,
13
28
  listKeymap
14
29
  } from "prosemirror-flat-list";
15
- function addListSpec() {
16
- return addNodeSpec({ name: "list", spec: createListSpec() });
30
+ import { ListDOMSerializer } from "prosemirror-flat-list";
31
+ function defineListSpec() {
32
+ return defineNodeSpec({ ...createListSpec(), name: "list" });
33
+ }
34
+ function defineListPlugins() {
35
+ return definePlugin(({ schema }) => createListPlugins({ schema }));
17
36
  }
18
- function addListPlugins() {
19
- return addPlugin({ plugins: ({ schema }) => createListPlugins({ schema }) });
37
+ function defineListKeymap() {
38
+ return defineKeymap(listKeymap);
20
39
  }
21
- function addListKeymap() {
22
- return addKeymap(listKeymap);
40
+ function defineListInputRules() {
41
+ return union(listInputRules.map(defineInputRule));
23
42
  }
24
- function addListInputRules() {
25
- return addInputRule(() => listInputRules);
43
+ function defineListCommands() {
44
+ return defineCommands({
45
+ dedentList: createDedentListCommand,
46
+ indentList: createIndentListCommand,
47
+ moveList: createMoveListCommand,
48
+ splitList: createSplitListCommand,
49
+ toggleCollapsed: createToggleCollapsedCommand,
50
+ toggleList: createToggleListCommand,
51
+ unwrapList: createUnwrapListCommand,
52
+ wrapInList: createWrapInListCommand,
53
+ insertList: (attrs) => {
54
+ return insertNode({ type: "list", attrs });
55
+ }
56
+ });
26
57
  }
27
- function addList() {
28
- return defineExtension([
29
- addListSpec(),
30
- addListPlugins(),
31
- addListKeymap(),
32
- addListInputRules()
58
+ function defineList() {
59
+ return union([
60
+ defineListSpec(),
61
+ defineListPlugins(),
62
+ // Use a high priority to override the default key bindings.
63
+ withPriority(defineListKeymap(), Priority.high),
64
+ defineListInputRules(),
65
+ defineListCommands()
33
66
  ]);
34
67
  }
35
68
  export {
36
- addList,
37
- addListInputRules,
38
- addListKeymap,
39
- addListPlugins,
40
- addListSpec
69
+ ListDOMSerializer,
70
+ defineList,
71
+ defineListCommands,
72
+ defineListInputRules,
73
+ defineListKeymap,
74
+ defineListPlugins,
75
+ defineListSpec
41
76
  };
@@ -0,0 +1,4 @@
1
+ export { defineMentionSpec } from './_tsup-dts-rollup';
2
+ export { defineMentionCommands } from './_tsup-dts-rollup';
3
+ export { defineMention } from './_tsup-dts-rollup';
4
+ export { MentionAttrs } from './_tsup-dts-rollup';
@@ -0,0 +1,56 @@
1
+ // src/mention/index.ts
2
+ import {
3
+ defineCommands,
4
+ defineNodeSpec,
5
+ insertNode,
6
+ union
7
+ } from "@prosekit/core";
8
+ function defineMentionSpec() {
9
+ return defineNodeSpec({
10
+ name: "mention",
11
+ atom: true,
12
+ group: "inline",
13
+ attrs: {
14
+ id: {},
15
+ value: {},
16
+ kind: { default: "" }
17
+ },
18
+ inline: true,
19
+ leafText: (node) => node.attrs.value.toString(),
20
+ parseDOM: [
21
+ {
22
+ tag: `span[data-mention]`,
23
+ getAttrs: (dom) => ({
24
+ id: dom.getAttribute("data-id") || "",
25
+ kind: dom.getAttribute("data-mention") || "",
26
+ value: dom.textContent || ""
27
+ })
28
+ }
29
+ ],
30
+ toDOM(node) {
31
+ return [
32
+ "span",
33
+ {
34
+ "data-id": node.attrs.id.toString(),
35
+ "data-mention": node.attrs.kind.toString()
36
+ },
37
+ node.attrs.value.toString()
38
+ ];
39
+ }
40
+ });
41
+ }
42
+ function defineMentionCommands() {
43
+ return defineCommands({
44
+ insertMention: (attrs) => {
45
+ return insertNode({ type: "mention", attrs });
46
+ }
47
+ });
48
+ }
49
+ function defineMention() {
50
+ return union([defineMentionSpec(), defineMentionCommands()]);
51
+ }
52
+ export {
53
+ defineMention,
54
+ defineMentionCommands,
55
+ defineMentionSpec
56
+ };
@@ -1,23 +1,2 @@
1
- import * as _prosekit_core from '@prosekit/core';
2
-
3
- interface PlaceholderOptions {
4
- /**
5
- * The placeholder text to use.
6
- */
7
- placeholder: string;
8
- /**
9
- * By default, the placeholder text will be shown whenever the current text
10
- * cursor is in an empty node. If you only want to show the placeholder when
11
- * the whole doc is empty, you can set this option to 'doc'.
12
- *
13
- * @default 'block'
14
- */
15
- strategy?: 'doc' | 'block';
16
- }
17
- /**
18
- * Add a placeholder text to the editor when the current block or document is
19
- * empty.
20
- */
21
- declare function addPlaceholder(options: PlaceholderOptions): _prosekit_core.Extension<_prosekit_core.ExtensionTyping<string, string, _prosekit_core.CommandArgs>>;
22
-
23
- export { PlaceholderOptions, addPlaceholder };
1
+ export { definePlaceholder } from './_tsup-dts-rollup';
2
+ export { PlaceholderOptions } from './_tsup-dts-rollup';
@@ -1,19 +1,22 @@
1
1
  // src/placeholder/index.ts
2
- import { addPlugin } from "@prosekit/core";
3
- import { Plugin } from "@prosekit/pm/state";
2
+ import { definePlugin, isInCodeBlock } from "@prosekit/core";
3
+ import "@prosekit/pm/model";
4
+ import { Plugin, PluginKey } from "@prosekit/pm/state";
4
5
  import { Decoration, DecorationSet } from "@prosekit/pm/view";
5
- function addPlaceholder(options) {
6
- return addPlugin({
7
- plugins: [createPlaceholderPlugin(options)]
8
- });
6
+ function definePlaceholder(options) {
7
+ return definePlugin(createPlaceholderPlugin(options));
9
8
  }
10
9
  function createPlaceholderPlugin(options) {
11
10
  return new Plugin({
11
+ key: placeholderPluginKey,
12
12
  props: {
13
13
  decorations: (state) => {
14
14
  if (options.strategy === "doc" && !isDocEmpty(state.doc)) {
15
15
  return null;
16
16
  }
17
+ if (isInCodeBlock(state.selection)) {
18
+ return null;
19
+ }
17
20
  const placeholderText = options.placeholder;
18
21
  const deco = createPlaceholderDecoration(state, placeholderText);
19
22
  if (!deco) {
@@ -24,6 +27,7 @@ function createPlaceholderPlugin(options) {
24
27
  }
25
28
  });
26
29
  }
30
+ var placeholderPluginKey = new PluginKey("prosekit-placeholder");
27
31
  function isDocEmpty(doc) {
28
32
  var _a;
29
33
  return doc.childCount <= 1 && !((_a = doc.firstChild) == null ? void 0 : _a.content.size);
@@ -43,5 +47,5 @@ function createPlaceholderDecoration(state, placeholderText) {
43
47
  });
44
48
  }
45
49
  export {
46
- addPlaceholder
50
+ definePlaceholder
47
51
  };
@@ -0,0 +1 @@
1
+ export { defineReadonly } from './_tsup-dts-rollup';
@@ -0,0 +1,16 @@
1
+ // src/readonly/index.ts
2
+ import { definePlugin } from "@prosekit/core";
3
+ import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state";
4
+ function defineReadonly() {
5
+ return definePlugin(plugin);
6
+ }
7
+ var key = new PluginKey("readonly");
8
+ var plugin = new ProseMirrorPlugin({
9
+ key,
10
+ props: {
11
+ editable: () => false
12
+ }
13
+ });
14
+ export {
15
+ defineReadonly
16
+ };
@@ -0,0 +1,4 @@
1
+ export { defineStrikeSpec } from './_tsup-dts-rollup';
2
+ export { defineStrikeCommands } from './_tsup-dts-rollup';
3
+ export { defineStrikeKeymap } from './_tsup-dts-rollup';
4
+ export { defineStrike } from './_tsup-dts-rollup';
@@ -0,0 +1,47 @@
1
+ // src/strike/index.ts
2
+ import {
3
+ defineCommands,
4
+ defineKeymap,
5
+ defineMarkSpec,
6
+ union,
7
+ toggleMark
8
+ } from "@prosekit/core";
9
+ function defineStrikeSpec() {
10
+ return defineMarkSpec({
11
+ name: "strike",
12
+ parseDOM: [
13
+ { tag: "s" },
14
+ { tag: "strike" },
15
+ { tag: "del" },
16
+ { style: "text-decoration=line-through" },
17
+ { style: "text-decoration-line=line-through" }
18
+ ],
19
+ toDOM() {
20
+ return ["s", 0];
21
+ }
22
+ });
23
+ }
24
+ function defineStrikeCommands() {
25
+ return defineCommands({
26
+ toggleStrike: () => toggleMark({ type: "strike" })
27
+ });
28
+ }
29
+ function defineStrikeKeymap() {
30
+ return defineKeymap({
31
+ "Mod-shift-s": toggleMark({ type: "strike" }),
32
+ "Mod-shift-x": toggleMark({ type: "strike" })
33
+ });
34
+ }
35
+ function defineStrike() {
36
+ return union([
37
+ defineStrikeSpec(),
38
+ defineStrikeCommands(),
39
+ defineStrikeKeymap()
40
+ ]);
41
+ }
42
+ export {
43
+ defineStrike,
44
+ defineStrikeCommands,
45
+ defineStrikeKeymap,
46
+ defineStrikeSpec
47
+ };
@@ -0,0 +1,7 @@
1
+ export { defineTable } from './_tsup-dts-rollup';
2
+ export { defineTableCellSpec } from './_tsup-dts-rollup';
3
+ export { defineTableCommands } from './_tsup-dts-rollup';
4
+ export { defineTableHeaderCellSpec } from './_tsup-dts-rollup';
5
+ export { defineTablePlugins } from './_tsup-dts-rollup';
6
+ export { defineTableRowSpec } from './_tsup-dts-rollup';
7
+ export { defineTableSpec } from './_tsup-dts-rollup';
@@ -0,0 +1,197 @@
1
+ // src/table/index.ts
2
+ import { union } from "@prosekit/core";
3
+
4
+ // src/table/table-commands.ts
5
+ import {
6
+ defaultBlockAt,
7
+ defineCommands,
8
+ getNodeType,
9
+ insertNode
10
+ } from "@prosekit/core";
11
+ import { TextSelection } from "@prosekit/pm/state";
12
+ function createEmptyTable(schema, row, col, header) {
13
+ const table = getNodeType(schema, "table");
14
+ const tableRow = getNodeType(schema, "tableRow");
15
+ const tableCell = getNodeType(schema, "tableCell");
16
+ const tableHeaderCell = getNodeType(schema, "tableHeaderCell");
17
+ const createHeaderRow = () => {
18
+ return tableRow.createAndFill(
19
+ null,
20
+ Array.from({ length: col }, () => tableHeaderCell.createAndFill())
21
+ );
22
+ };
23
+ const createBodyRow = () => {
24
+ return tableRow.createAndFill(
25
+ null,
26
+ Array.from({ length: col }, () => tableCell.createAndFill())
27
+ );
28
+ };
29
+ const rows = [
30
+ ...Array.from({ length: header ? 1 : 0 }, createHeaderRow),
31
+ ...Array.from({ length: header ? row - 1 : row }, createBodyRow)
32
+ ];
33
+ return table.createAndFill(null, rows);
34
+ }
35
+ function insertTable({
36
+ row,
37
+ col,
38
+ header
39
+ }) {
40
+ return (state, dispatch, view) => {
41
+ const table = createEmptyTable(state.schema, row, col, header);
42
+ return insertNode({ node: table })(state, dispatch, view);
43
+ };
44
+ }
45
+ var exitTable = (state, dispatch) => {
46
+ const { $head, $anchor } = state.selection;
47
+ if (!$head.sameParent($anchor)) {
48
+ return false;
49
+ }
50
+ let tableStart = -1;
51
+ let tableDepth = -1;
52
+ for (let depth = $head.depth; depth >= 0; depth--) {
53
+ const node2 = $head.node(depth);
54
+ if (node2.type.spec.tableRole === "table") {
55
+ tableStart = $head.before(depth);
56
+ tableDepth = depth;
57
+ }
58
+ }
59
+ if (tableStart < 0 || tableDepth <= 0) {
60
+ return false;
61
+ }
62
+ const above = $head.node(tableDepth - 1);
63
+ const after = $head.indexAfter(tableDepth - 1);
64
+ const type = defaultBlockAt(above.contentMatchAt(after));
65
+ const node = type == null ? void 0 : type.createAndFill();
66
+ if (!type || !node || !above.canReplaceWith(after, after, type)) {
67
+ return false;
68
+ }
69
+ if (dispatch) {
70
+ const pos = $head.after(tableDepth);
71
+ const tr = state.tr.replaceWith(pos, pos, node);
72
+ tr.setSelection(TextSelection.near(tr.doc.resolve(pos), 1));
73
+ dispatch(tr.scrollIntoView());
74
+ }
75
+ return true;
76
+ };
77
+ function defineTableCommands() {
78
+ return defineCommands({
79
+ insertTable,
80
+ exitTable: () => exitTable
81
+ });
82
+ }
83
+
84
+ // src/table/table-plugins.ts
85
+ import { definePlugin } from "@prosekit/core";
86
+ import { tableEditing, columnResizing } from "prosemirror-tables";
87
+ function defineTablePlugins() {
88
+ return definePlugin([tableEditing(), columnResizing()]);
89
+ }
90
+
91
+ // src/table/table-spec.ts
92
+ import { defineNodeSpec } from "@prosekit/core";
93
+ import "prosemirror-tables";
94
+ var cellAttrs = {
95
+ colspan: { default: 1 },
96
+ rowspan: { default: 1 },
97
+ colwidth: { default: null }
98
+ };
99
+ var cellContent = "block+";
100
+ function getCellAttrs(dom) {
101
+ if (typeof dom === "string") {
102
+ return {};
103
+ }
104
+ const widthAttr = dom.getAttribute("data-colwidth");
105
+ const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(",").map((s) => Number(s)) : null;
106
+ const colspan = Number(dom.getAttribute("colspan") || 1);
107
+ return {
108
+ colspan,
109
+ rowspan: Number(dom.getAttribute("rowspan") || 1),
110
+ colwidth: widths && widths.length == colspan ? widths : null
111
+ };
112
+ }
113
+ function setCellAttrs(node) {
114
+ const pmAttrs = node.attrs;
115
+ const domAttrs = {};
116
+ if (pmAttrs.colspan !== 1) {
117
+ domAttrs.colspan = pmAttrs.colspan;
118
+ }
119
+ if (pmAttrs.rowspan !== 1) {
120
+ domAttrs.rowspan = pmAttrs.rowspan;
121
+ }
122
+ if (pmAttrs.colwidth) {
123
+ domAttrs["data-colwidth"] = pmAttrs.colwidth.join(",");
124
+ }
125
+ return domAttrs;
126
+ }
127
+ function defineTableSpec() {
128
+ return defineNodeSpec({
129
+ name: "table",
130
+ tableRole: "table",
131
+ content: "tableRow+",
132
+ isolating: true,
133
+ group: "block",
134
+ parseDOM: [{ tag: "table" }],
135
+ toDOM() {
136
+ return ["table", ["tbody", 0]];
137
+ }
138
+ });
139
+ }
140
+ function defineTableRowSpec() {
141
+ return defineNodeSpec({
142
+ name: "tableRow",
143
+ tableRole: "row",
144
+ content: "(tableCell | tableHeaderCell)*",
145
+ parseDOM: [{ tag: "tr" }],
146
+ toDOM() {
147
+ return ["tr", 0];
148
+ }
149
+ });
150
+ }
151
+ function defineTableCellSpec() {
152
+ return defineNodeSpec({
153
+ name: "tableCell",
154
+ tableRole: "cell",
155
+ content: cellContent,
156
+ attrs: cellAttrs,
157
+ isolating: true,
158
+ parseDOM: [{ tag: "td", getAttrs: (dom) => getCellAttrs(dom) }],
159
+ toDOM(node) {
160
+ return ["td", setCellAttrs(node), 0];
161
+ }
162
+ });
163
+ }
164
+ function defineTableHeaderCellSpec() {
165
+ return defineNodeSpec({
166
+ name: "tableHeaderCell",
167
+ tableRole: "header_cell",
168
+ content: cellContent,
169
+ attrs: cellAttrs,
170
+ isolating: true,
171
+ parseDOM: [{ tag: "th", getAttrs: (dom) => getCellAttrs(dom) }],
172
+ toDOM(node) {
173
+ return ["th", setCellAttrs(node), 0];
174
+ }
175
+ });
176
+ }
177
+
178
+ // src/table/index.ts
179
+ function defineTable() {
180
+ return union([
181
+ defineTableSpec(),
182
+ defineTableRowSpec(),
183
+ defineTableCellSpec(),
184
+ defineTableHeaderCellSpec(),
185
+ defineTablePlugins(),
186
+ defineTableCommands()
187
+ ]);
188
+ }
189
+ export {
190
+ defineTable,
191
+ defineTableCellSpec,
192
+ defineTableCommands,
193
+ defineTableHeaderCellSpec,
194
+ defineTablePlugins,
195
+ defineTableRowSpec,
196
+ defineTableSpec
197
+ };
@@ -0,0 +1,4 @@
1
+ export { defineUnderlineSpec } from './_tsup-dts-rollup';
2
+ export { defineUnderlineCommands } from './_tsup-dts-rollup';
3
+ export { defineUnderlineKeymap } from './_tsup-dts-rollup';
4
+ export { defineUnderline } from './_tsup-dts-rollup';