@fileverse-dev/ddoc 6.0.1-dist-slim.1 → 6.0.1-patch-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.
@@ -1,143 +0,0 @@
1
- var k = Object.defineProperty;
2
- var v = (t, o, r) => o in t ? k(t, o, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[o] = r;
3
- var d = (t, o, r) => v(t, typeof o != "symbol" ? o + "" : o, r);
4
- import { jsx as C } from "react/jsx-runtime";
5
- import { useRef as m, useEffect as f } from "react";
6
- import { EditorState as b, Annotation as L, Transaction as S, RangeSetBuilder as y } from "@codemirror/state";
7
- import { EditorView as u, lineNumbers as D, highlightActiveLine as E, highlightActiveLineGutter as w, keymap as H, ViewPlugin as P, placeholder as N, Decoration as A } from "@codemirror/view";
8
- import { history as M, defaultKeymap as T, historyKeymap as W } from "@codemirror/commands";
9
- import { markdown as $ } from "@codemirror/lang-markdown";
10
- import { syntaxHighlighting as G, defaultHighlightStyle as K, syntaxTree as F } from "@codemirror/language";
11
- const I = "Write your ideas. Watch them grow. 🌱", h = L.define(), O = /^https?:\/\/\S+$/i, R = u.domEventHandlers({
12
- paste(t, o) {
13
- var c, a;
14
- const r = (a = (c = t.clipboardData) == null ? void 0 : c.getData("text/plain")) == null ? void 0 : a.trim();
15
- if (!r || !O.test(r)) return !1;
16
- const { from: s, to: e } = o.state.selection.main, l = o.state.sliceDoc(s, e), n = l ? `[${l}](${r})` : `<${r}>`;
17
- return t.preventDefault(), o.dispatch({
18
- changes: { from: s, to: e, insert: n },
19
- selection: { anchor: s + n.length }
20
- }), !0;
21
- }
22
- }), U = A.mark({ class: "cm-md-link" }), _ = /* @__PURE__ */ new Set(["Link", "Autolink"]), p = (t) => {
23
- const o = new y();
24
- for (const { from: r, to: s } of t.visibleRanges)
25
- F(t.state).iterate({
26
- from: r,
27
- to: s,
28
- enter: (e) => {
29
- _.has(e.name) && e.to > e.from && o.add(e.from, e.to, U);
30
- }
31
- });
32
- return o.finish();
33
- }, j = P.fromClass(
34
- class {
35
- constructor(t) {
36
- d(this, "decorations");
37
- this.decorations = p(t);
38
- }
39
- update(t) {
40
- (t.docChanged || t.viewportChanged) && (this.decorations = p(t.view));
41
- }
42
- },
43
- { decorations: (t) => t.decorations }
44
- ), z = u.theme({
45
- "&": {
46
- height: "100%",
47
- fontSize: "14px",
48
- backgroundColor: "transparent",
49
- color: "hsl(var(--color-text-default))"
50
- },
51
- ".cm-scroller": {
52
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
53
- lineHeight: "1.7",
54
- padding: "12px 16px 12px 8px"
55
- },
56
- ".cm-content": { caretColor: "hsl(var(--color-text-default))", padding: "0" },
57
- "&.cm-focused": { outline: "none" },
58
- ".cm-gutters": {
59
- backgroundColor: "transparent",
60
- border: "none",
61
- color: "hsl(var(--color-text-secondary))"
62
- },
63
- ".cm-lineNumbers .cm-gutterElement": {
64
- minWidth: "26px",
65
- padding: "0 8px 0 4px"
66
- },
67
- ".cm-activeLine": { backgroundColor: "hsl(var(--color-bg-secondary))" },
68
- ".cm-activeLineGutter": { backgroundColor: "transparent" },
69
- ".cm-cursor, .cm-dropCursor": {
70
- borderLeftColor: "hsl(var(--color-text-default))"
71
- },
72
- // Markdown links use the editor's text-link token (override the default
73
- // syntax color, incl. the inner highlight spans).
74
- ".cm-md-link, .cm-md-link span": {
75
- color: "hsla(var(--color-text-link)) !important"
76
- }
77
- });
78
- function tt({
79
- value: t,
80
- onChange: o,
81
- onViewReady: r
82
- }) {
83
- const s = m(null), e = m(null), l = m(o);
84
- l.current = o;
85
- const n = m(r);
86
- return n.current = r, f(() => {
87
- var a;
88
- if (!s.current) return;
89
- const c = new u({
90
- parent: s.current,
91
- state: b.create({
92
- doc: t,
93
- extensions: [
94
- D(),
95
- E(),
96
- w(),
97
- M(),
98
- // Swallow Ctrl/Cmd+S so it doesn't open the browser "Save page"
99
- // dialog — there's no manual save in Split View (changes are live).
100
- H.of([
101
- { key: "Mod-s", run: () => !0, preventDefault: !0 },
102
- ...T,
103
- ...W
104
- ]),
105
- $(),
106
- G(K),
107
- j,
108
- R,
109
- N(I),
110
- u.lineWrapping,
111
- z,
112
- u.updateListener.of((i) => {
113
- const g = i.transactions.some(
114
- (x) => x.annotation(h)
115
- );
116
- i.docChanged && !g && l.current(i.state.doc.toString());
117
- })
118
- ]
119
- })
120
- });
121
- return e.current = c, (a = n.current) == null || a.call(n, c), () => {
122
- var i;
123
- (i = n.current) == null || i.call(n, null), c.destroy(), e.current = null;
124
- };
125
- }, []), f(() => {
126
- const c = e.current;
127
- if (!c) return;
128
- const a = c.state.doc.toString();
129
- t !== a && c.dispatch({
130
- changes: { from: 0, to: a.length, insert: t },
131
- // Keep the seed out of the undo history: its base state is the empty
132
- // mount-time doc, so an undo would revert the pane to empty and the
133
- // change listener would replace the whole document with nothing.
134
- annotations: [
135
- h.of(!0),
136
- S.addToHistory.of(!1)
137
- ]
138
- });
139
- }, [t]), /* @__PURE__ */ C("div", { ref: s, className: "w-full h-full overflow-auto" });
140
- }
141
- export {
142
- tt as default
143
- };
@@ -1,284 +0,0 @@
1
- import { fromUint8Array as R, toUint8Array as p } from "js-base64";
2
- import * as d from "yjs";
3
- const M = "default", E = "Tab 1", Y = "ddocTabs", F = "tabs_order", S = "tabs_name_registry", N = "tabs_emoji_registry", U = "tabs_state", L = "tabs_delete_registry", A = "activeTabId";
4
- function m(e) {
5
- return {
6
- order: e.getArray(F),
7
- nameById: e.getMap(S),
8
- emojiById: e.getMap(N),
9
- tabState: e.getMap(U),
10
- // Soft-deleted tabs keep their fragment for undo and late peer updates.
11
- // This tombstone stops self-heal from resurrecting deleted tabs from stale tab metadata.
12
- deletedById: e.getMap(L)
13
- };
14
- }
15
- function h(e, t) {
16
- if (e)
17
- try {
18
- if (Array.isArray(e)) {
19
- const n = e.map((r) => p(r));
20
- d.applyUpdate(t, d.mergeUpdates(n), "self");
21
- return;
22
- }
23
- d.applyUpdate(t, p(e), "self");
24
- } catch (n) {
25
- console.log(n);
26
- }
27
- }
28
- function g(e) {
29
- return e ? e.toArray().filter((t) => typeof t == "string") : [];
30
- }
31
- function C(e) {
32
- const t = e.getMap(Y), n = t.get("order"), r = t.get("tabs"), s = t.get("activeTabId"), l = g(
33
- n instanceof d.Array ? n : null
34
- ), o = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
35
- return r instanceof d.Map && r.forEach((u, a) => {
36
- if (!(u instanceof d.Map) || typeof a != "string") return;
37
- const i = u.get("name"), c = u.get("emoji");
38
- typeof i == "string" && o.set(a, i), (typeof c == "string" || c === null) && f.set(a, c);
39
- }), {
40
- order: l,
41
- names: o,
42
- emojis: f,
43
- activeTabId: s instanceof d.Text && s.toString() || null,
44
- deletedIds: /* @__PURE__ */ new Set(),
45
- hasData: l.length > 0 || o.size > 0 || f.size > 0 || s instanceof d.Text && s.length > 0
46
- };
47
- }
48
- function I(e) {
49
- const t = m(e), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
50
- t.nameById.forEach((f, u) => {
51
- typeof f == "string" && n.set(u, f);
52
- }), t.emojiById.forEach((f, u) => {
53
- (typeof f == "string" || f === null) && r.set(u, f);
54
- }), t.deletedById.forEach((f, u) => {
55
- f === !0 && s.add(u);
56
- });
57
- const l = t.tabState.get(A), o = typeof l == "string" ? l : null;
58
- return {
59
- order: g(t.order),
60
- names: n,
61
- emojis: r,
62
- activeTabId: o,
63
- deletedIds: s,
64
- hasData: t.order.length > 0 || t.nameById.size > 0 || t.emojiById.size > 0 || t.deletedById.size > 0 || o !== null
65
- };
66
- }
67
- function _(e) {
68
- const t = /* @__PURE__ */ new Set(), n = [];
69
- return e.forEach((r) => {
70
- t.has(r) || (t.add(r), n.push(r));
71
- }), n;
72
- }
73
- function j(e) {
74
- return e === 0 ? E : `Tab ${e + 1}`;
75
- }
76
- function K(e, t) {
77
- return _([
78
- ...e.order,
79
- ...t.order,
80
- ...Array.from(e.names.keys()),
81
- ...Array.from(e.emojis.keys()),
82
- ...Array.from(t.names.keys()),
83
- ...Array.from(t.emojis.keys())
84
- ]);
85
- }
86
- function b(e, t) {
87
- const n = new Set(e.deletedIds);
88
- t.forEach((a) => {
89
- a.deletedIds.forEach((i) => n.add(i));
90
- });
91
- const r = /* @__PURE__ */ new Set(), s = [];
92
- e.order.forEach((a) => {
93
- !n.has(a) && !r.has(a) && (r.add(a), s.push(a));
94
- });
95
- const l = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
96
- e.names.forEach((a, i) => {
97
- n.has(i) || l.set(i, a);
98
- }), e.emojis.forEach((a, i) => {
99
- n.has(i) || o.set(i, a);
100
- }), t.forEach((a) => {
101
- a.order.forEach((i) => {
102
- n.has(i) || (r.has(i) || (r.add(i), s.push(i)), !l.has(i) && a.names.has(i) && l.set(i, a.names.get(i) ?? E), o.has(i) || o.set(
103
- i,
104
- a.emojis.has(i) ? a.emojis.get(i) ?? null : null
105
- ));
106
- });
107
- }), s.forEach((a, i) => {
108
- l.has(a) || l.set(a, j(i)), (!o.has(a) || o.get(a) === void 0) && o.set(a, null);
109
- });
110
- const u = [
111
- e.activeTabId,
112
- ...t.map((a) => a.activeTabId)
113
- ].find(
114
- (a) => !!a && r.has(a) && !n.has(a)
115
- ) ?? s[0] ?? null;
116
- return {
117
- order: s,
118
- names: l,
119
- emojis: o,
120
- activeTabId: u,
121
- deletedIds: n
122
- };
123
- }
124
- function z(e, t, n) {
125
- const r = (n == null ? void 0 : n.createDefaultTabIfMissing) ?? !1, s = new Set(e.deletedIds), l = K(
126
- e,
127
- t
128
- ).filter((c) => !s.has(c)), o = _([
129
- ...e.order,
130
- ...t.order
131
- ]);
132
- l.forEach((c) => {
133
- o.includes(c) || o.push(c);
134
- }), o.length === 0 && r && o.push(M);
135
- const f = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
136
- o.forEach((c, D) => {
137
- const B = e.names.get(c) ?? t.names.get(c) ?? j(D), O = e.emojis.has(c) ? e.emojis.get(c) ?? null : t.emojis.has(c) ? t.emojis.get(c) ?? null : null;
138
- f.set(c, B), u.set(c, O);
139
- });
140
- const i = [
141
- e.activeTabId,
142
- t.activeTabId
143
- ].find(
144
- (c) => !!c && o.includes(c)
145
- ) ?? o[0] ?? null;
146
- return {
147
- order: o,
148
- names: f,
149
- emojis: u,
150
- activeTabId: i,
151
- deletedIds: s
152
- };
153
- }
154
- function k(e, t) {
155
- return e.length !== t.length ? !1 : e.every((n, r) => n === t[r]);
156
- }
157
- function V(e, t) {
158
- const n = g(e);
159
- return k(n, t) ? !1 : (e.length > 0 && e.delete(0, e.length), t.length > 0 && e.insert(0, t), !0);
160
- }
161
- function W(e, t, n) {
162
- const r = e.get(t);
163
- return n === null ? r === void 0 ? !1 : (e.delete(t), !0) : r === n ? !1 : (e.set(t, n), !0);
164
- }
165
- function T(e, t) {
166
- let n = !1;
167
- return Array.from(e.keys()).forEach((r) => {
168
- t.has(r) || (e.delete(r), n = !0);
169
- }), t.forEach((r, s) => {
170
- e.get(s) !== r && (e.set(s, r), n = !0);
171
- }), n;
172
- }
173
- function v(e, t, n = "self") {
174
- const r = m(e);
175
- let s = !1;
176
- const l = new Map(
177
- Array.from(t.deletedIds, (o) => [o, !0])
178
- );
179
- return e.transact(() => {
180
- t.order.forEach((o) => {
181
- e.getXmlFragment(o);
182
- }), s = V(r.order, t.order) || s, s = T(r.nameById, t.names) || s, s = T(r.emojiById, t.emojis) || s, s = W(
183
- r.tabState,
184
- A,
185
- t.activeTabId
186
- ) || s, s = T(r.deletedById, l) || s;
187
- }, n), s;
188
- }
189
- function y(e, t) {
190
- const n = I(e), r = C(e), s = z(
191
- n,
192
- r,
193
- t
194
- );
195
- return {
196
- tabSnapshotV2: n,
197
- legacySnapshot: r,
198
- resolvedTabState: s
199
- };
200
- }
201
- function w(e, t, n = "self") {
202
- const { resolvedTabState: r } = y(e, t);
203
- return v(e, r, n);
204
- }
205
- function P(e, t, n) {
206
- h(e, t);
207
- const r = w(t, {
208
- ...n,
209
- createDefaultTabIfMissing: (n == null ? void 0 : n.createDefaultTabIfMissing) ?? !0
210
- }), s = m(t);
211
- return {
212
- tabList: q(s),
213
- activeTabId: X(s) || M,
214
- didWrite: r
215
- };
216
- }
217
- function $(e) {
218
- return m(e);
219
- }
220
- function H(e, t, n = "self") {
221
- const r = w(e, t, n);
222
- return {
223
- ...m(e),
224
- didWrite: r
225
- };
226
- }
227
- function Q(e, t) {
228
- const n = e.map((o) => {
229
- const f = new d.Doc();
230
- return h(o, f), y(f, t).resolvedTabState;
231
- }), r = new d.Doc();
232
- h(e, r);
233
- const { resolvedTabState: s } = y(
234
- r,
235
- t
236
- ), l = b(
237
- s,
238
- n
239
- );
240
- return v(r, l), R(d.encodeStateAsUpdate(r));
241
- }
242
- function X(e) {
243
- const t = e.tabState.get(A);
244
- return typeof t == "string" ? t : null;
245
- }
246
- function G(e, t) {
247
- return e.nameById.has(t) ? {
248
- name: e.nameById.get(t) ?? E,
249
- emoji: e.emojiById.has(t) ? e.emojiById.get(t) ?? null : null
250
- } : null;
251
- }
252
- function q(e) {
253
- const t = /* @__PURE__ */ new Set();
254
- return g(e.order).filter((n) => t.has(n) ? !1 : (t.add(n), !0)).map((n) => {
255
- const r = G(
256
- e,
257
- n
258
- );
259
- return r ? {
260
- id: n,
261
- name: r.name,
262
- emoji: r.emoji
263
- } : null;
264
- }).filter((n) => n !== null);
265
- }
266
- function Z(e) {
267
- return e.toArray().map((t) => t instanceof d.XmlElement || t instanceof d.XmlText ? t.clone() : null).filter((t) => t !== null);
268
- }
269
- export {
270
- A,
271
- M as D,
272
- Y as L,
273
- F as O,
274
- U as S,
275
- G as a,
276
- X as b,
277
- Z as c,
278
- P as d,
279
- q as e,
280
- E as f,
281
- $ as g,
282
- Q as m,
283
- H as s
284
- };