@clevertask/scribe 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +3 -0
  2. package/dist/BarMenu-CXaFlpRJ.js +272 -0
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.d.ts.map +1 -1
  5. package/dist/components/Menu/BarMenu.js +2 -10
  6. package/dist/components/Menu/BubbleMenu.d.ts.map +1 -1
  7. package/dist/components/Menu/BubbleMenu.js +165 -1023
  8. package/dist/components/Menu/LinkBubbleMenu.d.ts +8 -0
  9. package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -0
  10. package/dist/components/Menu/LinkBubbleMenu.js +78 -0
  11. package/dist/components/Menu/LinkEditor.d.ts +14 -0
  12. package/dist/components/Menu/LinkEditor.d.ts.map +1 -0
  13. package/dist/components/Menu/LinkEditor.js +140 -0
  14. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
  15. package/dist/components/Menu/Mobile/ListOptionBar.js +38 -44
  16. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +5 -0
  17. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -0
  18. package/dist/components/Menu/linkBubbleMenuPlugin.js +7 -0
  19. package/dist/components/Menu/linkUrl.d.ts +2 -0
  20. package/dist/components/Menu/linkUrl.d.ts.map +1 -0
  21. package/dist/components/Menu/linkUrl.js +21 -0
  22. package/dist/components/Scribe/extension/emoji/EmojiList.js +58 -45
  23. package/dist/components/Scribe/extension/emoji/suggest.d.ts +2 -2
  24. package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -1
  25. package/dist/components/Scribe/extension/emoji/suggest.js +39 -43
  26. package/dist/components/Scribe/extension/extension-link.d.ts.map +1 -1
  27. package/dist/components/Scribe/extension/extension-link.js +2 -4
  28. package/dist/components/Scribe/extension/extension-markdown-paste.d.ts.map +1 -1
  29. package/dist/components/Scribe/extension/extension-markdown-paste.js +50 -45
  30. package/dist/components/Scribe/extension/extension-selectedText.d.ts.map +1 -1
  31. package/dist/components/Scribe/extension/extension-selectedText.js +10 -12
  32. package/dist/components/Scribe/extension/getPopupMountTarget.d.ts.map +1 -1
  33. package/dist/components/Scribe/extension/getPopupMountTarget.js +12 -15
  34. package/dist/components/Scribe/extension/index.d.ts +4 -4
  35. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  36. package/dist/components/Scribe/extension/index.js +2 -39521
  37. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3369 -3731
  38. package/dist/components/Scribe/extension/slashCommand/index.js +2 -6
  39. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
  40. package/dist/components/Scribe/extension/slashCommand/items.js +177 -176
  41. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -1
  42. package/dist/components/Scribe/extension/slashCommand/renderItems.js +35 -41
  43. package/dist/components/Scribe/extension/tableOfContents.js +153 -180
  44. package/dist/components/Scribe/index.d.ts.map +1 -1
  45. package/dist/components/Scribe/index.js +113 -153
  46. package/dist/dist-BQjH-i-q.js +7016 -0
  47. package/dist/dist-CnXCIcnl.js +3506 -0
  48. package/dist/dist-Cp938P7P.js +689 -0
  49. package/dist/extension-CZOsheCI.js +56236 -0
  50. package/dist/extension-link-DZID_SYl.js +908 -0
  51. package/dist/floating-ui.dom-rih69525.js +928 -0
  52. package/dist/html-to-markdown-CrNOkSye.js +497 -0
  53. package/dist/icons/ToolbarIcons.d.ts.map +1 -1
  54. package/dist/icons/ToolbarIcons.js +76 -135
  55. package/dist/main.css +10 -0
  56. package/dist/main.js +7 -15
  57. package/dist/markdown-to-html-DEczPfuq.js +1458 -0
  58. package/dist/menus-CakIdDdY.js +633 -0
  59. package/dist/purify.es-DF9CW1cl.js +767 -0
  60. package/dist/rolldown-runtime-CtkjhSXr.js +4 -0
  61. package/dist/slashCommand-B7CRIaKG.js +429 -0
  62. package/dist/tables-CjOC70rm.js +1345 -0
  63. package/dist/tippy.esm-D9LL2xiE.js +1713 -0
  64. package/dist/utils/convert-legacy-math-delimiters.d.ts.map +1 -1
  65. package/dist/utils/convert-legacy-math-delimiters.js +7 -13
  66. package/dist/utils/create-scribe-editor.js +2 -31
  67. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  68. package/dist/utils/html-to-markdown.js +2 -600
  69. package/dist/utils/index.js +24 -12
  70. package/dist/utils/is-in-viewport.d.ts.map +1 -1
  71. package/dist/utils/is-in-viewport.js +6 -6
  72. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  73. package/dist/utils/markdown-to-html.js +2 -5
  74. package/dist/vite-env.d.js +0 -1
  75. package/package.json +38 -36
  76. package/dist/BarMenu-BNk2I0zi.js +0 -327
  77. package/dist/extension-link-P1rro4zO.js +0 -1059
  78. package/dist/floating-ui.dom-ZRy7FSVk.js +0 -1246
  79. package/dist/index-BMISMQrG.js +0 -855
  80. package/dist/index-ByyiiYsp.js +0 -1410
  81. package/dist/index-CnKS-BY2.js +0 -13834
  82. package/dist/index-CnQHDObA.js +0 -539
  83. package/dist/markdown-to-html-Bw9L43K6.js +0 -1135
  84. package/dist/purify.es-DC1iJOxX.js +0 -864
  85. package/dist/tippy.esm-DLHdsnfG.js +0 -1711
