@kernhq/module-quire 0.13.1 → 0.14.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/contract/models.d.ts +185 -0
- package/dist/contract/models.d.ts.map +1 -1
- package/dist/contract/models.js +133 -0
- package/dist/contract/models.js.map +1 -1
- package/dist/contract/permissions.d.ts +14 -0
- package/dist/contract/permissions.d.ts.map +1 -1
- package/dist/contract/permissions.js +82 -0
- package/dist/contract/permissions.js.map +1 -1
- package/dist/contract/properties.d.ts +4 -4
- package/dist/contract/router.d.ts +535 -8
- package/dist/contract/router.d.ts.map +1 -1
- package/dist/contract/router.js +133 -1
- package/dist/contract/router.js.map +1 -1
- package/dist/server/_impl.d.ts +519 -8
- package/dist/server/_impl.d.ts.map +1 -1
- package/dist/server/_impl.js +128 -0
- package/dist/server/_impl.js.map +1 -1
- package/dist/server/export/html.d.ts +67 -0
- package/dist/server/export/html.d.ts.map +1 -0
- package/dist/server/export/html.js +206 -0
- package/dist/server/export/html.js.map +1 -0
- package/dist/server/export/markdown.d.ts +51 -0
- package/dist/server/export/markdown.d.ts.map +1 -0
- package/dist/server/export/markdown.js +312 -0
- package/dist/server/export/markdown.js.map +1 -0
- package/dist/server/export/pdf.d.ts +20 -0
- package/dist/server/export/pdf.d.ts.map +1 -0
- package/dist/server/export/pdf.js +91 -0
- package/dist/server/export/pdf.js.map +1 -0
- package/dist/server/export/zip.d.ts +31 -0
- package/dist/server/export/zip.d.ts.map +1 -0
- package/dist/server/export/zip.js +158 -0
- package/dist/server/export/zip.js.map +1 -0
- package/dist/server/import/csv.d.ts +77 -0
- package/dist/server/import/csv.d.ts.map +1 -0
- package/dist/server/import/csv.js +263 -0
- package/dist/server/import/csv.js.map +1 -0
- package/dist/server/import/html.d.ts +52 -0
- package/dist/server/import/html.d.ts.map +1 -0
- package/dist/server/import/html.js +472 -0
- package/dist/server/import/html.js.map +1 -0
- package/dist/server/import/markdown.d.ts +63 -0
- package/dist/server/import/markdown.d.ts.map +1 -0
- package/dist/server/import/markdown.js +692 -0
- package/dist/server/import/markdown.js.map +1 -0
- package/dist/server/import/plan.d.ts +70 -0
- package/dist/server/import/plan.d.ts.map +1 -0
- package/dist/server/import/plan.js +761 -0
- package/dist/server/import/plan.js.map +1 -0
- package/dist/server/import/ydoc.d.ts +35 -0
- package/dist/server/import/ydoc.d.ts.map +1 -0
- package/dist/server/import/ydoc.js +91 -0
- package/dist/server/import/ydoc.js.map +1 -0
- package/dist/server/import/zip.d.ts +63 -0
- package/dist/server/import/zip.d.ts.map +1 -0
- package/dist/server/import/zip.js +308 -0
- package/dist/server/import/zip.js.map +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +3 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/schema.d.ts +445 -1
- package/dist/server/schema.d.ts.map +1 -1
- package/dist/server/schema.js +146 -0
- package/dist/server/schema.js.map +1 -1
- package/dist/server/services/databases.d.ts +5 -5
- package/dist/server/services/export.d.ts +176 -0
- package/dist/server/services/export.d.ts.map +1 -0
- package/dist/server/services/export.js +822 -0
- package/dist/server/services/export.js.map +1 -0
- package/dist/server/services/import.d.ts +109 -0
- package/dist/server/services/import.d.ts.map +1 -0
- package/dist/server/services/import.js +570 -0
- package/dist/server/services/import.js.map +1 -0
- package/dist/server/services/index.d.ts +26 -1
- package/dist/server/services/index.d.ts.map +1 -1
- package/dist/server/services/index.js +60 -1
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/versions.d.ts +1 -1
- package/migrations/0010_transfers.sql +154 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +1 -1
- package/src/client/components/ExportDialog.svelte +685 -0
- package/src/client/components/ImportDialog.svelte +702 -0
- package/src/client/components/ImportReport.svelte +310 -0
- package/src/client/components/SidebarSpaces.svelte +79 -0
- package/src/client/i18n.ts +614 -0
- package/src/client/index.ts +32 -0
- package/src/client/mock.ts +318 -0
- package/src/client/module.ts +36 -0
- package/src/client/pages/PageView.svelte +36 -0
- package/src/client/pages/TransfersPage.svelte +570 -0
- package/src/client/permissions.ts +11 -0
- package/src/client/query.ts +23 -0
- package/src/client/transfers.ts +142 -0
- package/src/contract/models.ts +152 -0
- package/src/contract/permissions.ts +84 -0
- package/src/contract/router.ts +147 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../../../src/server/import/csv.ts"],"names":[],"mappings":"AAuBA,6FAA6F;AAC7F,MAAM,MAAM,GAAG,GAAG,CAAA;AAElB,8EAA8E;AAC9E,MAAM,WAAW,GAAG,EAAE,CAAA;AAEtB,2EAA2E;AAC3E,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAE5B;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,MAAM,IAAI,GAAe,EAAE,CAAA;IAC3B,IAAI,GAAG,GAAa,EAAE,CAAA;IACtB,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,QAAQ,GAAG,GAAG,EAAE;QACpB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACf,KAAK,GAAG,EAAE,CAAA;QACV,QAAQ,GAAG,KAAK,CAAA;IAClB,CAAC,CAAA;IACD,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,QAAQ,EAAE,CAAA;QACV,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACd,GAAG,GAAG,EAAE,CAAA;IACV,CAAC,CAAA;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAE,CAAA;QACrB,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;gBACf,KAA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
2
|
+
* HTML to a page document, for the one source that has no Markdown: a Confluence space export.
|
|
3
|
+
*
|
|
4
|
+
* Confluence's "Export space → HTML" writes one already-rendered `.html` per page, an `index.html`
|
|
5
|
+
* listing them, and an `attachments/` tree. There is no storage format to read — the wiki markup and
|
|
6
|
+
* the `<ac:…>` macros are gone by the time the export is written — so the rendered HTML *is* the
|
|
7
|
+
* document, and reading it is the only route in that does not ask a customer to install a plugin.
|
|
8
|
+
*
|
|
9
|
+
* **A tag soup parser, deliberately, and not a DOM.** No `jsdom`, no `parse5`: this reads one
|
|
10
|
+
* bounded, machine-written dialect, and the whole job is a tokeniser plus a stack that closes
|
|
11
|
+
* implied tags. Nothing here is executed, nothing is fetched, and no attribute reaches a page
|
|
12
|
+
* unfiltered — a `src` and an `href` come out as raw strings for `plan.ts` to resolve and everything
|
|
13
|
+
* else is dropped, so a `<script>`, an `onclick` or a `javascript:` href has nowhere to land. That is
|
|
14
|
+
* the property that matters, because the input is a file somebody uploaded.
|
|
15
|
+
*
|
|
16
|
+
* Confluence's own furniture is recognised where it maps onto something Quire has — an information
|
|
17
|
+
* macro is a callout, a `syntaxhighlighter` block is a code block, an inline task list is a task list
|
|
18
|
+
* — and ignored where it does not. What it cannot map, it keeps as prose rather than dropping, which
|
|
19
|
+
* is the same rule the Markdown reader follows and for the same reason.
|
|
20
|
+
*/
|
|
21
|
+
import type { PageDoc } from '@kernhq/ui/editor/page-doc';
|
|
22
|
+
export interface HtmlElement {
|
|
23
|
+
tag: string;
|
|
24
|
+
attrs: Record<string, string>;
|
|
25
|
+
children: HtmlNode[];
|
|
26
|
+
}
|
|
27
|
+
export type HtmlNode = HtmlElement | {
|
|
28
|
+
text: string;
|
|
29
|
+
};
|
|
30
|
+
/** `&`, `—`, `—` — everything else is left exactly as it was written. */
|
|
31
|
+
export declare function decodeEntities(value: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* A document as a tree.
|
|
34
|
+
*
|
|
35
|
+
* Comments, doctypes and processing instructions are skipped rather than kept: none of them can
|
|
36
|
+
* become a node, and a comment holding `<div>` would otherwise open one.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseHtml(source: string): HtmlElement;
|
|
39
|
+
/** The first element matching a predicate, depth first. */
|
|
40
|
+
export declare function findElement(node: HtmlNode, match: (el: HtmlElement) => boolean): HtmlElement | null;
|
|
41
|
+
/** Every class on an element, lower-cased — Confluence's markup is identified entirely by class. */
|
|
42
|
+
export declare const classesOf: (el: HtmlElement) => string[];
|
|
43
|
+
/** All the text under a node, with runs of whitespace collapsed. What a title needs and no more. */
|
|
44
|
+
export declare function textContent(node: HtmlNode): string;
|
|
45
|
+
/**
|
|
46
|
+
* An HTML fragment as a page document.
|
|
47
|
+
*
|
|
48
|
+
* Always a `doc`: an element holding nothing is an empty page, which is a correct reading of an empty
|
|
49
|
+
* page rather than a failure.
|
|
50
|
+
*/
|
|
51
|
+
export declare function htmlToPageDoc(node: HtmlNode): PageDoc;
|
|
52
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../src/server/import/html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,OAAO,EAA4B,MAAM,4BAA4B,CAAA;AAMnF,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,QAAQ,EAAE,QAAQ,EAAE,CAAA;CACrB;AACD,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AA6ErD,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAapD;AAaD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAyErD;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,GAAG,WAAW,GAAG,IAAI,CAQnG;AAED,oGAAoG;AACpG,eAAO,MAAM,SAAS,GAAI,IAAI,WAAW,KAAG,MAAM,EAAuD,CAAA;AAEzG,oGAAoG;AACpG,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAGlD;AAkSD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
const isElement = (node) => 'tag' in node;
|
|
2
|
+
/** Tags that never have children, so a missing `/` is not a document with everything inside a `<br>`. */
|
|
3
|
+
const VOID_TAGS = new Set([
|
|
4
|
+
'area',
|
|
5
|
+
'base',
|
|
6
|
+
'br',
|
|
7
|
+
'col',
|
|
8
|
+
'embed',
|
|
9
|
+
'hr',
|
|
10
|
+
'img',
|
|
11
|
+
'input',
|
|
12
|
+
'link',
|
|
13
|
+
'meta',
|
|
14
|
+
'param',
|
|
15
|
+
'source',
|
|
16
|
+
'track',
|
|
17
|
+
'wbr',
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Tags whose content is text rather than markup.
|
|
21
|
+
*
|
|
22
|
+
* `<script>` and `<style>` are here so that a `<` inside them cannot open an element — and their
|
|
23
|
+
* content is then thrown away, because neither has any meaning in a page document. Reading them as
|
|
24
|
+
* markup is how `if (a < b)` inside a script becomes an element called `b`.
|
|
25
|
+
*/
|
|
26
|
+
const RAW_TEXT_TAGS = new Set(['script', 'style', 'textarea', 'title']);
|
|
27
|
+
/**
|
|
28
|
+
* Which open tags a new one implicitly closes.
|
|
29
|
+
*
|
|
30
|
+
* Confluence writes well-formed HTML, so this is for the exports that are not — hand-edited files,
|
|
31
|
+
* and older Confluence versions that leave `<li>` and `<p>` unclosed. Without it one unclosed `<li>`
|
|
32
|
+
* nests every following item inside it and a page arrives as a staircase.
|
|
33
|
+
*/
|
|
34
|
+
const IMPLIED_CLOSE = {
|
|
35
|
+
li: ['li'],
|
|
36
|
+
p: ['p'],
|
|
37
|
+
td: ['td', 'th'],
|
|
38
|
+
th: ['td', 'th'],
|
|
39
|
+
tr: ['td', 'th', 'tr'],
|
|
40
|
+
dt: ['dt', 'dd'],
|
|
41
|
+
dd: ['dt', 'dd'],
|
|
42
|
+
option: ['option'],
|
|
43
|
+
};
|
|
44
|
+
const NAMED_ENTITIES = {
|
|
45
|
+
amp: '&',
|
|
46
|
+
lt: '<',
|
|
47
|
+
gt: '>',
|
|
48
|
+
quot: '"',
|
|
49
|
+
apos: "'",
|
|
50
|
+
nbsp: ' ',
|
|
51
|
+
hellip: '…',
|
|
52
|
+
mdash: '—',
|
|
53
|
+
ndash: '–',
|
|
54
|
+
lsquo: '‘',
|
|
55
|
+
rsquo: '’',
|
|
56
|
+
ldquo: '“',
|
|
57
|
+
rdquo: '”',
|
|
58
|
+
times: '×',
|
|
59
|
+
middot: '·',
|
|
60
|
+
bull: '•',
|
|
61
|
+
copy: '©',
|
|
62
|
+
reg: '®',
|
|
63
|
+
trade: '™',
|
|
64
|
+
deg: '°',
|
|
65
|
+
euro: '€',
|
|
66
|
+
pound: '£',
|
|
67
|
+
laquo: '«',
|
|
68
|
+
raquo: '»',
|
|
69
|
+
check: '✓',
|
|
70
|
+
};
|
|
71
|
+
/** `&`, `—`, `—` — everything else is left exactly as it was written. */
|
|
72
|
+
export function decodeEntities(value) {
|
|
73
|
+
return value.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]{1,31});/g, (whole, body) => {
|
|
74
|
+
if (body[0] === '#') {
|
|
75
|
+
const code = body[1] === 'x' || body[1] === 'X' ? Number.parseInt(body.slice(2), 16) : Number(body.slice(1));
|
|
76
|
+
// A surrogate half or an out-of-range code point would throw; the source text is the honest
|
|
77
|
+
// fallback, because a mangled character is easier to explain than a failed import.
|
|
78
|
+
if (!Number.isFinite(code) || code <= 0 || code > 0x10ffff || (code >= 0xd800 && code <= 0xdfff))
|
|
79
|
+
return whole;
|
|
80
|
+
return String.fromCodePoint(code);
|
|
81
|
+
}
|
|
82
|
+
return NAMED_ENTITIES[body.toLowerCase()] ?? whole;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** The attributes of one start tag. Values are decoded; names are lower-cased. */
|
|
86
|
+
function parseAttributes(source) {
|
|
87
|
+
const attrs = {};
|
|
88
|
+
const pattern = /([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;
|
|
89
|
+
for (const match of source.matchAll(pattern)) {
|
|
90
|
+
const name = match[1].toLowerCase();
|
|
91
|
+
attrs[name] = decodeEntities(match[2] ?? match[3] ?? match[4] ?? '');
|
|
92
|
+
}
|
|
93
|
+
return attrs;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A document as a tree.
|
|
97
|
+
*
|
|
98
|
+
* Comments, doctypes and processing instructions are skipped rather than kept: none of them can
|
|
99
|
+
* become a node, and a comment holding `<div>` would otherwise open one.
|
|
100
|
+
*/
|
|
101
|
+
export function parseHtml(source) {
|
|
102
|
+
const root = { tag: '#root', attrs: {}, children: [] };
|
|
103
|
+
const stack = [root];
|
|
104
|
+
const top = () => stack[stack.length - 1];
|
|
105
|
+
const pushText = (value) => {
|
|
106
|
+
if (value.length > 0)
|
|
107
|
+
top().children.push({ text: decodeEntities(value) });
|
|
108
|
+
};
|
|
109
|
+
let at = 0;
|
|
110
|
+
while (at < source.length) {
|
|
111
|
+
const lt = source.indexOf('<', at);
|
|
112
|
+
if (lt < 0) {
|
|
113
|
+
pushText(source.slice(at));
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
pushText(source.slice(at, lt));
|
|
117
|
+
if (source.startsWith('<!--', lt)) {
|
|
118
|
+
const end = source.indexOf('-->', lt + 4);
|
|
119
|
+
at = end < 0 ? source.length : end + 3;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (source.startsWith('<!', lt) || source.startsWith('<?', lt)) {
|
|
123
|
+
const end = source.indexOf('>', lt);
|
|
124
|
+
at = end < 0 ? source.length : end + 1;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const close = /^<\/\s*([a-zA-Z][^\s>]*)\s*>/.exec(source.slice(lt));
|
|
128
|
+
if (close) {
|
|
129
|
+
const tag = close[1].toLowerCase();
|
|
130
|
+
// Close the nearest matching element, discarding anything left open inside it.
|
|
131
|
+
for (let i = stack.length - 1; i > 0; i--)
|
|
132
|
+
if (stack[i].tag === tag) {
|
|
133
|
+
stack.length = i;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
at = lt + close[0].length;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const open = /^<([a-zA-Z][^\s/>]*)((?:[^>"']|"[^"]*"|'[^']*')*?)(\/?)>/.exec(source.slice(lt));
|
|
140
|
+
if (!open) {
|
|
141
|
+
// A bare `<` that opens nothing is a character somebody typed.
|
|
142
|
+
pushText('<');
|
|
143
|
+
at = lt + 1;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const tag = open[1].toLowerCase();
|
|
147
|
+
const attrs = parseAttributes(open[2] ?? '');
|
|
148
|
+
at = lt + open[0].length;
|
|
149
|
+
if (RAW_TEXT_TAGS.has(tag)) {
|
|
150
|
+
const end = source.toLowerCase().indexOf(`</${tag}`, at);
|
|
151
|
+
const body = source.slice(at, end < 0 ? source.length : end);
|
|
152
|
+
// `<title>` is the only one whose text is worth anything, and the page reader asks for it.
|
|
153
|
+
if (tag === 'title')
|
|
154
|
+
top().children.push({ tag, attrs, children: [{ text: decodeEntities(body) }] });
|
|
155
|
+
at = end < 0 ? source.length : source.indexOf('>', end) + 1;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
for (const closes of IMPLIED_CLOSE[tag] ?? [])
|
|
159
|
+
if (top().tag === closes) {
|
|
160
|
+
stack.pop();
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
const element = { tag, attrs, children: [] };
|
|
164
|
+
top().children.push(element);
|
|
165
|
+
if (!VOID_TAGS.has(tag) && open[3] !== '/')
|
|
166
|
+
stack.push(element);
|
|
167
|
+
}
|
|
168
|
+
return root;
|
|
169
|
+
}
|
|
170
|
+
/** The first element matching a predicate, depth first. */
|
|
171
|
+
export function findElement(node, match) {
|
|
172
|
+
if (!isElement(node))
|
|
173
|
+
return null;
|
|
174
|
+
if (node.tag !== '#root' && match(node))
|
|
175
|
+
return node;
|
|
176
|
+
for (const child of node.children) {
|
|
177
|
+
const found = findElement(child, match);
|
|
178
|
+
if (found)
|
|
179
|
+
return found;
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
/** Every class on an element, lower-cased — Confluence's markup is identified entirely by class. */
|
|
184
|
+
export const classesOf = (el) => (el.attrs.class ?? '').toLowerCase().split(/\s+/);
|
|
185
|
+
/** All the text under a node, with runs of whitespace collapsed. What a title needs and no more. */
|
|
186
|
+
export function textContent(node) {
|
|
187
|
+
if (!isElement(node))
|
|
188
|
+
return node.text;
|
|
189
|
+
return node.children.map(textContent).join('');
|
|
190
|
+
}
|
|
191
|
+
// ------------------------------------------------------------------------------------------------
|
|
192
|
+
// To a page document
|
|
193
|
+
// ------------------------------------------------------------------------------------------------
|
|
194
|
+
const MARKS = {
|
|
195
|
+
strong: 'bold',
|
|
196
|
+
b: 'bold',
|
|
197
|
+
em: 'italic',
|
|
198
|
+
i: 'italic',
|
|
199
|
+
u: 'underline',
|
|
200
|
+
ins: 'underline',
|
|
201
|
+
s: 'strike',
|
|
202
|
+
del: 'strike',
|
|
203
|
+
strike: 'strike',
|
|
204
|
+
mark: 'highlight',
|
|
205
|
+
code: 'code',
|
|
206
|
+
};
|
|
207
|
+
const HEADINGS = { h1: 1, h2: 2, h3: 3, h4: 4, h5: 5, h6: 6 };
|
|
208
|
+
/** Confluence names its five information macros by class; these are the ones with a Quire tone. */
|
|
209
|
+
const MACRO_TONES = {
|
|
210
|
+
'confluence-information-macro-information': 'info',
|
|
211
|
+
'confluence-information-macro-note': 'note',
|
|
212
|
+
'confluence-information-macro-tip': 'success',
|
|
213
|
+
'confluence-information-macro-warning': 'warning',
|
|
214
|
+
'confluence-information-macro-problem': 'danger',
|
|
215
|
+
};
|
|
216
|
+
const isBlockTag = (tag) => tag in HEADINGS ||
|
|
217
|
+
[
|
|
218
|
+
'p',
|
|
219
|
+
'div',
|
|
220
|
+
'ul',
|
|
221
|
+
'ol',
|
|
222
|
+
'li',
|
|
223
|
+
'table',
|
|
224
|
+
'thead',
|
|
225
|
+
'tbody',
|
|
226
|
+
'tr',
|
|
227
|
+
'td',
|
|
228
|
+
'th',
|
|
229
|
+
'pre',
|
|
230
|
+
'blockquote',
|
|
231
|
+
'hr',
|
|
232
|
+
].includes(tag);
|
|
233
|
+
/** Collapse the whitespace HTML treats as insignificant, keeping the single spaces between words. */
|
|
234
|
+
const collapse = (value) => value.replace(/[\t\r\n]+/g, ' ').replace(/ {2,}/g, ' ');
|
|
235
|
+
function withMark(nodes, mark) {
|
|
236
|
+
return nodes.map((node) => typeof node.text === 'string'
|
|
237
|
+
? { ...node, marks: [...(node.marks ?? []).filter((m) => m.type !== mark.type), mark] }
|
|
238
|
+
: node);
|
|
239
|
+
}
|
|
240
|
+
/** Inline content, for anything that cannot hold a block. */
|
|
241
|
+
function inlineOf(nodes) {
|
|
242
|
+
const out = [];
|
|
243
|
+
const push = (values) => {
|
|
244
|
+
for (const node of values) {
|
|
245
|
+
const last = out.at(-1);
|
|
246
|
+
if (last &&
|
|
247
|
+
typeof last.text === 'string' &&
|
|
248
|
+
typeof node.text === 'string' &&
|
|
249
|
+
JSON.stringify(last.marks ?? null) === JSON.stringify(node.marks ?? null))
|
|
250
|
+
last.text += node.text;
|
|
251
|
+
else
|
|
252
|
+
out.push(node);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
for (const node of nodes) {
|
|
256
|
+
if (!isElement(node)) {
|
|
257
|
+
const value = collapse(node.text);
|
|
258
|
+
if (value.length > 0)
|
|
259
|
+
push([{ type: 'text', text: value }]);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (node.tag === 'br') {
|
|
263
|
+
push([{ type: 'hardBreak' }]);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (node.tag === 'img') {
|
|
267
|
+
const src = node.attrs.src ?? '';
|
|
268
|
+
if (src)
|
|
269
|
+
push([{ type: 'image', attrs: { src, alt: node.attrs.alt ?? '' } }]);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (node.tag === 'a') {
|
|
273
|
+
const href = node.attrs.href ?? '';
|
|
274
|
+
const inner = inlineOf(node.children);
|
|
275
|
+
// A link with no target is not a link; keeping its label is better than dropping the words.
|
|
276
|
+
push(href ? withMark(inner, { type: 'link', attrs: { href } }) : inner);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const mark = MARKS[node.tag];
|
|
280
|
+
if (mark) {
|
|
281
|
+
push(withMark(inlineOf(node.children), { type: mark }));
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
// Anything else — a `<span>`, a `<time>`, a Confluence wrapper — contributes its content.
|
|
285
|
+
push(inlineOf(node.children));
|
|
286
|
+
}
|
|
287
|
+
return out;
|
|
288
|
+
}
|
|
289
|
+
/** A paragraph from inline content, or nothing when the content was only whitespace. */
|
|
290
|
+
function paragraphOf(nodes) {
|
|
291
|
+
const content = trimInline(inlineOf(nodes));
|
|
292
|
+
return content.length > 0 ? { type: 'paragraph', content } : null;
|
|
293
|
+
}
|
|
294
|
+
/** Drop the leading and trailing whitespace HTML puts between tags. */
|
|
295
|
+
function trimInline(nodes) {
|
|
296
|
+
const out = [...nodes];
|
|
297
|
+
while (out.length > 0 && typeof out[0].text === 'string' && out[0].text.trim() === '')
|
|
298
|
+
out.shift();
|
|
299
|
+
while (out.length > 0 && typeof out.at(-1).text === 'string' && out.at(-1).text.trim() === '')
|
|
300
|
+
out.pop();
|
|
301
|
+
if (out.length > 0 && typeof out[0].text === 'string')
|
|
302
|
+
out[0] = { ...out[0], text: out[0].text.replace(/^ +/, '') };
|
|
303
|
+
const last = out.at(-1);
|
|
304
|
+
if (last && typeof last.text === 'string')
|
|
305
|
+
out[out.length - 1] = { ...last, text: last.text.replace(/ +$/, '') };
|
|
306
|
+
return out.filter((node) => typeof node.text !== 'string' || node.text.length > 0);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* A list item's content, as blocks.
|
|
310
|
+
*
|
|
311
|
+
* An item holding nothing but inline content becomes one paragraph, which is what every other writer
|
|
312
|
+
* in this module produces; an item holding a nested list keeps both.
|
|
313
|
+
*/
|
|
314
|
+
function itemContent(children) {
|
|
315
|
+
const blocks = blocksOf(children);
|
|
316
|
+
return blocks.length > 0 ? blocks : [{ type: 'paragraph', content: [] }];
|
|
317
|
+
}
|
|
318
|
+
/** A `<ul>` or `<ol>`, as the list — or the task list — it is. */
|
|
319
|
+
function listOf(el) {
|
|
320
|
+
const items = el.children.filter((child) => isElement(child) && child.tag === 'li');
|
|
321
|
+
// Confluence writes a task list as `<ul class="inline-task-list"><li class="checked">`.
|
|
322
|
+
const isTasks = classesOf(el).includes('inline-task-list');
|
|
323
|
+
if (isTasks)
|
|
324
|
+
return {
|
|
325
|
+
type: 'taskList',
|
|
326
|
+
content: items.map((item) => ({
|
|
327
|
+
type: 'taskItem',
|
|
328
|
+
attrs: { checked: classesOf(item).includes('checked') },
|
|
329
|
+
content: itemContent(item.children),
|
|
330
|
+
})),
|
|
331
|
+
};
|
|
332
|
+
if (el.tag === 'ol') {
|
|
333
|
+
const start = Number(el.attrs.start);
|
|
334
|
+
return {
|
|
335
|
+
type: 'orderedList',
|
|
336
|
+
attrs: { start: Number.isInteger(start) && start > 0 ? start : 1 },
|
|
337
|
+
content: items.map((item) => ({ type: 'listItem', content: itemContent(item.children) })),
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
type: 'bulletList',
|
|
342
|
+
content: items.map((item) => ({ type: 'listItem', content: itemContent(item.children) })),
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
/** A `<table>`, flattened past `<thead>`/`<tbody>` — Quire's table is rows all the way down. */
|
|
346
|
+
function tableOf(el) {
|
|
347
|
+
const rows = [];
|
|
348
|
+
const collect = (node) => {
|
|
349
|
+
if (!isElement(node))
|
|
350
|
+
return;
|
|
351
|
+
if (node.tag === 'tr') {
|
|
352
|
+
rows.push(node);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
for (const child of node.children)
|
|
356
|
+
collect(child);
|
|
357
|
+
};
|
|
358
|
+
collect(el);
|
|
359
|
+
if (rows.length === 0)
|
|
360
|
+
return null;
|
|
361
|
+
const content = rows.map((row) => ({
|
|
362
|
+
type: 'tableRow',
|
|
363
|
+
content: row.children
|
|
364
|
+
.filter((cell) => isElement(cell) && (cell.tag === 'td' || cell.tag === 'th'))
|
|
365
|
+
.map((cell) => ({
|
|
366
|
+
type: cell.tag === 'th' ? 'tableHeader' : 'tableCell',
|
|
367
|
+
content: itemContent(cell.children),
|
|
368
|
+
})),
|
|
369
|
+
}));
|
|
370
|
+
return { type: 'table', content };
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* A `<pre>` as a code block, with the language Confluence puts in the class if there is one.
|
|
374
|
+
*
|
|
375
|
+
* The text is taken raw rather than collapsed: whitespace is the whole point of a code block, and a
|
|
376
|
+
* collapsed one is a snippet nobody can run.
|
|
377
|
+
*/
|
|
378
|
+
function codeOf(el) {
|
|
379
|
+
const language = classesOf(el)
|
|
380
|
+
.map((name) => /^(?:language|brush|lang)[-:]([a-z0-9#+.-]{1,24})$/i.exec(name)?.[1])
|
|
381
|
+
.find((found) => found !== undefined);
|
|
382
|
+
const body = textContent(el)
|
|
383
|
+
.replace(/\r\n|\r/g, '\n')
|
|
384
|
+
.replace(/^\n+|\n+$/g, '');
|
|
385
|
+
return {
|
|
386
|
+
type: 'codeBlock',
|
|
387
|
+
...(language ? { attrs: { language } } : {}),
|
|
388
|
+
content: body.length > 0 ? [{ type: 'text', text: body }] : [],
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The blocks under one element.
|
|
393
|
+
*
|
|
394
|
+
* A run of inline content between block children becomes a paragraph of its own, which is what makes
|
|
395
|
+
* `<div>text<ul>…</ul>more text</div>` — the shape Confluence's macros produce — come out as three
|
|
396
|
+
* blocks rather than as one paragraph with a list hidden inside it.
|
|
397
|
+
*/
|
|
398
|
+
function blocksOf(children) {
|
|
399
|
+
const out = [];
|
|
400
|
+
let inline = [];
|
|
401
|
+
const flush = () => {
|
|
402
|
+
const node = paragraphOf(inline);
|
|
403
|
+
if (node)
|
|
404
|
+
out.push(node);
|
|
405
|
+
inline = [];
|
|
406
|
+
};
|
|
407
|
+
for (const child of children) {
|
|
408
|
+
if (!isElement(child) || !isBlockTag(child.tag)) {
|
|
409
|
+
inline.push(child);
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
flush();
|
|
413
|
+
out.push(...blockOf(child));
|
|
414
|
+
}
|
|
415
|
+
flush();
|
|
416
|
+
return out;
|
|
417
|
+
}
|
|
418
|
+
function blockOf(el) {
|
|
419
|
+
const level = HEADINGS[el.tag];
|
|
420
|
+
if (level !== undefined) {
|
|
421
|
+
const content = trimInline(inlineOf(el.children));
|
|
422
|
+
return content.length > 0 ? [{ type: 'heading', attrs: { level }, content }] : [];
|
|
423
|
+
}
|
|
424
|
+
switch (el.tag) {
|
|
425
|
+
case 'p': {
|
|
426
|
+
const node = paragraphOf(el.children);
|
|
427
|
+
return node ? [node] : [];
|
|
428
|
+
}
|
|
429
|
+
case 'hr':
|
|
430
|
+
return [{ type: 'horizontalRule' }];
|
|
431
|
+
case 'pre':
|
|
432
|
+
return [codeOf(el)];
|
|
433
|
+
case 'ul':
|
|
434
|
+
case 'ol':
|
|
435
|
+
return [listOf(el)];
|
|
436
|
+
case 'table': {
|
|
437
|
+
const node = tableOf(el);
|
|
438
|
+
return node ? [node] : [];
|
|
439
|
+
}
|
|
440
|
+
case 'blockquote': {
|
|
441
|
+
const body = blocksOf(el.children);
|
|
442
|
+
return [{ type: 'blockquote', content: body.length > 0 ? body : [{ type: 'paragraph', content: [] }] }];
|
|
443
|
+
}
|
|
444
|
+
default: {
|
|
445
|
+
// A `<div>`. Confluence's information macros are the one kind worth recognising: each is a
|
|
446
|
+
// `<div>` whose class names the tone, holding the body in a nested `<div>`.
|
|
447
|
+
const tone = classesOf(el)
|
|
448
|
+
.map((name) => MACRO_TONES[name])
|
|
449
|
+
.find((found) => found !== undefined);
|
|
450
|
+
const body = blocksOf(el.children);
|
|
451
|
+
if (tone)
|
|
452
|
+
return [
|
|
453
|
+
{
|
|
454
|
+
type: 'callout',
|
|
455
|
+
attrs: { tone },
|
|
456
|
+
content: body.length > 0 ? body : [{ type: 'paragraph', content: [] }],
|
|
457
|
+
},
|
|
458
|
+
];
|
|
459
|
+
return body;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* An HTML fragment as a page document.
|
|
465
|
+
*
|
|
466
|
+
* Always a `doc`: an element holding nothing is an empty page, which is a correct reading of an empty
|
|
467
|
+
* page rather than a failure.
|
|
468
|
+
*/
|
|
469
|
+
export function htmlToPageDoc(node) {
|
|
470
|
+
return { type: 'doc', content: isElement(node) ? blocksOf(node.children) : blocksOf([node]) };
|
|
471
|
+
}
|
|
472
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../../src/server/import/html.ts"],"names":[],"mappings":"AAiCA,MAAM,SAAS,GAAG,CAAC,IAAc,EAAuB,EAAE,CAAC,KAAK,IAAI,I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C,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;QACzG,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,2FAA2F;YAC3F,4EAA4E;YAC5E,MAAM,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;iBACvB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;iBAChC,IAAI,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAA;YACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAA;YAClC,IAAI,IAAI;gBACN,OAAO;oBACL;wBACE,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,EAAE,IAAI,EAAE;wBACf,OAAO,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;qBACvE;iBACF,CAAA;YACH,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,IAAc;IAC1C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAA;AAC/F,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown to a page document — the reader for `../export/markdown.ts`.
|
|
3
|
+
*
|
|
4
|
+
* The two files are a pair and the pairing is the requirement: everything the writer emits has to
|
|
5
|
+
* come back as itself. That is what makes a Quire export a valid Quire import, and it is the only
|
|
6
|
+
* check on the writer that is not somebody reading it. `import.int.test.ts` asserts the round trip
|
|
7
|
+
* block by block.
|
|
8
|
+
*
|
|
9
|
+
* **This is not a CommonMark implementation and does not pretend to be.** It covers the dialect the
|
|
10
|
+
* writer produces and the dialect Notion and Confluence produce, which is GitHub-flavoured Markdown
|
|
11
|
+
* with a handful of HTML tags: ATX and setext headings, fenced code with an info string, blockquotes,
|
|
12
|
+
* GitHub alerts (`> [!WARNING]`) as callouts, bullet, ordered and task lists with nesting, GFM
|
|
13
|
+
* tables, thematic breaks, `<details>` toggles, `<u>`, `<mark>` and `<br>`, and inline emphasis, code
|
|
14
|
+
* spans, links, autolinks and images. What it deliberately does not do — reference links, footnotes,
|
|
15
|
+
* HTML blocks it has no node for — degrades to a paragraph of the text rather than being dropped,
|
|
16
|
+
* because losing a paragraph silently is the failure this whole slice exists to prevent.
|
|
17
|
+
*
|
|
18
|
+
* **A hard line break is spelled `<br>`, including internally.** A paragraph's lines are joined
|
|
19
|
+
* before its inline content is scanned, because an emphasis run or a link label may wrap across them
|
|
20
|
+
* — and the join then has to remember which wraps were `two spaces` or a trailing backslash and
|
|
21
|
+
* which were ordinary soft wraps. Rewriting the first kind as `<br>` rather than inventing a sentinel
|
|
22
|
+
* character means the marker is a real thing the format already has: it is what the writer's own
|
|
23
|
+
* table cells carry, what Confluence emits in prose, and something a reader can see in a diff.
|
|
24
|
+
*
|
|
25
|
+
* **Links and images keep their raw targets.** A `link` mark carries the href exactly as it was
|
|
26
|
+
* written and an `image` node carries its `src`, because resolving them needs the whole archive —
|
|
27
|
+
* which page is at `../Team%20notes/Onboarding%2012ab.md` is not a question one file can answer.
|
|
28
|
+
* `plan.ts` walks the finished document and rewrites or degrades them, and that split is what keeps
|
|
29
|
+
* this file pure and testable on a string.
|
|
30
|
+
*/
|
|
31
|
+
import type { PageDoc, PageDocNode } from '@kernhq/ui/editor/page-doc';
|
|
32
|
+
/**
|
|
33
|
+
* One paragraph (or one table cell) of prose as inline nodes.
|
|
34
|
+
*
|
|
35
|
+
* A `\n` still in `source` is a soft wrap and becomes the space a reader would have rendered; a hard
|
|
36
|
+
* break arrived as `<br>`, which `findOpener` sees like any other inline construct.
|
|
37
|
+
*/
|
|
38
|
+
export declare function inlineNodes(source: string): PageDocNode[];
|
|
39
|
+
/**
|
|
40
|
+
* A page's title and its body, split.
|
|
41
|
+
*
|
|
42
|
+
* A title is a **column** in Quire, not a node in its document, so the `# Title` the writer puts at
|
|
43
|
+
* the top of every exported file has to come back off the top rather than becoming an H1 inside the
|
|
44
|
+
* page. Notion writes the same shape, and Notion's is the one that matters: its filename has been
|
|
45
|
+
* through a sanitiser that turns `Q3/Q4 Handover` into `Q3Q4 Handover`, while the heading still says
|
|
46
|
+
* what the page is called. Taking the title from the heading is the difference between importing a
|
|
47
|
+
* page under its own name and importing it under a name nobody chose.
|
|
48
|
+
*
|
|
49
|
+
* Only a level-1 heading, and only as the first non-blank line: a file that opens with prose keeps
|
|
50
|
+
* its prose, and a file whose first heading is `##` is one whose author did not mean it as a title.
|
|
51
|
+
*/
|
|
52
|
+
export declare function splitTitle(source: string): {
|
|
53
|
+
title: string | null;
|
|
54
|
+
body: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Markdown as a page document.
|
|
58
|
+
*
|
|
59
|
+
* Always a `doc`, never null: a file holding nothing but its own title is an empty page, and an empty
|
|
60
|
+
* page is a correct import of an empty page.
|
|
61
|
+
*/
|
|
62
|
+
export declare function markdownToPageDoc(source: string): PageDoc;
|
|
63
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/server/import/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,OAAO,EAAe,WAAW,EAAE,MAAM,4BAA4B,CAAA;AA0MnF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAwCzD;AAydD;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAkBjF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|