@w100n/documents 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SheetView-4TPL7DES.js → SheetView-72KXS4DM.js} +4 -4
- package/dist/{TextEditor-VBHWUOZR.js → TextEditor-NSICFE6U.js} +173 -5
- package/dist/TextEditor-NSICFE6U.js.map +1 -0
- package/dist/{chunk-DR3TTJWZ.js → chunk-M4OQG3EN.js} +388 -36
- package/dist/chunk-M4OQG3EN.js.map +1 -0
- package/dist/{chunk-RCQODE2Z.js → chunk-OXC4PUOC.js} +2 -2
- package/dist/{chunk-5MH4WDW4.js → chunk-Z7UNJ4ND.js} +66 -10
- package/dist/chunk-Z7UNJ4ND.js.map +1 -0
- package/dist/collab.cjs +450 -44
- package/dist/collab.cjs.map +1 -1
- package/dist/collab.js +2 -2
- package/dist/index.cjs +712 -131
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +159 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/TextEditor-VBHWUOZR.js.map +0 -1
- package/dist/chunk-5MH4WDW4.js.map +0 -1
- package/dist/chunk-DR3TTJWZ.js.map +0 -1
- /package/dist/{SheetView-4TPL7DES.js.map → SheetView-72KXS4DM.js.map} +0 -0
- /package/dist/{chunk-RCQODE2Z.js.map → chunk-OXC4PUOC.js.map} +0 -0
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
pending,
|
|
6
6
|
save,
|
|
7
7
|
seed
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-Z7UNJ4ND.js";
|
|
9
9
|
|
|
10
10
|
// src/editor/live.ts
|
|
11
11
|
import { HocuspocusProvider } from "@hocuspocus/provider";
|
|
@@ -193,4 +193,4 @@ ${id}`, id, kind, doc, host2, { id: me.id, name: me.name, language }, edit) : ne
|
|
|
193
193
|
export {
|
|
194
194
|
useLive
|
|
195
195
|
};
|
|
196
|
-
//# sourceMappingURL=chunk-
|
|
196
|
+
//# sourceMappingURL=chunk-OXC4PUOC.js.map
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
entry,
|
|
6
6
|
escape,
|
|
7
7
|
inflate,
|
|
8
|
+
mathml,
|
|
8
9
|
parse,
|
|
9
10
|
readDocx,
|
|
10
11
|
texts,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
unzip,
|
|
13
14
|
writeDocx,
|
|
14
15
|
zip
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-M4OQG3EN.js";
|
|
16
17
|
import {
|
|
17
18
|
a1,
|
|
18
19
|
box,
|
|
@@ -35,7 +36,7 @@ import { prosemirrorJSONToYXmlFragment, updateYFragment, yXmlFragmentToProseMirr
|
|
|
35
36
|
import * as Y2 from "yjs";
|
|
36
37
|
|
|
37
38
|
// package.json
|
|
38
|
-
var version = "0.
|
|
39
|
+
var version = "0.15.0";
|
|
39
40
|
|
|
40
41
|
// src/editor/extensions.ts
|
|
41
42
|
import { Extension as Extension2, Mark, Node } from "@tiptap/core";
|
|
@@ -66,6 +67,10 @@ function measure(view) {
|
|
|
66
67
|
const room = page.height - top - bottom;
|
|
67
68
|
const els = [...view.dom.children];
|
|
68
69
|
const gaps = [];
|
|
70
|
+
const line = page.width - page.margins[1] - page.margins[3];
|
|
71
|
+
const area = (list) => list.length ? 14 + list.reduce((h, text) => h + 15 * Math.max(1, Math.ceil(text.length * 5.6 / line)), 0) : 0;
|
|
72
|
+
let notes2 = [];
|
|
73
|
+
let count = 0;
|
|
69
74
|
let i = 0;
|
|
70
75
|
let shift = 0;
|
|
71
76
|
let start = 0;
|
|
@@ -79,17 +84,25 @@ function measure(view) {
|
|
|
79
84
|
if (!el) return;
|
|
80
85
|
const y = el.offsetTop - shift;
|
|
81
86
|
const end = y + el.offsetHeight;
|
|
87
|
+
const mine = [];
|
|
88
|
+
node.descendants((d) => {
|
|
89
|
+
if (d.type.name === "footnote") mine.push(`${count + mine.length + 1} ${d.attrs.text}`);
|
|
90
|
+
});
|
|
82
91
|
if (node.type.name === "pageBreak") {
|
|
83
|
-
gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1 });
|
|
92
|
+
gaps.push({ pos: offset + node.nodeSize, height: start + room - end + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
|
|
93
|
+
notes2 = [];
|
|
84
94
|
start = end;
|
|
85
|
-
} else if (end > start + room && y > start) {
|
|
86
|
-
gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1 });
|
|
95
|
+
} else if (end > start + room - area([...notes2, ...mine]) && y > start) {
|
|
96
|
+
gaps.push({ pos: offset, height: start + room - y + bottom + 24 + top, page: gaps.length + 1, notes: notes2 });
|
|
97
|
+
notes2 = [];
|
|
87
98
|
start = y;
|
|
88
99
|
}
|
|
100
|
+
notes2.push(...mine);
|
|
101
|
+
count += mine.length;
|
|
89
102
|
while (end > start + room) start += room;
|
|
90
103
|
last = end;
|
|
91
104
|
});
|
|
92
|
-
gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last), page: gaps.length + 1, end: true });
|
|
105
|
+
gaps.push({ pos: view.state.doc.content.size, height: Math.max(0, start + room - last), page: gaps.length + 1, end: true, notes: notes2 });
|
|
93
106
|
return gaps.map((g) => ({ ...g, height: Math.max(0, Math.round(g.height)) }));
|
|
94
107
|
}
|
|
95
108
|
var Pager = Extension.create({
|
|
@@ -111,7 +124,7 @@ var Pager = Extension.create({
|
|
|
111
124
|
if (!view.dom.isConnected) return;
|
|
112
125
|
const gaps = measure(view);
|
|
113
126
|
const { marks } = paging.getState(view.state);
|
|
114
|
-
const next = gaps.map((g) => `${g.pos}:${g.height}`).join() + `|${marks.header}|${marks.footer}`;
|
|
127
|
+
const next = gaps.map((g) => `${g.pos}:${g.height}:${g.notes.join("\n")}`).join() + `|${marks.header}|${marks.footer}`;
|
|
115
128
|
if (next === sig) return;
|
|
116
129
|
sig = next;
|
|
117
130
|
const line = (parent, cls, text) => {
|
|
@@ -136,8 +149,20 @@ var Pager = Extension.create({
|
|
|
136
149
|
el.contentEditable = "false";
|
|
137
150
|
line(el, "w100n-text-foot", marks.footer);
|
|
138
151
|
if (!g.end) line(el, "w100n-text-head", marks.header);
|
|
152
|
+
if (g.notes.length) {
|
|
153
|
+
const list = document.createElement("div");
|
|
154
|
+
list.className = "w100n-text-footnotes";
|
|
155
|
+
for (const note of g.notes) {
|
|
156
|
+
const p = document.createElement("p");
|
|
157
|
+
const n = document.createElement("sup");
|
|
158
|
+
n.textContent = note.slice(0, note.indexOf(" "));
|
|
159
|
+
p.append(n, note.slice(note.indexOf(" ")));
|
|
160
|
+
list.append(p);
|
|
161
|
+
}
|
|
162
|
+
el.append(list);
|
|
163
|
+
}
|
|
139
164
|
return el;
|
|
140
|
-
}, { key: `${g.pos}:${g.height}:${g.page}:${marks.header}:${marks.footer}`, side: -1, ignoreSelection: true }))]);
|
|
165
|
+
}, { key: `${g.pos}:${g.height}:${g.page}:${marks.header}:${marks.footer}:${g.notes.join("\n")}`, side: -1, ignoreSelection: true }))]);
|
|
141
166
|
view.dispatch(view.state.tr.setMeta(paging, { set }).setMeta("addToHistory", false));
|
|
142
167
|
};
|
|
143
168
|
const later = (ms) => {
|
|
@@ -309,6 +334,37 @@ var PageBreak = Node.create({
|
|
|
309
334
|
return ["div", { "data-page-break": "", "data-label": this.options.label, class: "w100n-text-break", contenteditable: "false" }];
|
|
310
335
|
}
|
|
311
336
|
});
|
|
337
|
+
var Formula = Node.create({
|
|
338
|
+
name: "math",
|
|
339
|
+
group: "inline",
|
|
340
|
+
inline: true,
|
|
341
|
+
atom: true,
|
|
342
|
+
selectable: true,
|
|
343
|
+
addAttributes: () => ({ latex: { default: "", parseHTML: (el) => el.getAttribute("data-math") ?? "" } }),
|
|
344
|
+
parseHTML: () => [{ tag: "span[data-math]" }],
|
|
345
|
+
renderHTML: ({ node }) => ["span", { "data-math": node.attrs.latex, class: "w100n-math" }],
|
|
346
|
+
addNodeView: () => ({ node }) => {
|
|
347
|
+
const dom = document.createElement("span");
|
|
348
|
+
dom.className = "w100n-math";
|
|
349
|
+
dom.dataset.math = node.attrs.latex;
|
|
350
|
+
dom.contentEditable = "false";
|
|
351
|
+
dom.innerHTML = mathml(node.attrs.latex);
|
|
352
|
+
return { dom };
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
var Footnote = Node.create({
|
|
356
|
+
name: "footnote",
|
|
357
|
+
group: "inline",
|
|
358
|
+
inline: true,
|
|
359
|
+
atom: true,
|
|
360
|
+
selectable: true,
|
|
361
|
+
addAttributes: () => ({
|
|
362
|
+
id: { default: null, parseHTML: (el) => el.getAttribute("data-note-id") },
|
|
363
|
+
text: { default: "", parseHTML: (el) => el.getAttribute("title") ?? "" }
|
|
364
|
+
}),
|
|
365
|
+
parseHTML: () => [{ tag: "sup[data-footnote]" }],
|
|
366
|
+
renderHTML: ({ node }) => ["sup", { "data-footnote": "", "data-note-id": node.attrs.id ?? void 0, title: node.attrs.text, class: "w100n-fn", contenteditable: "false" }]
|
|
367
|
+
});
|
|
312
368
|
var headings = (doc, after) => {
|
|
313
369
|
const found = [];
|
|
314
370
|
doc.descendants((node, pos) => {
|
|
@@ -631,7 +687,7 @@ function kit(kind, t, live) {
|
|
|
631
687
|
Toc.configure({ relative: kind === "markdown", label: t.toc, empty: t.tocEmpty }),
|
|
632
688
|
Note,
|
|
633
689
|
Notes,
|
|
634
|
-
...kind === "docx" ? [Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
|
|
690
|
+
...kind === "docx" ? [Formula, Footnote, Pager, Locks.configure({ label: t.locked }), revision("insertion", "ins"), revision("deletion", "del"), Suggest] : [],
|
|
635
691
|
...live ? [Collaboration.configure({ document: live.doc }), CollaborationCaret.configure({ provider: live.link, user: live.user })] : []
|
|
636
692
|
];
|
|
637
693
|
}
|
|
@@ -3557,4 +3613,4 @@ export {
|
|
|
3557
3613
|
applyText,
|
|
3558
3614
|
save
|
|
3559
3615
|
};
|
|
3560
|
-
//# sourceMappingURL=chunk-
|
|
3616
|
+
//# sourceMappingURL=chunk-Z7UNJ4ND.js.map
|