@@ -1,181 +1,154 @@
1
- import { P as v, a as C, b as w } from "../../../index-CnKS-BY2.js";
2
- const u = "scribeTableOfContents", S = new v("scribeTableOfContents"), T = 10, b = (e) => e.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "heading", m = (e, t) => {
3
- const n = t[t.length - 1], s = [...t].reverse().find((r) => r.originalLevel <= e.node.attrs.level)?.level || 1;
4
- return e.node.attrs.level > (n?.originalLevel || 1) ? (n?.level || 1) + 1 : e.node.attrs.level < (n?.originalLevel || 1) ? s : n?.level || 1;
5
- }, y = (e) => (e[e.length - 1]?.itemIndex || 0) + 1, H = (e, t, n) => {
6
- if (e.textContent.length === 0)
7
- return null;
8
- const o = b(e.textContent), s = (t.get(o) || 0) + 1, r = s === 1 ? o : `${o}-${s}`;
9
- return t.set(o, s), n === r ? n : r;
10
- }, d = (e, t) => {
11
- const n = e.tr, o = /* @__PURE__ */ new Map();
12
- let s = !1;
13
- return e.doc.descendants((r, a) => {
14
- if (!t.includes(r.type.name))
15
- return;
16
- const i = r.attrs["data-toc-id"], l = H(r, o, i);
17
- i !== l && (n.setNodeMarkup(a, void 0, {
18
- ...r.attrs,
19
- "data-toc-id": l
20
- }), s = !0);
21
- }), s ? n.setMeta(u, !0).setMeta("addToHistory", !1) : null;
22
- }, R = (e) => {
23
- const { overflowY: t } = window.getComputedStyle(e);
24
- return /(auto|scroll|overlay)/.test(t) && e.scrollHeight > e.clientHeight;
25
- }, A = (e) => {
26
- let t = e.parentElement;
27
- for (; t; ) {
28
- if (R(t))
29
- return t;
30
- t = t.parentElement;
31
- }
32
- return window;
33
- }, h = (e) => typeof Window < "u" && e instanceof Window, E = (e) => h(e) ? 32 : e.getBoundingClientRect().top + 32, c = (e) => e.isConnected && e.getClientRects().length > 0, I = (e, t) => {
34
- const n = e.view.nodeDOM(t);
35
- return n instanceof HTMLElement ? n : null;
36
- }, O = (e, t) => {
37
- const n = [];
38
- return e.state.doc.descendants((o, s) => {
39
- !t.includes(o.type.name) || o.textContent.length === 0 || n.push({ node: o, pos: s });
40
- }), n;
41
- }, g = (e, t) => e.length === 0 ? !0 : !t || !e.every((n) => c(n.dom)) ? !1 : h(t) || c(t), L = (e, t) => {
42
- if (!g(e, t))
43
- return e;
44
- const n = E(t), o = /* @__PURE__ */ new Set();
45
- let s = null;
46
- return e.forEach((r) => {
47
- r.dom.getBoundingClientRect().top <= n && (s = r.id, o.add(r.id));
48
- }), e.map((r) => ({
49
- ...r,
50
- isActive: r.id === s,
51
- isScrolledOver: o.has(r.id)
52
- }));
53
- }, x = (e, t, n) => {
54
- const o = O(e, t), s = [];
55
- return o.forEach((r) => {
56
- const a = r.node.attrs["data-toc-id"], i = I(e, r.pos);
57
- if (!a || !i)
58
- return;
59
- const l = Number(r.node.attrs.level) || 1, f = m(r, s), p = y(s);
60
- s.push({
61
- dom: i,
62
- editor: e,
63
- id: a,
64
- isActive: !1,
65
- isScrolledOver: !1,
66
- itemIndex: p,
67
- level: f,
68
- node: r.node,
69
- originalLevel: l,
70
- pos: r.pos,
71
- textContent: r.node.textContent
72
- });
73
- }), L(s, n);
74
- }, M = (e) => JSON.stringify(
75
- e.map((t) => ({
76
- id: t.id,
77
- isActive: t.isActive,
78
- isScrolledOver: t.isScrolledOver,
79
- itemIndex: t.itemIndex,
80
- level: t.level,
81
- originalLevel: t.originalLevel,
82
- pos: t.pos,
83
- textContent: t.textContent
84
- }))
85
- ), P = (e, t, n) => {
86
- const o = M(n), s = !e.hasCreated;
87
- e.anchors = n.map((r) => r.dom), e.content = n, !(!s && o === e.lastSignature) && (e.hasCreated = !0, e.lastSignature = o, t.onUpdate?.(n, s));
88
- }, F = C.create({
89
- name: "scribeTableOfContents",
90
- addOptions() {
91
- return {
92
- anchorTypes: ["heading"]
93
- };
94
- },
95
- addStorage() {
96
- return {
97
- anchors: [],
98
- content: [],
99
- hasCreated: !1,
100
- lastSignature: "",
101
- layoutRefreshRetries: 0,
102
- rafId: null,
103
- refresh: () => null,
104
- scheduleRefresh: () => null,
105
- scrollHandler: () => null,
106
- scrollParent: null,
107
- updateScrollParent: () => null
108
- };
109
- },
110
- addGlobalAttributes() {
111
- return [
112
- {
113
- types: this.options.anchorTypes,
114
- attributes: {
115
- "data-toc-id": {
116
- default: null,
117
- renderHTML: (e) => {
118
- const t = e["data-toc-id"];
119
- return t ? { "data-toc-id": t } : {};
120
- },
121
- parseHTML: (e) => e.getAttribute("data-toc-id")
122
- }
123
- }
124
- }
125
- ];
126
- },
127
- addCommands() {
128
- return {
129
- updateScribeTableOfContents: () => ({ dispatch: e }) => (e && this.storage.refresh(), !0)
130
- };
131
- },
132
- addProseMirrorPlugins() {
133
- return [
134
- new w({
135
- key: S,
136
- appendTransaction: (e, t, n) => typeof window > "u" || e.some(
137
- (s) => s.getMeta(u) || s.getMeta("composition")
138
- ) || !e.some((s) => s.docChanged) ? null : d(n, this.options.anchorTypes)
139
- })
140
- ];
141
- },
142
- onCreate() {
143
- if (typeof window > "u" || !this.editor.view)
144
- return;
145
- this.storage.scrollHandler = () => {
146
- this.storage.refresh();
147
- }, this.storage.updateScrollParent = () => {
148
- const t = A(this.editor.view.dom);
149
- this.storage.scrollParent !== t && (this.storage.scrollParent?.removeEventListener("scroll", this.storage.scrollHandler), this.storage.scrollParent = t, this.storage.scrollParent.addEventListener("scroll", this.storage.scrollHandler));
150
- }, this.storage.refresh = () => {
151
- if (this.editor.isDestroyed)
152
- return;
153
- this.storage.updateScrollParent();
154
- const t = x(
155
- this.editor,
156
- this.options.anchorTypes,
157
- this.storage.scrollParent
158
- ), n = this.editor.view.dom.isConnected && g(t, this.storage.scrollParent);
159
- n && (this.storage.layoutRefreshRetries = 0), P(this.storage, this.options, t), !n && this.storage.layoutRefreshRetries < T && (this.storage.layoutRefreshRetries += 1, this.storage.scheduleRefresh());
160
- }, this.storage.scheduleRefresh = () => {
161
- this.storage.rafId !== null && window.cancelAnimationFrame(this.storage.rafId), this.storage.rafId = window.requestAnimationFrame(() => {
162
- this.storage.rafId = null, this.storage.refresh();
163
- });
164
- };
165
- const e = d(
166
- this.editor.state,
167
- this.options.anchorTypes
168
- );
169
- e && this.editor.view.dispatch(e), this.storage.scheduleRefresh();
170
- },
171
- onTransaction({ transaction: e }) {
172
- e.docChanged && this.storage.scheduleRefresh();
173
- },
174
- onDestroy() {
175
- typeof window < "u" && this.storage.rafId !== null && window.cancelAnimationFrame(this.storage.rafId), this.storage.scrollParent?.removeEventListener("scroll", this.storage.scrollHandler);
176
- }
1
+ import { a as e, i as t } from "../../../dist-CnXCIcnl.js";
2
+ import { n } from "../../../dist-BQjH-i-q.js";
3
+ //#region lib/components/Scribe/extension/tableOfContents.ts
4
+ var r = "scribeTableOfContents", i = new e("scribeTableOfContents"), a = 10, o = (e) => e.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "heading", s = (e, t) => {
5
+ let n = t[t.length - 1], r = [...t].reverse().find((t) => t.originalLevel <= e.node.attrs.level)?.level || 1;
6
+ return e.node.attrs.level > (n?.originalLevel || 1) ? (n?.level || 1) + 1 : e.node.attrs.level < (n?.originalLevel || 1) ? r : n?.level || 1;
7
+ }, c = (e) => (e[e.length - 1]?.itemIndex || 0) + 1, l = (e, t, n) => {
8
+ if (e.textContent.length === 0) return null;
9
+ let r = o(e.textContent), i = (t.get(r) || 0) + 1, a = i === 1 ? r : `${r}-${i}`;
10
+ return t.set(r, i), n === a ? n : a;
11
+ }, u = (e, t) => {
12
+ let n = e.tr, i = /* @__PURE__ */ new Map(), a = !1;
13
+ return e.doc.descendants((e, r) => {
14
+ if (!t.includes(e.type.name)) return;
15
+ let o = e.attrs["data-toc-id"], s = l(e, i, o);
16
+ o !== s && (n.setNodeMarkup(r, void 0, {
17
+ ...e.attrs,
18
+ "data-toc-id": s
19
+ }), a = !0);
20
+ }), a ? n.setMeta(r, !0).setMeta("addToHistory", !1) : null;
21
+ }, d = (e) => {
22
+ let { overflowY: t } = window.getComputedStyle(e);
23
+ return /(auto|scroll|overlay)/.test(t) && e.scrollHeight > e.clientHeight;
24
+ }, f = (e) => {
25
+ let t = e.parentElement;
26
+ for (; t;) {
27
+ if (d(t)) return t;
28
+ t = t.parentElement;
29
+ }
30
+ return window;
31
+ }, p = (e) => typeof Window < "u" && e instanceof Window, m = (e) => p(e) ? 32 : e.getBoundingClientRect().top + 32, h = (e) => e.isConnected && e.getClientRects().length > 0, g = (e, t) => {
32
+ let n = e.view.nodeDOM(t);
33
+ return n instanceof HTMLElement ? n : null;
34
+ }, _ = (e, t) => {
35
+ let n = [];
36
+ return e.state.doc.descendants((e, r) => {
37
+ !t.includes(e.type.name) || e.textContent.length === 0 || n.push({
38
+ node: e,
39
+ pos: r
40
+ });
41
+ }), n;
42
+ }, v = (e, t) => e.length === 0 ? !0 : !t || !e.every((e) => h(e.dom)) ? !1 : p(t) || h(t), y = (e, t) => {
43
+ if (!v(e, t)) return e;
44
+ let n = m(t), r = /* @__PURE__ */ new Set(), i = null;
45
+ return e.forEach((e) => {
46
+ e.dom.getBoundingClientRect().top <= n && (i = e.id, r.add(e.id));
47
+ }), e.map((e) => ({
48
+ ...e,
49
+ isActive: e.id === i,
50
+ isScrolledOver: r.has(e.id)
51
+ }));
52
+ }, b = (e, t, n) => {
53
+ let r = _(e, t), i = [];
54
+ return r.forEach((t) => {
55
+ let n = t.node.attrs["data-toc-id"], r = g(e, t.pos);
56
+ if (!n || !r) return;
57
+ let a = Number(t.node.attrs.level) || 1, o = s(t, i), l = c(i);
58
+ i.push({
59
+ dom: r,
60
+ editor: e,
61
+ id: n,
62
+ isActive: !1,
63
+ isScrolledOver: !1,
64
+ itemIndex: l,
65
+ level: o,
66
+ node: t.node,
67
+ originalLevel: a,
68
+ pos: t.pos,
69
+ textContent: t.node.textContent
70
+ });
71
+ }), y(i, n);
72
+ }, x = (e) => JSON.stringify(e.map((e) => ({
73
+ id: e.id,
74
+ isActive: e.isActive,
75
+ isScrolledOver: e.isScrolledOver,
76
+ itemIndex: e.itemIndex,
77
+ level: e.level,
78
+ originalLevel: e.originalLevel,
79
+ pos: e.pos,
80
+ textContent: e.textContent
81
+ }))), S = (e, t, n) => {
82
+ let r = x(n), i = !e.hasCreated;
83
+ e.anchors = n.map((e) => e.dom), e.content = n, !(!i && r === e.lastSignature) && (e.hasCreated = !0, e.lastSignature = r, t.onUpdate?.(n, i));
84
+ }, C = n.create({
85
+ name: "scribeTableOfContents",
86
+ addOptions() {
87
+ return { anchorTypes: ["heading"] };
88
+ },
89
+ addStorage() {
90
+ return {
91
+ anchors: [],
92
+ content: [],
93
+ hasCreated: !1,
94
+ lastSignature: "",
95
+ layoutRefreshRetries: 0,
96
+ rafId: null,
97
+ refresh: () => null,
98
+ scheduleRefresh: () => null,
99
+ scrollHandler: () => null,
100
+ scrollParent: null,
101
+ updateScrollParent: () => null
102
+ };
103
+ },
104
+ addGlobalAttributes() {
105
+ return [{
106
+ types: this.options.anchorTypes,
107
+ attributes: { "data-toc-id": {
108
+ default: null,
109
+ renderHTML: (e) => {
110
+ let t = e["data-toc-id"];
111
+ return t ? { "data-toc-id": t } : {};
112
+ },
113
+ parseHTML: (e) => e.getAttribute("data-toc-id")
114
+ } }
115
+ }];
116
+ },
117
+ addCommands() {
118
+ return { updateScribeTableOfContents: () => ({ dispatch: e }) => (e && this.storage.refresh(), !0) };
119
+ },
120
+ addProseMirrorPlugins() {
121
+ return [new t({
122
+ key: i,
123
+ appendTransaction: (e, t, n) => typeof window > "u" || e.some((e) => e.getMeta("scribeTableOfContents") || e.getMeta("composition")) || !e.some((e) => e.docChanged) ? null : u(n, this.options.anchorTypes)
124
+ })];
125
+ },
126
+ onCreate() {
127
+ if (typeof window > "u" || !this.editor.view) return;
128
+ this.storage.scrollHandler = () => {
129
+ this.storage.refresh();
130
+ }, this.storage.updateScrollParent = () => {
131
+ let e = f(this.editor.view.dom);
132
+ this.storage.scrollParent !== e && (this.storage.scrollParent?.removeEventListener("scroll", this.storage.scrollHandler), this.storage.scrollParent = e, this.storage.scrollParent.addEventListener("scroll", this.storage.scrollHandler));
133
+ }, this.storage.refresh = () => {
134
+ if (this.editor.isDestroyed) return;
135
+ this.storage.updateScrollParent();
136
+ let e = b(this.editor, this.options.anchorTypes, this.storage.scrollParent), t = this.editor.view.dom.isConnected && v(e, this.storage.scrollParent);
137
+ t && (this.storage.layoutRefreshRetries = 0), S(this.storage, this.options, e), !t && this.storage.layoutRefreshRetries < a && (this.storage.layoutRefreshRetries += 1, this.storage.scheduleRefresh());
138
+ }, this.storage.scheduleRefresh = () => {
139
+ this.storage.rafId !== null && window.cancelAnimationFrame(this.storage.rafId), this.storage.rafId = window.requestAnimationFrame(() => {
140
+ this.storage.rafId = null, this.storage.refresh();
141
+ });
142
+ };
143
+ let e = u(this.editor.state, this.options.anchorTypes);
144
+ e && this.editor.view.dispatch(e), this.storage.scheduleRefresh();
145
+ },
146
+ onTransaction({ transaction: e }) {
147
+ e.docChanged && this.storage.scheduleRefresh();
148
+ },
149
+ onDestroy() {
150
+ typeof window < "u" && this.storage.rafId !== null && window.cancelAnimationFrame(this.storage.rafId), this.storage.scrollParent?.removeEventListener("scroll", this.storage.scrollHandler);
151
+ }
177
152
  });
178
- export {
179
- u as SCRIBE_TABLE_OF_CONTENTS_META,
180
- F as ScribeTableOfContents
181
- };
153
+ //#endregion
154
+ export { r as SCRIBE_TABLE_OF_CONTENTS_META, C as ScribeTableOfContents };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/Scribe/index.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAC;AAGxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,KAAK,EACV,kCAAkC,EAElC,iCAAiC,EAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,EACP,MAAM,EAGN,SAAS,EACT,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,oBAAoB,EAMrB,MAAM,OAAO,CAAC;AAGf,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,YAAY,EACV,kCAAkC,EAClC,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,OAAO,CAAC;IACrB,W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,KAAK,IAAI,CAAC;IACjF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC5D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE,UAAU,CAAC;IACpC,kBAAkB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACzC,sBAAsB,CAAC,EAAE,UAAU,CAAC;IACpC,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,yBAAyB,CAAC;IACzC,sEAAsE;IACtE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mFAAmF;IACnF,uBAAuB,CAAC,EAAE,kCAAkC,CAAC;CAC9D;AAED,eAAO,MAAM,MAAM,mGA0MjB,CAAC"}
@@ -1,154 +1,114 @@
1
- import { jsxs as I, jsx as a } from "react/jsx-runtime";
2
- import { B as A, c as b } from "../../BarMenu-BNk2I0zi.js";
3
- import { html2md as N } from "../../utils/html-to-markdown.js";
4
- import "../../markdown-to-html-Bw9L43K6.js";
5
- import "../../purify.es-DC1iJOxX.js";
6
- import { E as F } from "../../index-CnKS-BY2.js";
7
- import { initExtensions as J } from "./extension/index.js";
8
- import { SCRIBE_TABLE_OF_CONTENTS_META as U } from "./extension/tableOfContents.js";
9
- import { E as V } from "../../index-BMISMQrG.js";
10
- import { forwardRef as K, useRef as E, useEffect as c, useCallback as r, useState as q, useImperativeHandle as G } from "react";
11
- import { ListOptionBar as Q } from "../Menu/Mobile/ListOptionBar.js";
12
- import { SuggestionItemType as mt } from "./extension/slashCommand/items.js";
13
- import '../../assets/index.css';const it = K((h, B) => {
14
- const {
15
- autoFocus: g = !1,
16
- content: i,
17
- editable: o = !0,
18
- editorProps: d,
19
- extensions: L,
20
- onContentChange: l,
21
- showBarMenu: R = !0,
22
- editorContentStyle: j,
23
- editorContentClassName: H,
24
- mainContainerStyle: P,
25
- mainContainerClassName: k,
26
- onKeyDown: _,
27
- externalEditor: T,
28
- mobile: D,
29
- onTableOfContentsChange: f
30
- } = h, y = E(!T && i !== void 0), O = E([]), M = E(f);
31
- c(() => {
32
- M.current = f;
33
- }, [f]);
34
- const z = r(
35
- (e, s) => {
36
- O.current = e, M.current?.(e, s);
37
- },
38
- []
39
- ), p = r(
40
- ({ editor: e, transaction: s }) => {
41
- if (s.getMeta(U))
42
- return;
43
- const n = e.getHTML(), m = e.getJSON(), u = !o;
44
- l && l({
45
- jsonContent: e.isEmpty ? "" : m,
46
- htmlContent: e.isEmpty ? "" : n,
47
- markdownContent: e.isEmpty ? "" : N(n),
48
- source: u ? "programmatic" : "user"
49
- });
50
- },
51
- [o, l]
52
- ), [t] = q(() => T ?? new F({
53
- ...d,
54
- content: i ?? d?.content,
55
- editable: o,
56
- extensions: [
57
- ...J({
58
- ...h,
59
- onTableOfContentsChange: z
60
- }),
61
- ...L ?? []
62
- ],
63
- editorProps: {
64
- attributes: {
65
- class: "scribe"
66
- },
67
- ...d?.editorProps
68
- }
69
- })), S = r(() => {
70
- t.commands.setContent("");
71
- }, [t]), v = r(
72
- (e) => {
73
- const s = {
74
- html: () => t.getHTML(),
75
- json: () => t.getJSON(),
76
- markdown: () => N(t.getHTML())
77
- };
78
- return t.isEmpty ? "" : s[e]?.();
79
- },
80
- [t]
81
- ), w = r(
82
- (e) => {
83
- t.commands.setContent(e);
84
- },
85
- [t]
86
- ), x = r(
87
- (e) => {
88
- const s = typeof e == "string" ? e : e.id, n = O.current.find((C) => C.id === s) ?? (typeof e == "string" ? void 0 : e);
89
- if (!n || t.isDestroyed)
90
- return;
91
- const m = t.view.nodeDOM(n.pos), u = m instanceof HTMLElement ? m : n.dom;
92
- if (t.isEditable) {
93
- const C = Math.max(
94
- 0,
95
- Math.min(n.pos + n.node.nodeSize - 1, t.state.doc.content.size)
96
- );
97
- t.commands.focus(C, { scrollIntoView: !1 });
98
- }
99
- u.scrollIntoView({ behavior: "smooth", block: "start" });
100
- },
101
- [t]
102
- );
103
- return G(B, () => ({
104
- resetContent: S,
105
- setContent: w,
106
- getContent: v,
107
- scrollToTableOfContentsItem: x,
108
- editor: t
109
- }), [t, v, S, x, w]), c(() => {
110
- if (i !== void 0) {
111
- if (y.current) {
112
- y.current = !1;
113
- return;
114
- }
115
- t.commands.setContent(i, { emitUpdate: !1 });
116
- }
117
- }, [i, t]), c(() => {
118
- t.setEditable(!!o);
119
- }, [o, t]), c(() => (t.off("update"), t.on("update", p), () => {
120
- t.off("update", p);
121
- }), [t, p]), c(() => {
122
- g && t.commands.focus("end");
123
- }, [g, t]), /* @__PURE__ */ I(
124
- "div",
125
- {
126
- className: b("scribe-wrapper", "scribe-root", k),
127
- "data-scribe-root": !0,
128
- style: P,
129
- children: [
130
- /* @__PURE__ */ I("div", { className: b("scribe-frame", o && "scribe-frame--editable"), children: [
131
- t && R ? /* @__PURE__ */ a(A, { editor: t }) : null,
132
- /* @__PURE__ */ a(
133
- "div",
134
- {
135
- className: b(
136
- "scribe-content",
137
- o && "scribe-content--editable",
138
- H
139
- ),
140
- style: j,
141
- children: /* @__PURE__ */ a(V, { editor: t, onKeyDown: _ })
142
- }
143
- ),
144
- D ? /* @__PURE__ */ a(Q, { editor: t }) : null
145
- ] }),
146
- /* @__PURE__ */ a("div", { className: "scribe-popup-root", "data-scribe-popup-root": !0 })
147
- ]
148
- }
149
- );
1
+ import { n as e, t } from "../../BarMenu-CXaFlpRJ.js";
2
+ import { t as n } from "../../dist-Cp938P7P.js";
3
+ import { t as r } from "../../dist-BQjH-i-q.js";
4
+ import i from "../Menu/LinkBubbleMenu.js";
5
+ import { t as a } from "../../html-to-markdown-CrNOkSye.js";
6
+ import { t as o } from "../../extension-CZOsheCI.js";
7
+ import { SuggestionItemType as s } from "./extension/slashCommand/items.js";
8
+ import "./extension/tableOfContents.js";
9
+ import "../../utils/index.js";
10
+ import { ListOptionBar as c } from "../Menu/Mobile/ListOptionBar.js";
11
+ import { forwardRef as l, useCallback as u, useEffect as d, useImperativeHandle as f, useRef as p, useState as m } from "react";
12
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
13
+ import '../../assets/index.css';//#region lib/components/Scribe/index.tsx
14
+ var _ = l((s, l) => {
15
+ let { autoFocus: _ = !1, content: v, editable: y = !0, editorProps: b, extensions: x, onContentChange: S, showBarMenu: C = !0, editorContentStyle: w, editorContentClassName: T, mainContainerStyle: E, mainContainerClassName: D, onKeyDown: O, externalEditor: k, mobile: A, onTableOfContentsChange: j } = s, M = p(!k && v !== void 0), N = p([]), P = p(j);
16
+ d(() => {
17
+ P.current = j;
18
+ }, [j]);
19
+ let F = u((e, t) => {
20
+ N.current = e, P.current?.(e, t);
21
+ }, []), I = u(({ editor: e, transaction: t }) => {
22
+ if (t.getMeta("scribeTableOfContents")) return;
23
+ let n = e.getHTML(), r = e.getJSON(), i = !y;
24
+ S && S({
25
+ jsonContent: e.isEmpty ? "" : r,
26
+ htmlContent: e.isEmpty ? "" : n,
27
+ markdownContent: e.isEmpty ? "" : a(n),
28
+ source: i ? "programmatic" : "user"
29
+ });
30
+ }, [y, S]), [L] = m(() => k ?? new r({
31
+ ...b,
32
+ content: v ?? b?.content,
33
+ editable: y,
34
+ extensions: [...o({
35
+ ...s,
36
+ onTableOfContentsChange: F
37
+ }), ...x ?? []],
38
+ editorProps: {
39
+ attributes: { class: "scribe" },
40
+ ...b?.editorProps
41
+ }
42
+ })), R = u(() => {
43
+ L.commands.setContent("");
44
+ }, [L]), z = u((e) => L.isEmpty ? "" : {
45
+ html: () => L.getHTML(),
46
+ json: () => L.getJSON(),
47
+ markdown: () => a(L.getHTML())
48
+ }[e]?.(), [L]), B = u((e) => {
49
+ L.commands.setContent(e);
50
+ }, [L]), V = u((e) => {
51
+ let t = typeof e == "string" ? e : e.id, n = N.current.find((e) => e.id === t) ?? (typeof e == "string" ? void 0 : e);
52
+ if (!n || L.isDestroyed) return;
53
+ let r = L.view.nodeDOM(n.pos), i = r instanceof HTMLElement ? r : n.dom;
54
+ if (L.isEditable) {
55
+ let e = Math.max(0, Math.min(n.pos + n.node.nodeSize - 1, L.state.doc.content.size));
56
+ L.commands.focus(e, { scrollIntoView: !1 });
57
+ }
58
+ i.scrollIntoView({
59
+ behavior: "smooth",
60
+ block: "start"
61
+ });
62
+ }, [L]);
63
+ return f(l, () => ({
64
+ resetContent: R,
65
+ setContent: B,
66
+ getContent: z,
67
+ scrollToTableOfContentsItem: V,
68
+ editor: L
69
+ }), [
70
+ L,
71
+ z,
72
+ R,
73
+ V,
74
+ B
75
+ ]), d(() => {
76
+ if (v !== void 0) {
77
+ if (M.current) {
78
+ M.current = !1;
79
+ return;
80
+ }
81
+ L.commands.setContent(v, { emitUpdate: !1 });
82
+ }
83
+ }, [v, L]), d(() => {
84
+ L.setEditable(!!y);
85
+ }, [y, L]), d(() => (L.off("update"), L.on("update", I), () => {
86
+ L.off("update", I);
87
+ }), [L, I]), d(() => {
88
+ _ && L.commands.focus("end");
89
+ }, [_, L]), /* @__PURE__ */ g("div", {
90
+ className: e("scribe-wrapper", "scribe-root", D),
91
+ "data-scribe-root": !0,
92
+ style: E,
93
+ children: [/* @__PURE__ */ g("div", {
94
+ className: e("scribe-frame", y && "scribe-frame--editable"),
95
+ children: [
96
+ L && C ? /* @__PURE__ */ h(t, { editor: L }) : null,
97
+ /* @__PURE__ */ g("div", {
98
+ className: e("scribe-content", y && "scribe-content--editable", T),
99
+ style: w,
100
+ children: [/* @__PURE__ */ h(n, {
101
+ editor: L,
102
+ onKeyDown: O
103
+ }), y ? /* @__PURE__ */ h(i, { editor: L }) : null]
104
+ }),
105
+ A ? /* @__PURE__ */ h(c, { editor: L }) : null
106
+ ]
107
+ }), /* @__PURE__ */ h("div", {
108
+ className: "scribe-popup-root",
109
+ "data-scribe-popup-root": !0
110
+ })]
111
+ });
150
112
  });
151
- export {
152
- it as Scribe,
153
- mt as SuggestionItemType
154
- };
113
+ //#endregion
114
+ export { _ as Scribe, s as SuggestionItemType };