@kerebron/extension-odt 0.3.0 → 0.3.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 +8 -2
- package/esm/editor/src/CoreEditor.d.ts.map +1 -1
- package/esm/editor/src/CoreEditor.js +3 -1
- package/esm/editor/src/Extension.d.ts.map +1 -1
- package/esm/editor/src/ExtensionManager.d.ts +1 -1
- package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
- package/esm/editor/src/nodeToTreeString.d.ts +8 -2
- package/esm/editor/src/nodeToTreeString.d.ts.map +1 -1
- package/esm/editor/src/nodeToTreeString.js +27 -11
- package/esm/editor/src/utilities/SmartOutput.d.ts +39 -0
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -0
- package/esm/editor/src/utilities/SmartOutput.js +213 -0
- package/esm/extension-odt/src/ExtensionOdt.d.ts +0 -1
- package/esm/extension-odt/src/ExtensionOdt.d.ts.map +1 -1
- package/esm/extension-odt/src/ExtensionOdt.js +25 -28
- package/esm/extension-odt/src/OdtParser.d.ts +41 -63
- package/esm/extension-odt/src/OdtParser.d.ts.map +1 -1
- package/esm/extension-odt/src/OdtParser.js +172 -474
- package/esm/extension-odt/src/lists.d.ts +23 -0
- package/esm/extension-odt/src/lists.d.ts.map +1 -0
- package/esm/extension-odt/src/lists.js +55 -0
- package/esm/extension-odt/src/node_handlers/basic_node_handlers.d.ts +4 -0
- package/esm/extension-odt/src/node_handlers/basic_node_handlers.d.ts.map +1 -0
- package/esm/extension-odt/src/node_handlers/basic_node_handlers.js +138 -0
- package/esm/extension-odt/src/node_handlers/list_node_handlers.d.ts +3 -0
- package/esm/extension-odt/src/node_handlers/list_node_handlers.d.ts.map +1 -0
- package/esm/extension-odt/src/node_handlers/list_node_handlers.js +91 -0
- package/esm/extension-odt/src/node_handlers/table_node_handlers.d.ts +3 -0
- package/esm/extension-odt/src/node_handlers/table_node_handlers.d.ts.map +1 -0
- package/esm/extension-odt/src/node_handlers/table_node_handlers.js +24 -0
- package/esm/extension-odt/src/postprocess/convertCodeParagraphsToCodeBlocks.d.ts.map +1 -1
- package/esm/extension-odt/src/postprocess/convertCodeParagraphsToCodeBlocks.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,13 @@ deno task -f example-server-hono start
|
|
|
36
36
|
|
|
37
37
|
## Build
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
### Build static examples
|
|
40
|
+
|
|
41
|
+
```shell
|
|
42
|
+
deno task -r build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### NPM packages are generated using DNT
|
|
40
46
|
|
|
41
47
|
- https://deno.com/blog/publish-esm-cjs-module-dnt - the easiest way to publish
|
|
42
48
|
a hybrid npm module for ESM and CommonJS
|
|
@@ -46,7 +52,7 @@ deno task -f example-server-hono start
|
|
|
46
52
|
To generate npm packages
|
|
47
53
|
|
|
48
54
|
```shell
|
|
49
|
-
deno -A ./
|
|
55
|
+
deno -A ./build/build_npm.ts
|
|
50
56
|
```
|
|
51
57
|
|
|
52
58
|
## Run through docker
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/src/CoreEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAc3C,qBAAa,UAAW,SAAQ,WA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eAAe,CAAC;IACpC,KAAK,EAAG,WAAW,CAAC;gBAEf,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM;IA4BhD,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI9D,IAAW,MAAM,qBAEhB;IAEM,KAAK,IAAI,eAAe;IAIxB,GAAG,IAAI,eAAe;IAI7B,OAAO,CAAC,UAAU;IAqBX,mBAAmB,CAAC,WAAW,EAAE,WAAW;IAcnD,OAAO,CAAC,YAAY;IAcb,aAAa;IASb,WAAW,CAAC,OAAO,EAAE,GAAG;IAyBxB,WAAW;IAIL,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IA0BnD,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAY1D,OAAO,IAAI,WAAW;IAItB,KAAK,CAAC,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,UAAU;IAOvD,KAAK,CAAC,GAAG,CAAC,EAAE,eAAe;CAMnC"}
|
|
@@ -128,7 +128,9 @@ export class CoreEditor extends EventTarget {
|
|
|
128
128
|
this.setDocument(content);
|
|
129
129
|
}
|
|
130
130
|
setDocument(content) {
|
|
131
|
-
let doc = createNodeFromObject(content, this.schema
|
|
131
|
+
let doc = createNodeFromObject(content, this.schema, {
|
|
132
|
+
errorOnInvalidContent: true,
|
|
133
|
+
});
|
|
132
134
|
doc = ensureDocSchema(doc, this.schema);
|
|
133
135
|
this.state = EditorState.create({
|
|
134
136
|
doc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,O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AAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAInE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAI5E,SAAS,CAAC,IAAI,EAAE,UAAU;CAE3B"}
|
|
@@ -25,7 +25,7 @@ export declare class ExtensionManager {
|
|
|
25
25
|
converters: Record<string, Converter>;
|
|
26
26
|
private debug;
|
|
27
27
|
constructor(extensions: AnyExtensionOrReq[], editor: CoreEditor);
|
|
28
|
-
getExtension(name: string):
|
|
28
|
+
getExtension<T extends Extension>(name: string): T | undefined;
|
|
29
29
|
private getPlugins;
|
|
30
30
|
private setupExtensions;
|
|
31
31
|
getSchemaByResolvedExtensions(editor: CoreEditor): Schema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionManager.d.ts","sourceRoot":"","sources":["../../../src/editor/src/ExtensionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMjC,OAAO,EAGL,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAK3B,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAIlD;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,QAAQ,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eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC;;;;EAgBjE;AAED,qBAAa,gBAAgB;IAYkB,OAAO,CAAC,MAAM;IAX3D,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAgC;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAM;IAE7D,QAAQ,CAAC,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAAM;IAC3D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAM;IAElD,OAAO,CAAC,KAAK,CAAQ;gBAET,UAAU,EAAE,iBAAiB,EAAE,EAAU,MAAM,EAAE,UAAU;IAcvE,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAY9D,OAAO,CAAC,UAAU;IAoJlB,OAAO,CAAC,eAAe;IAoEvB,6BAA6B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;CAuC1D"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { Node } from 'prosemirror-model';
|
|
2
|
-
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
import { SmartOutput } from './utilities/SmartOutput.js';
|
|
3
|
+
export interface NodeAndPos {
|
|
4
|
+
node: Node;
|
|
5
|
+
pos: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function nodeToTreeStringOutput(output: SmartOutput<NodeAndPos>, node: Node | Node[] | readonly Node[], level?: number, currentPos?: number): SmartOutput<NodeAndPos> | undefined;
|
|
8
|
+
export declare function nodeToTreeString(node: Node | Node[] | readonly Node[]): string;
|
|
3
9
|
export declare function debugNode(node: Node | Node[]): void;
|
|
4
10
|
//# sourceMappingURL=nodeToTreeString.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAYzD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,EAC/B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EACrC,KAAK,SAAI,EACT,UAAU,SAAI,uCAmEf;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,UAIrE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,QAE5C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SmartOutput } from './utilities/SmartOutput.js';
|
|
1
2
|
function trimText(str, maxLen = 20) {
|
|
2
3
|
str = str.replaceAll('\n', '\\n');
|
|
3
4
|
if (str.length <= maxLen) {
|
|
@@ -5,19 +6,19 @@ function trimText(str, maxLen = 20) {
|
|
|
5
6
|
}
|
|
6
7
|
return str.slice(0, maxLen) + '...';
|
|
7
8
|
}
|
|
8
|
-
export function
|
|
9
|
+
export function nodeToTreeStringOutput(output, node, level = 0, currentPos = 0) {
|
|
9
10
|
let delim = '';
|
|
10
11
|
for (let i = 0; i < level; i++) {
|
|
11
12
|
delim += ' ';
|
|
12
13
|
}
|
|
13
|
-
let output = '';
|
|
14
14
|
if (Array.isArray(node)) {
|
|
15
15
|
for (const child of node) {
|
|
16
|
-
output
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
output.log(delim, { node: child, pos: currentPos });
|
|
17
|
+
nodeToTreeStringOutput(output, child, level + 1, currentPos);
|
|
18
|
+
// .replace(/\s+$/gm, '') +
|
|
19
|
+
// '\n'
|
|
19
20
|
}
|
|
20
|
-
return
|
|
21
|
+
return;
|
|
21
22
|
}
|
|
22
23
|
// https://prosemirror.net/docs/guide/#doc.indexing
|
|
23
24
|
let line = '';
|
|
@@ -33,7 +34,7 @@ export function nodeToTreeString(node, level = 0, currentPos = 0) {
|
|
|
33
34
|
if (node.content) {
|
|
34
35
|
line += `fragment.size: ${node.content.size}, `;
|
|
35
36
|
}
|
|
36
|
-
output
|
|
37
|
+
output.log((delim + line) + '\n', { node, pos: currentPos });
|
|
37
38
|
let marksLine = '';
|
|
38
39
|
if (node.marks) {
|
|
39
40
|
for (const mark of node.marks) {
|
|
@@ -41,18 +42,33 @@ export function nodeToTreeString(node, level = 0, currentPos = 0) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
if (marksLine) {
|
|
44
|
-
output
|
|
45
|
+
output.log((delim + ' ' + marksLine) + '\n', {
|
|
46
|
+
node,
|
|
47
|
+
pos: currentPos,
|
|
48
|
+
});
|
|
45
49
|
}
|
|
46
50
|
if (node.text) {
|
|
47
|
-
output
|
|
51
|
+
output.log((delim + ' "' + trimText(node.text) + '"') + '\n', {
|
|
52
|
+
node,
|
|
53
|
+
pos: currentPos,
|
|
54
|
+
});
|
|
48
55
|
}
|
|
49
56
|
}
|
|
50
57
|
node.forEach((child, offset) => {
|
|
51
|
-
output +=
|
|
52
|
-
|
|
58
|
+
// output +=
|
|
59
|
+
nodeToTreeStringOutput(output, child, level + 1, currentPos + offset + 1);
|
|
60
|
+
// .replace(
|
|
61
|
+
// /\s+$/gm,
|
|
62
|
+
// '',
|
|
63
|
+
// ) + '\n'; // + (node.isLeaf ? 1 : 2)
|
|
53
64
|
});
|
|
54
65
|
return output;
|
|
55
66
|
}
|
|
67
|
+
export function nodeToTreeString(node) {
|
|
68
|
+
const output = new SmartOutput();
|
|
69
|
+
nodeToTreeStringOutput(output, node);
|
|
70
|
+
return output.toString();
|
|
71
|
+
}
|
|
56
72
|
export function debugNode(node) {
|
|
57
73
|
console.debug(nodeToTreeString(node));
|
|
58
74
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface OutputMeta<K> {
|
|
2
|
+
rowPos: number;
|
|
3
|
+
colPos: number;
|
|
4
|
+
item: K;
|
|
5
|
+
}
|
|
6
|
+
interface Mapping {
|
|
7
|
+
sourceNo: number;
|
|
8
|
+
sourceRowPos: number;
|
|
9
|
+
sourceColPos: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SourceMap {
|
|
12
|
+
'version': 3;
|
|
13
|
+
'file': string;
|
|
14
|
+
'sourceRoot': string;
|
|
15
|
+
'sources': Array<string>;
|
|
16
|
+
'sourcesContent': Array<string>;
|
|
17
|
+
'names': Array<string>;
|
|
18
|
+
'mappings': string;
|
|
19
|
+
}
|
|
20
|
+
export declare class SmartOutput<K> {
|
|
21
|
+
private _rowPos;
|
|
22
|
+
private _colPos;
|
|
23
|
+
private chunks;
|
|
24
|
+
private metas;
|
|
25
|
+
log(text: string, item: K): void;
|
|
26
|
+
get chunkPos(): number;
|
|
27
|
+
rollback(pos: number): void;
|
|
28
|
+
get rowPos(): number;
|
|
29
|
+
get colPos(): number;
|
|
30
|
+
endsWith(text: string): boolean;
|
|
31
|
+
toString(): string;
|
|
32
|
+
getSourceMap(mapper: (item: K, rowPos: number, colPos: number) => Mapping | void): SourceMap;
|
|
33
|
+
}
|
|
34
|
+
/** @param {string} string */
|
|
35
|
+
export declare function decode(string: any): number[];
|
|
36
|
+
/** @param {number | number[]} value */
|
|
37
|
+
export declare function encode(value: any): string;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=SmartOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartOutput.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/SmartOutput.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;CACT;AAED,UAAU,OAAO;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,CAAC,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW,CAAC,CAAC;IACxB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IAEpB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,KAAK,CAA4B;IAEzC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAiBzB,IAAI,QAAQ,WAEX;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM;IAKpB,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAET;IAED,QAAQ,CAAC,IAAI,EAAE,MAAM;IAIrB,QAAQ;IAIR,YAAY,CACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,GAClE,SAAS;CAuDb;AA0DD,6BAA6B;AAC7B,wBAAgB,MAAM,CAAC,MAAM,KAAA,YAqC5B;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CAAC,KAAK,KAAA,UAW3B"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
export class SmartOutput {
|
|
2
|
+
constructor() {
|
|
3
|
+
Object.defineProperty(this, "_rowPos", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: 0
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(this, "_colPos", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: 0
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(this, "chunks", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: []
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(this, "metas", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: []
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
log(text, item) {
|
|
29
|
+
this.chunks.push(text);
|
|
30
|
+
this.metas.push({
|
|
31
|
+
colPos: this._colPos,
|
|
32
|
+
rowPos: this._rowPos,
|
|
33
|
+
item,
|
|
34
|
+
});
|
|
35
|
+
const lines = text.split('\n');
|
|
36
|
+
if (lines.length === 1) {
|
|
37
|
+
this._colPos += lines[lines.length - 1].length;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this._rowPos += lines.length - 1;
|
|
41
|
+
this._colPos = lines[lines.length - 1].length;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
get chunkPos() {
|
|
45
|
+
return this.chunks.length;
|
|
46
|
+
}
|
|
47
|
+
rollback(pos) {
|
|
48
|
+
this.chunks.splice(pos);
|
|
49
|
+
this.metas.splice(pos);
|
|
50
|
+
}
|
|
51
|
+
get rowPos() {
|
|
52
|
+
return this._rowPos;
|
|
53
|
+
}
|
|
54
|
+
get colPos() {
|
|
55
|
+
return this._colPos;
|
|
56
|
+
}
|
|
57
|
+
endsWith(text) {
|
|
58
|
+
return this.chunks.join('').endsWith(text);
|
|
59
|
+
}
|
|
60
|
+
toString() {
|
|
61
|
+
return this.chunks.join('');
|
|
62
|
+
}
|
|
63
|
+
getSourceMap(mapper) {
|
|
64
|
+
const mappingRows = [];
|
|
65
|
+
let lastRow = -1;
|
|
66
|
+
let lastCol = -1;
|
|
67
|
+
for (const meta of this.metas) {
|
|
68
|
+
while (meta.rowPos >= mappingRows.length) {
|
|
69
|
+
mappingRows.push([]);
|
|
70
|
+
}
|
|
71
|
+
if (lastRow != meta.rowPos || lastCol != meta.colPos) {
|
|
72
|
+
const currentRow = mappingRows[meta.rowPos];
|
|
73
|
+
const mapping = mapper(meta.item, meta.rowPos, meta.colPos);
|
|
74
|
+
if (mapping) {
|
|
75
|
+
currentRow.push([
|
|
76
|
+
meta.colPos,
|
|
77
|
+
mapping.sourceNo,
|
|
78
|
+
mapping.sourceRowPos,
|
|
79
|
+
mapping.sourceColPos,
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
lastRow = meta.rowPos;
|
|
84
|
+
lastCol = meta.colPos;
|
|
85
|
+
}
|
|
86
|
+
const mappings = mappingRows
|
|
87
|
+
.map((row) => row.map((group) => encode(group))
|
|
88
|
+
.join(','))
|
|
89
|
+
.join(';');
|
|
90
|
+
mappingRows.forEach((row, rowNo) => {
|
|
91
|
+
// console.log('g', rowNo, row);
|
|
92
|
+
row.forEach((group) => {
|
|
93
|
+
const enc = encode(group);
|
|
94
|
+
// console.log('g', rowNo, group, enc, decode(enc));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
version: 3,
|
|
99
|
+
file: '',
|
|
100
|
+
sourceRoot: '',
|
|
101
|
+
sources: [],
|
|
102
|
+
sourcesContent: [],
|
|
103
|
+
names: [],
|
|
104
|
+
mappings,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
109
|
+
function toVLQ(value) {
|
|
110
|
+
const vlq = [];
|
|
111
|
+
const isNegative = value < 0;
|
|
112
|
+
value = Math.abs(value);
|
|
113
|
+
if (value === 0) {
|
|
114
|
+
vlq.push(0);
|
|
115
|
+
return vlq;
|
|
116
|
+
}
|
|
117
|
+
while (value > 0) {
|
|
118
|
+
let digit = value & 0x1F;
|
|
119
|
+
value >>= 5;
|
|
120
|
+
if (value > 0) {
|
|
121
|
+
digit |= 0x20;
|
|
122
|
+
}
|
|
123
|
+
vlq.push(digit);
|
|
124
|
+
if (vlq.length === 1) {
|
|
125
|
+
digit = isNegative ? (digit | 0x1) : (digit & ~0x1);
|
|
126
|
+
vlq[0] = digit;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return vlq;
|
|
130
|
+
}
|
|
131
|
+
function encodeVLQ(input) {
|
|
132
|
+
const numbers = Array.isArray(input) ? input : [input];
|
|
133
|
+
let result = '';
|
|
134
|
+
for (const num of numbers) {
|
|
135
|
+
const vlq = toVLQ(num);
|
|
136
|
+
for (const digit of vlq) {
|
|
137
|
+
result += BASE64_CHARS[digit];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
/** @type {Record<string, number>} */
|
|
143
|
+
let char_to_integer = {};
|
|
144
|
+
/** @type {Record<number, string>} */
|
|
145
|
+
let integer_to_char = {};
|
|
146
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
|
147
|
+
.split('')
|
|
148
|
+
.forEach(function (char, i) {
|
|
149
|
+
char_to_integer[char] = i;
|
|
150
|
+
integer_to_char[i] = char;
|
|
151
|
+
});
|
|
152
|
+
/** @param {string} string */
|
|
153
|
+
export function decode(string) {
|
|
154
|
+
/** @type {number[]} */
|
|
155
|
+
let result = [];
|
|
156
|
+
let shift = 0;
|
|
157
|
+
let value = 0;
|
|
158
|
+
for (let i = 0; i < string.length; i += 1) {
|
|
159
|
+
let integer = char_to_integer[string[i]];
|
|
160
|
+
if (integer === undefined) {
|
|
161
|
+
throw new Error('Invalid character (' + string[i] + ')');
|
|
162
|
+
}
|
|
163
|
+
const has_continuation_bit = integer & 32;
|
|
164
|
+
integer &= 31;
|
|
165
|
+
value += integer << shift;
|
|
166
|
+
if (has_continuation_bit) {
|
|
167
|
+
shift += 5;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const should_negate = value & 1;
|
|
171
|
+
value >>>= 1;
|
|
172
|
+
if (should_negate) {
|
|
173
|
+
result.push(value === 0 ? -0x80000000 : -value);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
result.push(value);
|
|
177
|
+
}
|
|
178
|
+
// reset
|
|
179
|
+
value = shift = 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
/** @param {number | number[]} value */
|
|
185
|
+
export function encode(value) {
|
|
186
|
+
if (typeof value === 'number') {
|
|
187
|
+
return encode_integer(value);
|
|
188
|
+
}
|
|
189
|
+
let result = '';
|
|
190
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
191
|
+
result += encode_integer(value[i]);
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
/** @param {number} num */
|
|
196
|
+
function encode_integer(num) {
|
|
197
|
+
let result = '';
|
|
198
|
+
if (num < 0) {
|
|
199
|
+
num = (-num << 1) | 1;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
num <<= 1;
|
|
203
|
+
}
|
|
204
|
+
do {
|
|
205
|
+
let clamped = num & 31;
|
|
206
|
+
num >>>= 5;
|
|
207
|
+
if (num > 0) {
|
|
208
|
+
clamped |= 32;
|
|
209
|
+
}
|
|
210
|
+
result += integer_to_char[clamped];
|
|
211
|
+
} while (num > 0);
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
@@ -4,7 +4,6 @@ export interface OdtConfig {
|
|
|
4
4
|
linkFromRewriter?(href: string): string;
|
|
5
5
|
}
|
|
6
6
|
export declare class ExtensionOdt extends Extension {
|
|
7
|
-
protected config: OdtConfig;
|
|
8
7
|
name: string;
|
|
9
8
|
constructor(config?: OdtConfig);
|
|
10
9
|
getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionOdt.d.ts","sourceRoot":"","sources":["../../../src/extension-odt/src/ExtensionOdt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMrF,MAAM,WAAW,SAAS;IACxB,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACzC;AAED,qBAAa,YAAa,SAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"ExtensionOdt.d.ts","sourceRoot":"","sources":["../../../src/extension-odt/src/ExtensionOdt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMrF,MAAM,WAAW,SAAS;IACxB,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACzC;AAED,qBAAa,YAAa,SAAQ,SAAS;IACzC,IAAI,SAAS;gBAED,MAAM,GAAE,SAAc;IAIzB,aAAa,CACpB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;CA6C7B"}
|
|
@@ -5,12 +5,6 @@ import { getDefaultsPostProcessFilters } from './postprocess/postProcess.js';
|
|
|
5
5
|
export class ExtensionOdt extends Extension {
|
|
6
6
|
constructor(config = {}) {
|
|
7
7
|
super(config);
|
|
8
|
-
Object.defineProperty(this, "config", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: config
|
|
13
|
-
});
|
|
14
8
|
Object.defineProperty(this, "name", {
|
|
15
9
|
enumerable: true,
|
|
16
10
|
configurable: true,
|
|
@@ -20,31 +14,34 @@ export class ExtensionOdt extends Extension {
|
|
|
20
14
|
}
|
|
21
15
|
getConverters(editor, schema) {
|
|
22
16
|
const config = this.config;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const contentTree = parse_content(files.get('content.xml'));
|
|
32
|
-
// console.log(JSON.stringify(stylesTree, null, 2).split('\n').slice(0, 20).join('\n'));
|
|
33
|
-
// console.log(JSON.stringify(contentTree, null, 2).split('\n').slice(0, 20).join('\n'));
|
|
17
|
+
const odtConverter = {
|
|
18
|
+
fromDoc: async (document) => {
|
|
19
|
+
throw new Error('Not implemented');
|
|
20
|
+
},
|
|
21
|
+
toDoc: async (buffer) => {
|
|
22
|
+
const doc = await odtConverter.odtToJson(buffer);
|
|
23
|
+
const filterCommands = getDefaultsPostProcessFilters();
|
|
24
|
+
if (filterCommands.length > 0) {
|
|
34
25
|
const subEditor = editor.clone();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (filterCommands.length > 0) {
|
|
39
|
-
subEditor.setDocument(doc);
|
|
40
|
-
for (const filter of filterCommands) {
|
|
41
|
-
filter(subEditor.state, (tr) => subEditor.dispatchTransaction(tr));
|
|
42
|
-
}
|
|
43
|
-
return subEditor.getDocument();
|
|
26
|
+
subEditor.setDocument(doc.toJSON());
|
|
27
|
+
for (const filter of filterCommands) {
|
|
28
|
+
filter(subEditor.state, (tr) => subEditor.dispatchTransaction(tr));
|
|
44
29
|
}
|
|
45
|
-
return
|
|
46
|
-
}
|
|
30
|
+
return subEditor.getDocument();
|
|
31
|
+
}
|
|
32
|
+
return doc;
|
|
33
|
+
},
|
|
34
|
+
odtToJson: async (buffer) => {
|
|
35
|
+
const files = unzip(buffer);
|
|
36
|
+
const stylesTree = parse_styles(files.get('styles.xml'));
|
|
37
|
+
const contentTree = parse_content(files.get('content.xml'));
|
|
38
|
+
const parser = new OdtParser(editor.schema, config);
|
|
39
|
+
const doc = parser.parse({ ...files, contentTree, stylesTree });
|
|
40
|
+
return doc;
|
|
47
41
|
},
|
|
48
42
|
};
|
|
43
|
+
return {
|
|
44
|
+
'application/vnd.oasis.opendocument.text': odtConverter,
|
|
45
|
+
};
|
|
49
46
|
}
|
|
50
47
|
}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
node?: string;
|
|
6
|
-
children?: (node: OdtElement) => OdtElement[];
|
|
7
|
-
custom?: (state: OdtParseState, element?: OdtElement) => void;
|
|
8
|
-
text?: (node: OdtElement) => string;
|
|
9
|
-
block?: string | ((node: OdtElement, style: any) => [string]);
|
|
10
|
-
mark?: string;
|
|
11
|
-
attrs?: Attrs | null;
|
|
12
|
-
getAttrs?: (token: OdtElement, style: Style) => Attrs | null;
|
|
13
|
-
ignore?: boolean;
|
|
1
|
+
import { Mark, Node, Schema } from 'prosemirror-model';
|
|
2
|
+
import { ListTracker } from './lists.js';
|
|
3
|
+
export interface OdtElement {
|
|
4
|
+
$value: 'TODO';
|
|
14
5
|
}
|
|
6
|
+
export type NodeHandler = (ctx: OdtStashContext, value: any) => void;
|
|
15
7
|
interface ListStyle {
|
|
16
8
|
'@name': string;
|
|
17
9
|
}
|
|
18
10
|
interface Style {
|
|
19
11
|
'@name': string;
|
|
12
|
+
'@parent-style-name'?: string;
|
|
13
|
+
styles: string[];
|
|
20
14
|
}
|
|
21
15
|
interface StylesTree {
|
|
22
16
|
styles: {
|
|
@@ -27,64 +21,48 @@ interface StylesTree {
|
|
|
27
21
|
interface AutomaticStyles {
|
|
28
22
|
'style': Array<Style>;
|
|
29
23
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
declare class OdtParseState {
|
|
35
|
-
readonly schema: Schema;
|
|
36
|
-
readonly tokens: {
|
|
37
|
-
[name: string]: ParseSpec;
|
|
38
|
-
};
|
|
39
|
-
private readonly stylesTree;
|
|
40
|
-
private readonly automaticStyles;
|
|
41
|
-
stack: {
|
|
42
|
-
type: NodeType;
|
|
43
|
-
attrs: Attrs | null;
|
|
44
|
-
content: Node[];
|
|
45
|
-
marks: readonly Mark[];
|
|
46
|
-
}[];
|
|
47
|
-
textMarks: Set<TextMark>;
|
|
48
|
-
nextTextMarks: Set<TextMark>;
|
|
49
|
-
constructor(schema: Schema, tokens: {
|
|
50
|
-
[name: string]: ParseSpec;
|
|
51
|
-
}, stylesTree: StylesTree, automaticStyles: AutomaticStyles);
|
|
52
|
-
top(): {
|
|
53
|
-
type: NodeType;
|
|
54
|
-
attrs: Attrs | null;
|
|
55
|
-
content: Node[];
|
|
56
|
-
marks: readonly Mark[];
|
|
57
|
-
};
|
|
58
|
-
push(elt: Node): void;
|
|
59
|
-
addText(text: string): void;
|
|
60
|
-
openMark(mark: Mark): MarkType;
|
|
61
|
-
closeMark(mark: MarkType): void;
|
|
62
|
-
addNode(type: NodeType, attrs: Attrs | null, content?: readonly Node[], marks?: readonly Mark[]): Node | null;
|
|
63
|
-
openNode(type: NodeType, attrs: Attrs | null): void;
|
|
64
|
-
closeNode(marks?: readonly Mark[]): Node | null;
|
|
65
|
-
handleElement(nodeType: string, element: OdtElement): void;
|
|
24
|
+
export declare function resolveStyle(stylesTree: StylesTree, automaticStyles: AutomaticStyles, name: string): Style;
|
|
25
|
+
export interface TaggedEnum {
|
|
26
|
+
tag: string;
|
|
27
|
+
value: any;
|
|
66
28
|
}
|
|
29
|
+
export declare function tagEnum(item: any): {
|
|
30
|
+
tag: string;
|
|
31
|
+
value: unknown;
|
|
32
|
+
};
|
|
33
|
+
export declare function iterateChildren(nodes: unknown[], callback: (item: TaggedEnum) => void): void;
|
|
34
|
+
export declare function iterateEnum($value: unknown[]): Array<TaggedEnum>;
|
|
67
35
|
interface Config {
|
|
68
36
|
linkFromRewriter?(href: string): string;
|
|
69
37
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
38
|
+
export interface OdtContext {
|
|
39
|
+
handlers: Record<string, NodeHandler>;
|
|
40
|
+
content: Node[];
|
|
41
|
+
marks: Mark[];
|
|
42
|
+
meta: Record<string, any>;
|
|
43
|
+
}
|
|
44
|
+
export declare class OdtStashContext {
|
|
45
|
+
readonly schema: Schema;
|
|
46
|
+
readonly stylesTree: StylesTree;
|
|
47
|
+
readonly automaticStyles: AutomaticStyles;
|
|
48
|
+
private ctxStash;
|
|
49
|
+
private currentCtx;
|
|
50
|
+
listTracker: ListTracker;
|
|
51
|
+
constructor(schema: Schema, handlers: Record<string, NodeHandler>, stylesTree: StylesTree, automaticStyles: AutomaticStyles);
|
|
52
|
+
stash(): number;
|
|
53
|
+
unstash(): void;
|
|
54
|
+
openNode(): void;
|
|
55
|
+
closeNode(type: string, attrs?: {}, marks?: readonly Mark[]): Node;
|
|
56
|
+
private createNode;
|
|
57
|
+
createText(text: string): Node | undefined;
|
|
58
|
+
styleToMarks(style: Style): Mark[];
|
|
59
|
+
handle(nodeType: string, value: any): void;
|
|
60
|
+
getElementStyle(element: any): Style;
|
|
61
|
+
get current(): OdtContext;
|
|
80
62
|
}
|
|
81
63
|
export declare class OdtParser {
|
|
82
64
|
private readonly schema;
|
|
83
65
|
private readonly config;
|
|
84
|
-
listStack: never[];
|
|
85
|
-
listNumberings: Map<string, ListNumbering>;
|
|
86
|
-
private lastNumbering?;
|
|
87
|
-
preserveMinLevel: number;
|
|
88
66
|
constructor(schema: Schema, config?: Config);
|
|
89
67
|
parse(files: any): Node;
|
|
90
68
|
}
|