@clevertask/scribe 0.0.15 → 0.1.1
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.
- package/README.md +77 -27
- package/dist/BarMenu-DaKIz3zZ.js +327 -0
- package/dist/assets/index.css +1 -1
- package/dist/components/Menu/BarMenu.d.ts +0 -1
- package/dist/components/Menu/BarMenu.d.ts.map +1 -1
- package/dist/components/Menu/BarMenu.js +8 -140
- package/dist/components/Menu/BubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/BubbleMenu.js +2074 -159
- package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -1
- package/dist/components/Menu/Mobile/ListOptionBar.js +42 -22
- package/dist/components/Scribe/extension/emoji/EmojiList.d.ts +19 -1
- package/dist/components/Scribe/extension/emoji/EmojiList.d.ts.map +1 -1
- package/dist/components/Scribe/extension/emoji/EmojiList.js +42 -42
- package/dist/components/Scribe/extension/emoji/suggest.d.ts +2 -4
- package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -1
- package/dist/components/Scribe/extension/emoji/suggest.js +20 -15
- package/dist/components/Scribe/extension/extension-link.js +2 -984
- package/dist/components/Scribe/extension/extension-markdown-paste.js +4 -4
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/getPopupMountTarget.d.ts +3 -0
- package/dist/components/Scribe/extension/getPopupMountTarget.d.ts.map +1 -0
- package/dist/components/Scribe/extension/getPopupMountTarget.js +16 -0
- package/dist/components/Scribe/extension/index.d.ts +16 -2
- package/dist/components/Scribe/extension/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/index.js +37122 -34
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.d.ts +4 -1
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.d.ts.map +1 -1
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +3730 -14
- package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts +1 -1
- package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -1
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +21 -16
- package/dist/components/Scribe/extension/tableOfContents.d.ts +48 -0
- package/dist/components/Scribe/extension/tableOfContents.d.ts.map +1 -0
- package/dist/components/Scribe/extension/tableOfContents.js +180 -0
- package/dist/components/Scribe/index.d.ts +12 -1
- package/dist/components/Scribe/index.d.ts.map +1 -1
- package/dist/components/Scribe/index.js +133 -87
- package/dist/extension-link-Ch_T7WWG.js +1030 -0
- package/dist/icons/ToolbarIcons.d.ts +19 -0
- package/dist/icons/ToolbarIcons.d.ts.map +1 -0
- package/dist/icons/ToolbarIcons.js +135 -0
- package/dist/{index-BKFDqQPh.js → index-BiBV5TQx.js} +6598 -5432
- package/dist/index-CqzMmrnw.js +1410 -0
- package/dist/index-DxF-1P4n.js +834 -0
- package/dist/index-V-gN11Y9.js +249 -0
- package/dist/main.css +200 -1123
- package/dist/main.js +1 -1
- package/dist/markdown-to-html-pL7ckd-m.js +1135 -0
- package/dist/purify.es-exIQuqhb.js +595 -0
- package/dist/tippy.esm-DLHdsnfG.js +1711 -0
- package/dist/utils/create-scribe-editor.d.ts +2 -2
- package/dist/utils/create-scribe-editor.d.ts.map +1 -1
- package/dist/utils/create-scribe-editor.js +3 -3
- package/dist/utils/html-to-markdown.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.js +583 -18
- package/dist/utils/index.js +1 -1
- package/dist/utils/markdown-to-html.js +2 -2
- package/package.json +34 -37
- package/dist/clsx-OuTLNxxd.js +0 -16
- package/dist/index-CL2WLiGu.js +0 -159
- package/dist/index-Cxf4VEm1.js +0 -50957
- package/dist/index-PzbCrHp0.js +0 -2349
- package/dist/markdown-to-html-__93dwok.js +0 -1557
- package/dist/purify.es-BPDBzHtc.js +0 -552
- package/dist/turndown.browser.es-RmA_HBaI.js +0 -649
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../../../../index-
|
|
2
|
-
import {
|
|
1
|
+
import "../../../../index-BiBV5TQx.js";
|
|
2
|
+
import { a as o, s as e } from "../../../../index-V-gN11Y9.js";
|
|
3
3
|
export {
|
|
4
4
|
o as SlashCommand,
|
|
5
5
|
e as slashMenuPluginKey
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SuggestionKeyDownProps, SuggestionProps } from "@tiptap/suggestion";
|
|
2
|
-
declare const renderItems: (
|
|
2
|
+
declare const renderItems: () => {
|
|
3
3
|
onStart: (props: SuggestionProps) => void;
|
|
4
4
|
onUpdate: (props: SuggestionProps) => void;
|
|
5
5
|
onKeyDown(props: SuggestionKeyDownProps): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderItems.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/slashCommand/renderItems.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAK7E,QAAA,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"renderItems.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/slashCommand/renderItems.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAK7E,QAAA,MAAM,WAAW;qBAMI,eAAe;sBAwBd,eAAe;qBAahB,sBAAsB;;CA0B1C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import { R as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { R as o } from "../../../../index-DxF-1P4n.js";
|
|
2
|
+
import { t as s } from "../../../../tippy.esm-DLHdsnfG.js";
|
|
3
|
+
import { getPopupMountTarget as a } from "../getPopupMountTarget.js";
|
|
4
|
+
import { SlashCommandList as l } from "./SlashCommandList.js";
|
|
5
|
+
const u = () => {
|
|
6
|
+
let n, t = null, r;
|
|
5
7
|
return {
|
|
6
8
|
onStart: (e) => {
|
|
7
|
-
|
|
8
|
-
props:
|
|
9
|
+
r = e, n = new o(l, {
|
|
10
|
+
props: r,
|
|
9
11
|
editor: e.editor
|
|
10
|
-
}), e.clientRect && (t =
|
|
12
|
+
}), e.clientRect && (t = s(e.editor.view.dom, {
|
|
11
13
|
getReferenceClientRect: e.clientRect,
|
|
12
|
-
appendTo: ()
|
|
13
|
-
content:
|
|
14
|
+
appendTo: a(e.editor),
|
|
15
|
+
content: n.element,
|
|
16
|
+
popperOptions: {
|
|
17
|
+
strategy: "fixed"
|
|
18
|
+
},
|
|
14
19
|
showOnCreate: !0,
|
|
15
20
|
interactive: !0,
|
|
16
21
|
trigger: "manual",
|
|
17
22
|
placement: "bottom-start"
|
|
18
|
-
})
|
|
23
|
+
}));
|
|
19
24
|
},
|
|
20
25
|
onUpdate: (e) => {
|
|
21
|
-
|
|
26
|
+
r = e, n?.updateProps(r), e.clientRect && t && !t.state.isDestroyed && t.setProps({
|
|
22
27
|
getReferenceClientRect: e.clientRect
|
|
23
28
|
});
|
|
24
29
|
},
|
|
25
30
|
onKeyDown(e) {
|
|
26
|
-
return e.event.key === "Escape" &&
|
|
27
|
-
(
|
|
28
|
-
).length === 0 && this.onExit(),
|
|
31
|
+
return e.event.key === "Escape" && t && !t.state.isDestroyed ? (t.hide(), !0) : (e.event.key === "Enter" && r.items.filter(
|
|
32
|
+
(i) => i.title.toLowerCase().startsWith(r.query.toLowerCase())
|
|
33
|
+
).length === 0 && this.onExit(), n?.ref?.onKeyDown(e) || !1);
|
|
29
34
|
},
|
|
30
35
|
onExit() {
|
|
31
|
-
|
|
36
|
+
t && !t.state.isDestroyed && t.destroy(), n?.destroy();
|
|
32
37
|
}
|
|
33
38
|
};
|
|
34
39
|
};
|
|
35
40
|
export {
|
|
36
|
-
|
|
41
|
+
u as default
|
|
37
42
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Editor, Extension } from "@tiptap/core";
|
|
2
|
+
import { Node as TiptapNode } from "@tiptap/pm/model";
|
|
3
|
+
export declare const SCRIBE_TABLE_OF_CONTENTS_META = "scribeTableOfContents";
|
|
4
|
+
type ScrollParent = HTMLElement | Window;
|
|
5
|
+
export type ScribeTableOfContentsItem = {
|
|
6
|
+
dom: HTMLElement;
|
|
7
|
+
editor: Editor;
|
|
8
|
+
id: string;
|
|
9
|
+
isActive: boolean;
|
|
10
|
+
isScrolledOver: boolean;
|
|
11
|
+
itemIndex: number;
|
|
12
|
+
level: number;
|
|
13
|
+
node: TiptapNode;
|
|
14
|
+
originalLevel: number;
|
|
15
|
+
pos: number;
|
|
16
|
+
textContent: string;
|
|
17
|
+
};
|
|
18
|
+
export type ScribeTableOfContentsChangeHandler = (items: ScribeTableOfContentsItem[], isCreate?: boolean) => void;
|
|
19
|
+
export type ScribeTableOfContentsScrollTarget = ScribeTableOfContentsItem | string;
|
|
20
|
+
type ScribeTableOfContentsOptions = {
|
|
21
|
+
anchorTypes: string[];
|
|
22
|
+
onUpdate?: ScribeTableOfContentsChangeHandler;
|
|
23
|
+
};
|
|
24
|
+
type ScribeTableOfContentsStorage = {
|
|
25
|
+
anchors: HTMLElement[];
|
|
26
|
+
content: ScribeTableOfContentsItem[];
|
|
27
|
+
hasCreated: boolean;
|
|
28
|
+
lastSignature: string;
|
|
29
|
+
rafId: number | null;
|
|
30
|
+
refresh: () => void;
|
|
31
|
+
scheduleRefresh: () => void;
|
|
32
|
+
scrollHandler: () => void;
|
|
33
|
+
scrollParent: ScrollParent | null;
|
|
34
|
+
updateScrollParent: () => void;
|
|
35
|
+
};
|
|
36
|
+
declare module "@tiptap/core" {
|
|
37
|
+
interface Commands<ReturnType> {
|
|
38
|
+
scribeTableOfContents: {
|
|
39
|
+
updateScribeTableOfContents: () => ReturnType;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
interface Storage {
|
|
43
|
+
scribeTableOfContents: ScribeTableOfContentsStorage;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export declare const ScribeTableOfContents: Extension<ScribeTableOfContentsOptions, ScribeTableOfContentsStorage>;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=tableOfContents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableOfContents.d.ts","sourceRoot":"","sources":["../../../../lib/components/Scribe/extension/tableOfContents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGtD,eAAO,MAAM,6BAA6B,0BAA0B,CAAC;AAErE,KAAK,YAAY,GAAG,WAAW,GAAG,MAAM,CAAC;AAOzC,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,WAAW,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG,CAC/C,KAAK,EAAE,yBAAyB,EAAE,EAClC,QAAQ,CAAC,EAAE,OAAO,KACf,IAAI,CAAC;AAEV,MAAM,MAAM,iCAAiC,GAAG,yBAAyB,GAAG,MAAM,CAAC;AAEnF,KAAK,4BAA4B,GAAG;IAClC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,kCAAkC,CAAC;CAC/C,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,EAAE,yBAAyB,EAAE,CAAC;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,IAAI,CAAC;CAChC,CAAC;AAmPF,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,qBAAqB,EAAE;YACrB,2BAA2B,EAAE,MAAM,UAAU,CAAC;SAC/C,CAAC;KACH;IAED,UAAU,OAAO;QACf,qBAAqB,EAAE,4BAA4B,CAAC;KACrD;CACF;AAED,eAAO,MAAM,qBAAqB,uEA8JhC,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { P as g, a as f, b as p } from "../../../index-BiBV5TQx.js";
|
|
2
|
+
const c = "scribeTableOfContents", v = new g("scribeTableOfContents"), w = (e) => e.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "heading", C = (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
|
+
}, S = (e) => (e[e.length - 1]?.itemIndex || 0) + 1, T = (e, t, n) => {
|
|
6
|
+
if (e.textContent.length === 0)
|
|
7
|
+
return null;
|
|
8
|
+
const o = w(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 = T(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(c, !0).setMeta("addToHistory", !1) : null;
|
|
22
|
+
}, b = (e) => {
|
|
23
|
+
const { overflowY: t } = window.getComputedStyle(e);
|
|
24
|
+
return /(auto|scroll|overlay)/.test(t) && e.scrollHeight > e.clientHeight;
|
|
25
|
+
}, m = (e) => {
|
|
26
|
+
let t = e.parentElement;
|
|
27
|
+
for (; t; ) {
|
|
28
|
+
if (b(t))
|
|
29
|
+
return t;
|
|
30
|
+
t = t.parentElement;
|
|
31
|
+
}
|
|
32
|
+
return window;
|
|
33
|
+
}, H = (e) => typeof Window < "u" && e instanceof Window, O = (e) => H(e) ? 32 : e.getBoundingClientRect().top + 32, I = (e, t) => {
|
|
34
|
+
const n = e.view.nodeDOM(t);
|
|
35
|
+
return n instanceof HTMLElement ? n : null;
|
|
36
|
+
}, x = (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
|
+
}, y = (e, t) => {
|
|
42
|
+
if (!t)
|
|
43
|
+
return e;
|
|
44
|
+
const n = O(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
|
+
}, A = (e, t, n) => {
|
|
54
|
+
const o = x(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, u = C(r, s), h = S(s);
|
|
60
|
+
s.push({
|
|
61
|
+
dom: i,
|
|
62
|
+
editor: e,
|
|
63
|
+
id: a,
|
|
64
|
+
isActive: !1,
|
|
65
|
+
isScrolledOver: !1,
|
|
66
|
+
itemIndex: h,
|
|
67
|
+
level: u,
|
|
68
|
+
node: r.node,
|
|
69
|
+
originalLevel: l,
|
|
70
|
+
pos: r.pos,
|
|
71
|
+
textContent: r.node.textContent
|
|
72
|
+
});
|
|
73
|
+
}), y(s, n);
|
|
74
|
+
}, L = (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 = L(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
|
+
}, M = f.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
|
+
rafId: null,
|
|
102
|
+
refresh: () => null,
|
|
103
|
+
scheduleRefresh: () => null,
|
|
104
|
+
scrollHandler: () => null,
|
|
105
|
+
scrollParent: null,
|
|
106
|
+
updateScrollParent: () => null
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
addGlobalAttributes() {
|
|
110
|
+
return [
|
|
111
|
+
{
|
|
112
|
+
types: this.options.anchorTypes,
|
|
113
|
+
attributes: {
|
|
114
|
+
"data-toc-id": {
|
|
115
|
+
default: null,
|
|
116
|
+
renderHTML: (e) => {
|
|
117
|
+
const t = e["data-toc-id"];
|
|
118
|
+
return t ? { "data-toc-id": t } : {};
|
|
119
|
+
},
|
|
120
|
+
parseHTML: (e) => e.getAttribute("data-toc-id")
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
},
|
|
126
|
+
addCommands() {
|
|
127
|
+
return {
|
|
128
|
+
updateScribeTableOfContents: () => ({ dispatch: e }) => (e && this.storage.refresh(), !0)
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
addProseMirrorPlugins() {
|
|
132
|
+
return [
|
|
133
|
+
new p({
|
|
134
|
+
key: v,
|
|
135
|
+
appendTransaction: (e, t, n) => typeof window > "u" || e.some(
|
|
136
|
+
(s) => s.getMeta(c) || s.getMeta("composition")
|
|
137
|
+
) || !e.some((s) => s.docChanged) ? null : d(n, this.options.anchorTypes)
|
|
138
|
+
})
|
|
139
|
+
];
|
|
140
|
+
},
|
|
141
|
+
onCreate() {
|
|
142
|
+
if (typeof window > "u" || !this.editor.view)
|
|
143
|
+
return;
|
|
144
|
+
this.storage.scrollHandler = () => {
|
|
145
|
+
this.storage.refresh();
|
|
146
|
+
}, this.storage.updateScrollParent = () => {
|
|
147
|
+
const t = m(this.editor.view.dom);
|
|
148
|
+
this.storage.scrollParent !== t && (this.storage.scrollParent?.removeEventListener("scroll", this.storage.scrollHandler), this.storage.scrollParent = t, this.storage.scrollParent.addEventListener("scroll", this.storage.scrollHandler));
|
|
149
|
+
}, this.storage.refresh = () => {
|
|
150
|
+
if (this.editor.isDestroyed)
|
|
151
|
+
return;
|
|
152
|
+
this.storage.updateScrollParent();
|
|
153
|
+
const t = A(
|
|
154
|
+
this.editor,
|
|
155
|
+
this.options.anchorTypes,
|
|
156
|
+
this.storage.scrollParent
|
|
157
|
+
);
|
|
158
|
+
P(this.storage, this.options, t);
|
|
159
|
+
}, this.storage.scheduleRefresh = () => {
|
|
160
|
+
this.storage.rafId !== null && window.cancelAnimationFrame(this.storage.rafId), this.storage.rafId = window.requestAnimationFrame(() => {
|
|
161
|
+
this.storage.rafId = null, this.storage.refresh();
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const e = d(
|
|
165
|
+
this.editor.state,
|
|
166
|
+
this.options.anchorTypes
|
|
167
|
+
);
|
|
168
|
+
e && this.editor.view.dispatch(e), this.storage.scheduleRefresh();
|
|
169
|
+
},
|
|
170
|
+
onTransaction({ transaction: e }) {
|
|
171
|
+
e.docChanged && this.storage.scheduleRefresh();
|
|
172
|
+
},
|
|
173
|
+
onDestroy() {
|
|
174
|
+
typeof window < "u" && this.storage.rafId !== null && window.cancelAnimationFrame(this.storage.rafId), this.storage.scrollParent?.removeEventListener("scroll", this.storage.scrollHandler);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
export {
|
|
178
|
+
c as SCRIBE_TABLE_OF_CONTENTS_META,
|
|
179
|
+
M as ScribeTableOfContents
|
|
180
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import "katex/dist/katex.css";
|
|
2
2
|
import { ClassValue } from "clsx";
|
|
3
|
+
import type { ScribeTableOfContentsChangeHandler, ScribeTableOfContentsScrollTarget } from "./extension/tableOfContents";
|
|
3
4
|
import { Content, Editor, Extension, JSONContent, UseEditorOptions } from "@tiptap/react";
|
|
4
5
|
import { KeyboardEventHandler } from "react";
|
|
6
|
+
export type { ScribeTableOfContentsChangeHandler, ScribeTableOfContentsItem, ScribeTableOfContentsScrollTarget, } from "./extension/tableOfContents";
|
|
5
7
|
export type ScribeOnChangeContents = {
|
|
6
8
|
jsonContent: Content;
|
|
7
9
|
htmlContent: Content;
|
|
@@ -12,10 +14,16 @@ export interface ScribeRef {
|
|
|
12
14
|
resetContent: () => void;
|
|
13
15
|
getContent: (contentType: "html" | "json" | "markdown") => string | JSONContent | undefined;
|
|
14
16
|
setContent: (content: Content) => void;
|
|
17
|
+
/** @experimental The table of contents API may change while we stabilize this behavior. */
|
|
18
|
+
scrollToTableOfContentsItem: (target: ScribeTableOfContentsScrollTarget) => void;
|
|
15
19
|
editor: Editor;
|
|
16
20
|
}
|
|
17
21
|
export interface ScribeProps {
|
|
18
22
|
onContentChange?: (content: ScribeOnChangeContents) => void;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Controlled content updates are being phased out. Prefer
|
|
25
|
+
* `ScribeRef.setContent` for programmatic updates after mount.
|
|
26
|
+
*/
|
|
19
27
|
content?: string;
|
|
20
28
|
editable?: boolean;
|
|
21
29
|
autoFocus?: boolean;
|
|
@@ -29,8 +37,11 @@ export interface ScribeProps {
|
|
|
29
37
|
mainContainerStyle?: React.CSSProperties;
|
|
30
38
|
mainContainerClassName?: ClassValue;
|
|
31
39
|
onKeyDown?: KeyboardEventHandler;
|
|
32
|
-
darkMode?: boolean;
|
|
33
40
|
mobile?: boolean;
|
|
41
|
+
/** @experimental Enables Scribe's app-owned table-of-contents API. */
|
|
42
|
+
enableTableOfContents?: boolean;
|
|
43
|
+
/** @experimental Receives the current table-of-contents items when they change. */
|
|
44
|
+
onTableOfContentsChange?: ScribeTableOfContentsChangeHandler;
|
|
34
45
|
}
|
|
35
46
|
export declare const Scribe: import("react").ForwardRefExoticComponent<ScribeProps & import("react").RefAttributes<ScribeRef>>;
|
|
36
47
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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;
|
|
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;AAIxC,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,kCAAkC,EAClC,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,EAAE,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,KAAK,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IAC5F,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,2FAA2F;IAC3F,2BAA2B,EAAE,CAAC,MAAM,EAAE,iCAAiC,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,sEAAsE;IACtE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mFAAmF;IACnF,uBAAuB,CAAC,EAAE,kCAAkC,CAAC;CAC9D;AAED,eAAO,MAAM,MAAM,mGAyMjB,CAAC"}
|
|
@@ -1,106 +1,152 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import "../../
|
|
6
|
-
import "../../
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { E as
|
|
10
|
-
import { forwardRef as
|
|
11
|
-
import { ListOptionBar as
|
|
12
|
-
import '../../assets/index.css';const
|
|
1
|
+
import { jsxs as x, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { B as A, c as b } from "../../BarMenu-DaKIz3zZ.js";
|
|
3
|
+
import { html2md as I } from "../../utils/html-to-markdown.js";
|
|
4
|
+
import "../../markdown-to-html-pL7ckd-m.js";
|
|
5
|
+
import "../../purify.es-exIQuqhb.js";
|
|
6
|
+
import { E as F } from "../../index-BiBV5TQx.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-DxF-1P4n.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 '../../assets/index.css';const it = K((h, B) => {
|
|
13
13
|
const {
|
|
14
|
-
autoFocus:
|
|
15
|
-
content:
|
|
14
|
+
autoFocus: g = !1,
|
|
15
|
+
content: i,
|
|
16
16
|
editable: o = !0,
|
|
17
|
-
editorProps:
|
|
18
|
-
extensions:
|
|
19
|
-
onContentChange:
|
|
20
|
-
showBarMenu:
|
|
21
|
-
editorContentStyle:
|
|
22
|
-
editorContentClassName:
|
|
23
|
-
mainContainerStyle:
|
|
24
|
-
mainContainerClassName:
|
|
25
|
-
onKeyDown:
|
|
26
|
-
externalEditor:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
editorProps: d,
|
|
18
|
+
extensions: L,
|
|
19
|
+
onContentChange: l,
|
|
20
|
+
showBarMenu: R = !0,
|
|
21
|
+
editorContentStyle: j,
|
|
22
|
+
editorContentClassName: H,
|
|
23
|
+
mainContainerStyle: P,
|
|
24
|
+
mainContainerClassName: k,
|
|
25
|
+
onKeyDown: _,
|
|
26
|
+
externalEditor: T,
|
|
27
|
+
mobile: D,
|
|
28
|
+
onTableOfContentsChange: f
|
|
29
|
+
} = h, O = E(!T && i !== void 0), y = E([]), M = E(f);
|
|
30
|
+
c(() => {
|
|
31
|
+
M.current = f;
|
|
32
|
+
}, [f]);
|
|
33
|
+
const z = r(
|
|
34
|
+
(e, s) => {
|
|
35
|
+
y.current = e, M.current?.(e, s);
|
|
36
|
+
},
|
|
37
|
+
[]
|
|
38
|
+
), u = r(
|
|
39
|
+
({ editor: e, transaction: s }) => {
|
|
40
|
+
if (s.getMeta(U))
|
|
41
|
+
return;
|
|
42
|
+
const n = e.getHTML(), m = e.getJSON(), p = !o;
|
|
43
|
+
l && l({
|
|
44
|
+
jsonContent: e.isEmpty ? "" : m,
|
|
45
|
+
htmlContent: e.isEmpty ? "" : n,
|
|
46
|
+
markdownContent: e.isEmpty ? "" : I(n),
|
|
47
|
+
source: p ? "programmatic" : "user"
|
|
37
48
|
});
|
|
38
49
|
},
|
|
39
|
-
[o,
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
|
|
50
|
+
[o, l]
|
|
51
|
+
), [t] = q(() => T ?? new F({
|
|
52
|
+
...d,
|
|
53
|
+
content: i ?? d?.content,
|
|
43
54
|
editable: o,
|
|
44
|
-
extensions: [
|
|
55
|
+
extensions: [
|
|
56
|
+
...J({
|
|
57
|
+
...h,
|
|
58
|
+
onTableOfContentsChange: z
|
|
59
|
+
}),
|
|
60
|
+
...L ?? []
|
|
61
|
+
],
|
|
45
62
|
editorProps: {
|
|
46
63
|
attributes: {
|
|
47
64
|
class: "scribe"
|
|
48
65
|
},
|
|
49
|
-
...
|
|
66
|
+
...d?.editorProps
|
|
50
67
|
}
|
|
51
|
-
}))
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
t
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
})), v = r(() => {
|
|
69
|
+
t.commands.setContent("");
|
|
70
|
+
}, [t]), w = r(
|
|
71
|
+
(e) => {
|
|
72
|
+
const s = {
|
|
73
|
+
html: () => t.getHTML(),
|
|
74
|
+
json: () => t.getJSON(),
|
|
75
|
+
markdown: () => I(t.getHTML())
|
|
76
|
+
};
|
|
77
|
+
return t.isEmpty ? "" : s[e]?.();
|
|
78
|
+
},
|
|
79
|
+
[t]
|
|
80
|
+
), N = r(
|
|
81
|
+
(e) => {
|
|
82
|
+
t.commands.setContent(e);
|
|
83
|
+
},
|
|
84
|
+
[t]
|
|
85
|
+
), S = r(
|
|
86
|
+
(e) => {
|
|
87
|
+
const s = typeof e == "string" ? e : e.id, n = y.current.find((C) => C.id === s) ?? (typeof e == "string" ? void 0 : e);
|
|
88
|
+
if (!n || t.isDestroyed)
|
|
89
|
+
return;
|
|
90
|
+
const m = t.view.nodeDOM(n.pos), p = m instanceof HTMLElement ? m : n.dom;
|
|
91
|
+
if (t.isEditable) {
|
|
92
|
+
const C = Math.max(
|
|
93
|
+
0,
|
|
94
|
+
Math.min(n.pos + n.node.nodeSize - 1, t.state.doc.content.size)
|
|
95
|
+
);
|
|
96
|
+
t.commands.focus(C, { scrollIntoView: !1 });
|
|
97
|
+
}
|
|
98
|
+
p.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
99
|
+
},
|
|
100
|
+
[t]
|
|
101
|
+
);
|
|
102
|
+
return G(B, () => ({
|
|
103
|
+
resetContent: v,
|
|
104
|
+
setContent: N,
|
|
105
|
+
getContent: w,
|
|
106
|
+
scrollToTableOfContentsItem: S,
|
|
68
107
|
editor: t
|
|
69
|
-
}), [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, [
|
|
108
|
+
}), [t, w, v, S, N]), c(() => {
|
|
109
|
+
if (i !== void 0) {
|
|
110
|
+
if (O.current) {
|
|
111
|
+
O.current = !1;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
t.commands.setContent(i, { emitUpdate: !1 });
|
|
115
|
+
}
|
|
116
|
+
}, [i, t]), c(() => {
|
|
117
|
+
t.setEditable(!!o);
|
|
118
|
+
}, [o, t]), c(() => (t.off("update"), t.on("update", u), () => {
|
|
119
|
+
t.off("update", u);
|
|
120
|
+
}), [t, u]), c(() => {
|
|
121
|
+
g && t.commands.focus("end");
|
|
122
|
+
}, [g, t]), /* @__PURE__ */ x(
|
|
78
123
|
"div",
|
|
79
124
|
{
|
|
80
|
-
className:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
),
|
|
125
|
+
className: b("scribe-wrapper", "scribe-root", k),
|
|
126
|
+
"data-scribe-root": !0,
|
|
127
|
+
style: P,
|
|
84
128
|
children: [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
129
|
+
/* @__PURE__ */ x("div", { className: b("scribe-frame", o && "scribe-frame--editable"), children: [
|
|
130
|
+
t && R ? /* @__PURE__ */ a(A, { editor: t }) : null,
|
|
131
|
+
/* @__PURE__ */ a(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
className: b(
|
|
135
|
+
"scribe-content",
|
|
136
|
+
o && "scribe-content--editable",
|
|
137
|
+
H
|
|
138
|
+
),
|
|
139
|
+
style: j,
|
|
140
|
+
children: /* @__PURE__ */ a(V, { editor: t, onKeyDown: _ })
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
D ? /* @__PURE__ */ a(Q, { editor: t }) : null
|
|
144
|
+
] }),
|
|
145
|
+
/* @__PURE__ */ a("div", { className: "scribe-popup-root", "data-scribe-popup-root": !0 })
|
|
100
146
|
]
|
|
101
147
|
}
|
|
102
|
-
)
|
|
148
|
+
);
|
|
103
149
|
});
|
|
104
150
|
export {
|
|
105
|
-
|
|
151
|
+
it as Scribe
|
|
106
152
|
};
|