@kerebron/extension-odt 0.4.26 → 0.4.27

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.
Files changed (35) hide show
  1. package/package.json +4 -3
  2. package/esm/ExtensionOdt.d.ts +0 -16
  3. package/esm/ExtensionOdt.d.ts.map +0 -1
  4. package/esm/ExtensionOdt.js +0 -130
  5. package/esm/OdtParser.d.ts +0 -70
  6. package/esm/OdtParser.d.ts.map +0 -1
  7. package/esm/OdtParser.js +0 -249
  8. package/esm/lists.d.ts +0 -23
  9. package/esm/lists.d.ts.map +0 -1
  10. package/esm/lists.js +0 -23
  11. package/esm/node_handlers/basic_node_handlers.d.ts +0 -4
  12. package/esm/node_handlers/basic_node_handlers.d.ts.map +0 -1
  13. package/esm/node_handlers/basic_node_handlers.js +0 -133
  14. package/esm/node_handlers/list_node_handlers.d.ts +0 -3
  15. package/esm/node_handlers/list_node_handlers.d.ts.map +0 -1
  16. package/esm/node_handlers/list_node_handlers.js +0 -91
  17. package/esm/node_handlers/table_node_handlers.d.ts +0 -3
  18. package/esm/node_handlers/table_node_handlers.d.ts.map +0 -1
  19. package/esm/node_handlers/table_node_handlers.js +0 -24
  20. package/esm/package.json +0 -3
  21. package/esm/postprocess/convertCodeParagraphsToCodeBlocks.d.ts +0 -3
  22. package/esm/postprocess/convertCodeParagraphsToCodeBlocks.d.ts.map +0 -1
  23. package/esm/postprocess/convertCodeParagraphsToCodeBlocks.js +0 -81
  24. package/esm/postprocess/convertMathMl.d.ts +0 -3
  25. package/esm/postprocess/convertMathMl.d.ts.map +0 -1
  26. package/esm/postprocess/convertMathMl.js +0 -35
  27. package/esm/postprocess/fixContinuedLists.d.ts +0 -3
  28. package/esm/postprocess/fixContinuedLists.d.ts.map +0 -1
  29. package/esm/postprocess/fixContinuedLists.js +0 -80
  30. package/esm/postprocess/postProcess.d.ts +0 -8
  31. package/esm/postprocess/postProcess.d.ts.map +0 -1
  32. package/esm/postprocess/postProcess.js +0 -12
  33. package/esm/postprocess/removeUnusedBookmarks.d.ts +0 -3
  34. package/esm/postprocess/removeUnusedBookmarks.d.ts.map +0 -1
  35. package/esm/postprocess/removeUnusedBookmarks.js +0 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerebron/extension-odt",
3
- "version": "0.4.26",
3
+ "version": "0.4.27",
4
4
  "license": "MIT",
5
5
  "module": "./esm/ExtensionOdt.js",
6
6
  "exports": {
@@ -9,9 +9,10 @@
9
9
  }
10
10
  },
11
11
  "scripts": {},
12
+ "files": [],
12
13
  "dependencies": {
13
- "@kerebron/editor": "0.4.26",
14
- "@kerebron/odt-wasm": "0.4.26",
14
+ "@kerebron/editor": "0.4.27",
15
+ "@kerebron/odt-wasm": "0.4.27",
15
16
  "prosemirror-model": "1.25.3",
16
17
  "prosemirror-state": "1.4.3"
17
18
  },
@@ -1,16 +0,0 @@
1
- import type { Schema } from 'prosemirror-model';
2
- import { type Converter, type CoreEditor, Extension, type UrlRewriter } from '@kerebron/editor';
3
- import { OdtParserConfig } from './OdtParser.js';
4
- import { Command } from '@kerebron/editor/commands';
5
- export interface OdtConfig extends OdtParserConfig {
6
- debug?: boolean;
7
- postProcessCommands?: Command[];
8
- }
9
- export declare class ExtensionOdt extends Extension {
10
- config: OdtConfig;
11
- name: string;
12
- urlFromRewriter?: UrlRewriter;
13
- constructor(config?: OdtConfig);
14
- getConverters(editor: CoreEditor, schema: Schema): Record<string, Converter>;
15
- }
16
- //# sourceMappingURL=ExtensionOdt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExtensionOdt.d.ts","sourceRoot":"","sources":["../src/ExtensionOdt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,SAAS,EACT,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAa,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpD,MAAM,WAAW,SAAU,SAAQ,eAAe;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mBAAmB,CAAC,EAAE,OAAO,EAAE,CAAC;CACjC;AAED,qBAAa,YAAa,SAAQ,SAAS;IAIb,MAAM,EAAE,SAAS;IAH7C,IAAI,SAAS;IACN,eAAe,CAAC,EAAE,WAAW,CAAC;gBAET,MAAM,GAAE,SAAc;IAIzC,aAAa,CACpB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;CAoK7B"}
@@ -1,130 +0,0 @@
1
- import { Extension, } from '@kerebron/editor';
2
- import { parse_content, parse_styles, unzip } from '@kerebron/odt-wasm';
3
- import { OdtParser } from './OdtParser.js';
4
- import { getDefaultsPostProcessFilters } from './postprocess/postProcess.js';
5
- import { InputRulesPlugin } from '@kerebron/editor/plugins/input-rules';
6
- export class ExtensionOdt extends Extension {
7
- config;
8
- name = 'odt';
9
- urlFromRewriter;
10
- constructor(config = {}) {
11
- super(config);
12
- this.config = config;
13
- }
14
- getConverters(editor, schema) {
15
- const config = this.config;
16
- const odtConverter = {
17
- fromDoc: async (document) => {
18
- throw new Error('Not implemented');
19
- },
20
- toDoc: async (buffer) => {
21
- const { doc, filesMap } = odtConverter.odtToJson(buffer);
22
- const filterCommands = getDefaultsPostProcessFilters({
23
- doc,
24
- filesMap,
25
- }).concat(this.config.postProcessCommands || []);
26
- const plugin = editor.state.plugins.find((plugin) => plugin instanceof InputRulesPlugin);
27
- if (plugin) {
28
- // plugin.props.
29
- }
30
- const subEditor = editor.clone();
31
- subEditor.setDocument(doc.toJSON());
32
- let modified = false;
33
- if (this.urlFromRewriter) {
34
- const imageNodes = [];
35
- subEditor.getDocument().descendants((node, pos) => {
36
- if (node.type.name === 'image') {
37
- imageNodes.push({ node, pos });
38
- }
39
- });
40
- const linkNodes = [];
41
- subEditor.getDocument().descendants((node, pos) => {
42
- if (node.marks.find((mark) => mark.type.name === 'link')) {
43
- linkNodes.push({ node, pos });
44
- }
45
- });
46
- const tr = subEditor.state.tr;
47
- for (const { node, pos } of linkNodes) {
48
- const linkMark = node.marks.find((mark) => mark.type.name === 'link');
49
- if (!linkMark) {
50
- continue;
51
- }
52
- let href = linkMark.attrs.href || '';
53
- href = await this.urlFromRewriter(href, {
54
- type: 'A',
55
- dest: 'kerebron',
56
- });
57
- if (href !== linkMark.attrs.href) {
58
- const newMarks = node.marks.map((mark) => {
59
- if (mark.type.name === 'link') {
60
- const markType = this.editor.schema.marks['link'];
61
- return markType.create({ ...mark.attrs, href });
62
- }
63
- return mark;
64
- });
65
- const nodeType = this.editor.schema.nodes[node.type.name];
66
- let replaceNode;
67
- if (nodeType.isText) {
68
- replaceNode = this.editor.schema.text(node.text || '', newMarks);
69
- }
70
- else {
71
- replaceNode = nodeType.create(node.attrs, node.content, newMarks);
72
- }
73
- tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos + node.nodeSize), replaceNode);
74
- }
75
- }
76
- for (const { node, pos } of imageNodes) {
77
- let src = node.attrs.src || '';
78
- src = await this.urlFromRewriter(src, {
79
- type: 'IMG',
80
- dest: 'kerebron',
81
- filesMap,
82
- });
83
- if (src !== node.attrs.src) {
84
- const nodeType = this.editor.schema.nodes[node.type.name];
85
- const replaceNode = nodeType.create({ ...node.attrs, src }, node.content, node.marks);
86
- tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos + node.nodeSize), replaceNode);
87
- }
88
- }
89
- subEditor.dispatchTransaction(tr), modified = true;
90
- }
91
- if (filterCommands.length > 0) {
92
- for (const filter of filterCommands) {
93
- filter(subEditor.state, (tr) => subEditor.dispatchTransaction(tr));
94
- }
95
- modified = true;
96
- }
97
- if (modified) {
98
- return subEditor.getDocument();
99
- }
100
- return doc;
101
- },
102
- odtToJson: (buffer) => {
103
- const files = unzip(buffer);
104
- const filesMap = {};
105
- for (const k of files.keys()) {
106
- filesMap[k] = Uint8Array.from(files.get(k));
107
- }
108
- const stylesTree = parse_styles(files.get('styles.xml'));
109
- const contentTree = parse_content(files.get('content.xml'));
110
- if (this.config.debug) {
111
- const event = new CustomEvent('odt:parsed', {
112
- detail: {
113
- stylesTree,
114
- contentTree,
115
- filesMap,
116
- },
117
- });
118
- this.editor.dispatchEvent(event);
119
- }
120
- const parser = new OdtParser(editor.schema, this.config);
121
- parser.filesMap = filesMap;
122
- const doc = parser.parse({ ...filesMap, contentTree, stylesTree });
123
- return { doc, stylesTree, contentTree, filesMap };
124
- },
125
- };
126
- return {
127
- 'application/vnd.oasis.opendocument.text': odtConverter,
128
- };
129
- }
130
- }
@@ -1,70 +0,0 @@
1
- import { Mark, Node, Schema } from 'prosemirror-model';
2
- import { ListTracker } from './lists.js';
3
- export interface OdtElement {
4
- $value: 'TODO';
5
- }
6
- export type NodeHandler = (ctx: OdtStashContext, value: any) => void;
7
- interface ListStyle {
8
- '@name': string;
9
- }
10
- interface Style {
11
- '@name': string;
12
- '@parent-style-name'?: string;
13
- styles: string[];
14
- }
15
- interface StylesTree {
16
- styles: {
17
- 'list-style': Array<ListStyle>;
18
- 'style': Array<Style>;
19
- };
20
- }
21
- interface AutomaticStyles {
22
- 'style': Array<Style>;
23
- }
24
- export declare function resolveStyle(stylesTree: StylesTree, automaticStyles: AutomaticStyles, name: string): Style;
25
- export interface TaggedEnum {
26
- tag: string;
27
- value: any;
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>;
35
- export interface OdtParserConfig {
36
- }
37
- export interface OdtContext {
38
- handlers: Record<string, NodeHandler>;
39
- content: Node[];
40
- marks: Mark[];
41
- meta: Record<string, any>;
42
- }
43
- export declare class OdtStashContext {
44
- readonly schema: Schema;
45
- readonly stylesTree: StylesTree;
46
- readonly automaticStyles: AutomaticStyles;
47
- private ctxStash;
48
- private currentCtx;
49
- listTracker: ListTracker;
50
- constructor(schema: Schema, handlers: Record<string, NodeHandler>, stylesTree: StylesTree, automaticStyles: AutomaticStyles);
51
- stash(): number;
52
- unstash(): void;
53
- openNode(): void;
54
- closeNode(type: string, attrs?: {}, marks?: readonly Mark[]): Node;
55
- private createNode;
56
- createText(text: string): Node | undefined;
57
- styleToMarks(style: Style): Mark[];
58
- handle(nodeType: string, value: any): void;
59
- getElementStyle(element: any): Style;
60
- get current(): OdtContext;
61
- }
62
- export declare class OdtParser {
63
- private readonly schema;
64
- private readonly config;
65
- constructor(schema: Schema, config?: OdtParserConfig);
66
- filesMap?: Record<string, Uint8Array<ArrayBufferLike>>;
67
- parse(files: any): Node;
68
- }
69
- export {};
70
- //# sourceMappingURL=OdtParser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OdtParser.d.ts","sourceRoot":"","sources":["../src/OdtParser.ts"],"names":[],"mappings":"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"}
package/esm/OdtParser.js DELETED
@@ -1,249 +0,0 @@
1
- import { Mark } from 'prosemirror-model';
2
- import { getBasicNodesHandlers, getInlineNodesHandlers, } from './node_handlers/basic_node_handlers.js';
3
- import { getListNodesHandlers } from './node_handlers/list_node_handlers.js';
4
- import { getTableNodesHandlers } from './node_handlers/table_node_handlers.js';
5
- import { ListTracker } from './lists.js';
6
- const COURIER_FONTS = ['Courier New', 'Courier', 'Roboto Mono'];
7
- export function resolveStyle(stylesTree, automaticStyles, name) {
8
- let style;
9
- if (!style) {
10
- style = stylesTree.styles['list-style'].find((item) => item['@name'] === name);
11
- }
12
- if (!style) {
13
- style = stylesTree.styles['style'].find((item) => item['@name'] === name);
14
- }
15
- if (!style) {
16
- style = automaticStyles.style.find((item) => item['@name'] === name);
17
- }
18
- if (!style) {
19
- style = {
20
- '@name': name,
21
- };
22
- }
23
- style['styles'] = [name];
24
- if (style['@parent-style-name']) {
25
- const parentStyle = resolveStyle(stylesTree, automaticStyles, style['@parent-style-name']);
26
- if (parentStyle) {
27
- const styles = [...style['styles'], ...parentStyle['styles']];
28
- for (const key in style) {
29
- if (typeof style[key] === 'undefined') {
30
- delete style[key];
31
- }
32
- }
33
- style = {
34
- ...parentStyle,
35
- ...style,
36
- styles,
37
- };
38
- }
39
- }
40
- return style;
41
- }
42
- export function tagEnum(item) {
43
- if ('string' === typeof item) {
44
- return {
45
- tag: item, // '$text',
46
- value: item,
47
- };
48
- }
49
- if ('object' === typeof item) {
50
- const entries = Object.entries(item);
51
- if (entries.length === 1) {
52
- return {
53
- tag: entries[0][0],
54
- value: entries[0][1],
55
- };
56
- }
57
- }
58
- throw new Error('Incorrect enum: ' + JSON.stringify(item));
59
- }
60
- export function iterateChildren(nodes, callback) {
61
- for (const child of nodes) {
62
- if ('Unknown' === child) {
63
- continue;
64
- }
65
- const item = tagEnum(child);
66
- callback(item);
67
- }
68
- }
69
- export function iterateEnum($value) {
70
- if (!$value) {
71
- return [];
72
- }
73
- return $value.map(tagEnum);
74
- }
75
- export class OdtStashContext {
76
- schema;
77
- stylesTree;
78
- automaticStyles;
79
- ctxStash = [];
80
- currentCtx;
81
- listTracker = new ListTracker();
82
- constructor(schema, handlers, stylesTree, automaticStyles) {
83
- this.schema = schema;
84
- this.stylesTree = stylesTree;
85
- this.automaticStyles = automaticStyles;
86
- this.currentCtx = {
87
- handlers,
88
- content: [],
89
- marks: [],
90
- meta: {},
91
- };
92
- this.stash();
93
- }
94
- stash() {
95
- this.ctxStash.push(this.currentCtx);
96
- const funcs = {};
97
- const handlers = { ...this.currentCtx.handlers };
98
- const content = this.currentCtx.content;
99
- const marks = this.currentCtx.marks;
100
- this.currentCtx = {
101
- ...structuredClone({
102
- ...this.currentCtx,
103
- content: undefined,
104
- marks: undefined,
105
- handlers: undefined,
106
- }),
107
- ...funcs,
108
- content,
109
- marks,
110
- handlers,
111
- };
112
- return this.ctxStash.length - 1;
113
- }
114
- unstash() {
115
- const ctx = this.ctxStash.pop();
116
- if (!ctx) {
117
- throw new Error('Unstash failed');
118
- }
119
- this.currentCtx = ctx;
120
- }
121
- openNode() {
122
- this.stash();
123
- this.current.content = [];
124
- }
125
- closeNode(type, attrs = {}, marks = Mark.none) {
126
- const node = this.createNode(type, attrs, marks);
127
- this.unstash();
128
- if (node) {
129
- this.current.content.push(node);
130
- }
131
- return node;
132
- }
133
- createNode(type, attrs = {}, marks = Mark.none) {
134
- const nodeType = this.schema.nodes[type];
135
- if (!nodeType) {
136
- throw new Error('Invalid node type: ' + type);
137
- }
138
- const node = nodeType.createAndFill(attrs, this.current.content, marks);
139
- if (!node) {
140
- throw new Error('Error creating node: ' + type);
141
- }
142
- return node;
143
- }
144
- createText(text) {
145
- if (!text)
146
- return;
147
- return this.schema.text(text, this.current.marks);
148
- }
149
- styleToMarks(style) {
150
- const marks = [];
151
- const textProperties = style && style['text-properties'] || {};
152
- if (COURIER_FONTS.indexOf(textProperties['@font-name'] || '') > -1) {
153
- const markType = this.schema.mark('code');
154
- marks.push(markType);
155
- }
156
- if (textProperties['@font-style'] === 'italic') {
157
- const markType = this.schema.mark('em');
158
- marks.push(markType);
159
- }
160
- if (textProperties['@font-weight'] === 'bold') {
161
- const markType = this.schema.mark('strong');
162
- marks.push(markType);
163
- }
164
- return marks;
165
- }
166
- handle(nodeType, value) {
167
- if (!this.current.handlers[nodeType]) {
168
- throw new Error('No handler for node: ' + nodeType);
169
- }
170
- if ('function' !== typeof this.current.handlers[nodeType]) {
171
- throw new Error('Invalid handler for node: ' + nodeType);
172
- }
173
- this.current.handlers[nodeType](this, value);
174
- }
175
- getElementStyle(element) {
176
- const style = ('object' === typeof element && element['@style-name'])
177
- ? resolveStyle(this.stylesTree, this.automaticStyles, element['@style-name'])
178
- : {};
179
- return style;
180
- }
181
- get current() {
182
- return this.currentCtx;
183
- }
184
- }
185
- export class OdtParser {
186
- schema;
187
- config;
188
- constructor(schema, config = {}) {
189
- this.schema = schema;
190
- this.config = config;
191
- }
192
- filesMap;
193
- parse(files) {
194
- const contentTree = files.contentTree;
195
- const stylesTree = files.stylesTree;
196
- const handlers = {
197
- ...getInlineNodesHandlers(),
198
- ...getBasicNodesHandlers(),
199
- ...getListNodesHandlers(),
200
- ...getTableNodesHandlers(),
201
- 'change-start': {
202
- // custom(state) {
203
- // state.textMarks.add({
204
- // markName: 'change',
205
- // markAttributes: {},
206
- // });
207
- // },
208
- },
209
- 'change-end': {
210
- // custom(state) {
211
- // state.textMarks.forEach((x) =>
212
- // x.markName === 'change' ? state.textMarks.delete(x) : x
213
- // );
214
- // },
215
- },
216
- 'frame': (ctx, odtElement) => {
217
- if (odtElement.object && odtElement.object['@href']) {
218
- const fullPath = odtElement.object['@href'].replace(/^\.\//, '') +
219
- '/content.xml';
220
- if (files[fullPath]) {
221
- const content = new TextDecoder().decode(files[fullPath]);
222
- ctx.openNode();
223
- ctx.closeNode('math', {
224
- lang: 'mathml',
225
- content,
226
- });
227
- return;
228
- }
229
- }
230
- if (odtElement.image && odtElement.image['@href']) { // TODO links rewrite
231
- const alt = odtElement.description?.value || '';
232
- const src = odtElement.image['@href'];
233
- ctx.openNode();
234
- ctx.closeNode('image', {
235
- src,
236
- alt,
237
- });
238
- }
239
- },
240
- 'annotation': () => {
241
- // ignore: true,
242
- },
243
- };
244
- const ctx = new OdtStashContext(this.schema, handlers, stylesTree, contentTree['automatic-styles']);
245
- ctx.openNode();
246
- ctx.handle('body', contentTree.body);
247
- return ctx.closeNode('doc');
248
- }
249
- }
package/esm/lists.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import { OdtElement } from './OdtParser.js';
2
- export declare class ListNumbering {
3
- levels: {
4
- [level: number]: number;
5
- };
6
- levelNodes: {
7
- [level: number]: Node;
8
- };
9
- constructor();
10
- clearAbove(level: number): void;
11
- setLevelNode(level: number, node: Node): void;
12
- }
13
- export interface List {
14
- level: number;
15
- odtElement: OdtElement;
16
- }
17
- export declare class ListTracker {
18
- listStack: List[];
19
- listNumberings: Map<string, ListNumbering>;
20
- lastNumbering?: ListNumbering;
21
- preserveMinLevel: number;
22
- }
23
- //# sourceMappingURL=lists.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../src/lists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,qBAAa,aAAa;IACxB,MAAM,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAM;IACzC,UAAU,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAM;;IAQ3C,UAAU,CAAC,KAAK,EAAE,MAAM;IAMxB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;CAGvC;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,qBAAa,WAAW;IACtB,SAAS,EAAE,IAAI,EAAE,CAAM;IAEvB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAoC;IAC9E,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,gBAAgB,SAAO;CACxB"}
package/esm/lists.js DELETED
@@ -1,23 +0,0 @@
1
- export class ListNumbering {
2
- levels = {};
3
- levelNodes = {};
4
- constructor() {
5
- for (let i = 0; i < 20; i++) {
6
- this.levels[i] = 1;
7
- }
8
- }
9
- clearAbove(level) {
10
- for (let i = level + 1; i < 20; i++) {
11
- this.levels[i] = 1;
12
- }
13
- }
14
- setLevelNode(level, node) {
15
- this.levelNodes[level] = node;
16
- }
17
- }
18
- export class ListTracker {
19
- listStack = [];
20
- listNumberings = new Map();
21
- lastNumbering;
22
- preserveMinLevel = 999;
23
- }
@@ -1,4 +0,0 @@
1
- import { NodeHandler } from '../OdtParser.js';
2
- export declare function getInlineNodesHandlers(): Record<string, NodeHandler>;
3
- export declare function getBasicNodesHandlers(): Record<string, NodeHandler>;
4
- //# sourceMappingURL=basic_node_handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic_node_handlers.d.ts","sourceRoot":"","sources":["../../src/node_handlers/basic_node_handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAEhF,wBAAgB,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CA4DpE;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CA0FnE"}
@@ -1,133 +0,0 @@
1
- import { iterateChildren } from '../OdtParser.js';
2
- export function getInlineNodesHandlers() {
3
- return {
4
- '$text': (ctx, value) => {
5
- const node = ctx.createText(value);
6
- if (node) {
7
- ctx.current.content.push(node);
8
- }
9
- },
10
- 's': (ctx, odtElement) => {
11
- const chars = odtElement['@c'] || 1;
12
- const text = ' '.repeat(chars);
13
- const node = ctx.createText(text);
14
- if (node) {
15
- ctx.current.content.push(node);
16
- }
17
- },
18
- 'tab': (ctx, odtElement) => {
19
- const node = ctx.createText('\t');
20
- if (node) {
21
- ctx.current.content.push(node);
22
- }
23
- },
24
- 'rect': (ctx, odtElement) => {
25
- // if (odtElement['@rel-width'] === '100%') {
26
- // ctx.openNode();
27
- // ctx.closeNode('hr');
28
- // }
29
- },
30
- 'line-break': (ctx, odtElement) => {
31
- ctx.openNode();
32
- ctx.closeNode('br');
33
- },
34
- 'soft-page-break': (ctx, odtElement) => {
35
- ctx.openNode();
36
- ctx.closeNode('br');
37
- },
38
- 'bookmark': (ctx, element) => {
39
- ctx.openNode();
40
- ctx.closeNode('bookmark-node', {
41
- id: element['@name'],
42
- });
43
- },
44
- 'bookmark-start': (ctx, element) => {
45
- // state.textMarks.add({
46
- // markName: 'bookmark',
47
- // markAttributes: {
48
- // id: element['@name'],
49
- // },
50
- // });
51
- },
52
- 'bookmark-end': (ctx, element) => {
53
- // state.textMarks.forEach((x) =>
54
- // x.markName === 'bookmark' &&
55
- // x.markAttributes.id === element['@name']
56
- // ? state.textMarks.delete(x)
57
- // : x
58
- // );
59
- },
60
- };
61
- }
62
- export function getBasicNodesHandlers() {
63
- return {
64
- 'body': (ctx, value) => {
65
- ctx.handle('text', value.text);
66
- },
67
- 'text': (ctx, value) => {
68
- iterateChildren(value.$value, (child) => ctx.handle(child.tag, child.value));
69
- },
70
- 'p': (ctx, value) => {
71
- const attrs = {};
72
- const style = ctx.getElementStyle(value);
73
- const heading = style.styles.find((item) => item.startsWith('Heading_20_'));
74
- if (heading) {
75
- attrs.level = parseInt(heading.substring('Heading_20_'.length));
76
- }
77
- let nodeType = 'paragraph';
78
- if (style.styles.find((item) => item.startsWith('Heading_20_'))) {
79
- nodeType = 'heading';
80
- }
81
- ctx.openNode();
82
- const marks = ctx.styleToMarks(style);
83
- if (marks.length > 0) {
84
- ctx.current.marks = [...ctx.current.marks, ...marks];
85
- }
86
- iterateChildren(value.$value, (child) => {
87
- ctx.handle(child.tag, child.value);
88
- });
89
- ctx.closeNode(nodeType, attrs);
90
- },
91
- 'table-of-content': (ctx, value) => {
92
- ctx.openNode();
93
- for (const pElem of value['index-body']['p']) {
94
- ctx.openNode();
95
- ctx.handle('p', pElem);
96
- ctx.closeNode('list_item');
97
- }
98
- ctx.closeNode('bullet_list');
99
- },
100
- 'span': (ctx, value) => {
101
- const style = ctx.getElementStyle(value);
102
- const marks = ctx.styleToMarks(style);
103
- if (marks.length > 0) {
104
- ctx.stash();
105
- ctx.current.marks = [...ctx.current.marks, ...marks];
106
- }
107
- iterateChildren(value.$value, (child) => {
108
- ctx.handle(child.tag, child.value);
109
- });
110
- if (marks.length > 0) {
111
- ctx.unstash();
112
- }
113
- },
114
- 'a': (ctx, value) => {
115
- const attrs = {
116
- href: value['@href'],
117
- // title: tok.attrGet('title') || null,
118
- };
119
- const markType = ctx.schema.mark('link', attrs);
120
- const marks = [markType];
121
- if (marks.length > 0) {
122
- ctx.stash();
123
- ctx.current.marks = [...ctx.current.marks, ...marks];
124
- }
125
- iterateChildren(value.$value, (child) => {
126
- ctx.handle(child.tag, child.value);
127
- });
128
- if (marks.length > 0) {
129
- ctx.unstash();
130
- }
131
- },
132
- };
133
- }
@@ -1,3 +0,0 @@
1
- import { NodeHandler } from '../OdtParser.js';
2
- export declare function getListNodesHandlers(): Record<string, NodeHandler>;
3
- //# sourceMappingURL=list_node_handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list_node_handlers.d.ts","sourceRoot":"","sources":["../../src/node_handlers/list_node_handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EAGZ,MAAM,iBAAiB,CAAC;AAEzB,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CA0HlE"}
@@ -1,91 +0,0 @@
1
- import { ListNumbering } from '../lists.js';
2
- import { iterateChildren, resolveStyle, } from '../OdtParser.js';
3
- export function getListNodesHandlers() {
4
- return {
5
- 'list': (ctx, odtElement) => {
6
- const listTracker = ctx.listTracker;
7
- const list = {
8
- level: listTracker.listStack.length + 1,
9
- odtElement,
10
- };
11
- listTracker.listStack.push(list);
12
- let style = {};
13
- let listId = null;
14
- for (let i = listTracker.listStack.length - 1; i >= 0; i--) {
15
- const element = listTracker.listStack[i].odtElement;
16
- if (!listId) {
17
- if (element['@id']) {
18
- listId = element['@id'];
19
- }
20
- }
21
- if (!style['@style-name']) {
22
- style = ('object' === typeof element && element['@style-name'])
23
- ? resolveStyle(ctx.stylesTree, ctx.automaticStyles, element['@style-name'])
24
- : {};
25
- }
26
- }
27
- let nodeTypeName = 'bullet_list';
28
- const attrs = {};
29
- if (style) {
30
- const numLevelStyle = style['list-level-style-number'].find((levelStyle) => parseInt(levelStyle['@level']) === list.level);
31
- if (numLevelStyle) {
32
- attrs['type'] = numLevelStyle['@num-format'] || '1';
33
- nodeTypeName = 'ordered_list';
34
- }
35
- }
36
- ctx.current.meta['list_type'] = nodeTypeName;
37
- let listNumbering = null;
38
- if (listId && listTracker.listNumberings.has(listId)) {
39
- listNumbering = listTracker.listNumberings.get(listId);
40
- }
41
- let isContinue = false;
42
- if (odtElement['@continue-list'] &&
43
- listTracker.listNumberings.has(odtElement['@continue-list'])) {
44
- listNumbering = listTracker.listNumberings.get(odtElement['@continue-list']);
45
- isContinue = true;
46
- }
47
- if (odtElement['@continue-numbering']) {
48
- listNumbering = listTracker.lastNumbering;
49
- isContinue = true;
50
- }
51
- if (!listNumbering) {
52
- listNumbering = new ListNumbering();
53
- }
54
- if (isContinue) {
55
- listTracker.preserveMinLevel = 999;
56
- }
57
- if (listId) {
58
- listTracker.listNumberings.set(listId, listNumbering);
59
- }
60
- listTracker.lastNumbering = listNumbering;
61
- if (listTracker.preserveMinLevel <= list.level) {
62
- listNumbering.clearAbove(list.level - 1);
63
- }
64
- if (nodeTypeName === 'ordered_list') {
65
- attrs['start'] = listNumbering.levels[list.level] || 1;
66
- }
67
- ctx.openNode();
68
- const children = odtElement['list-item'].map((item) => ({
69
- 'list-item': item,
70
- }));
71
- if (children) {
72
- iterateChildren(children, (child) => {
73
- ctx.handle(child.tag, child.value);
74
- });
75
- listNumbering.levels[list.level] += children.length;
76
- }
77
- ctx.closeNode(nodeTypeName, attrs);
78
- if (listTracker.preserveMinLevel >= list.level) {
79
- listTracker.preserveMinLevel = list.level;
80
- }
81
- listTracker.listStack.pop();
82
- },
83
- 'list-item': (ctx, odtElement) => {
84
- ctx.openNode();
85
- iterateChildren(odtElement.$value, (child) => ctx.handle(child.tag, child.value));
86
- const attrs = {};
87
- attrs.markup = '* ';
88
- ctx.closeNode('list_item', attrs);
89
- },
90
- };
91
- }
@@ -1,3 +0,0 @@
1
- import { NodeHandler } from '../OdtParser.js';
2
- export declare function getTableNodesHandlers(): Record<string, NodeHandler>;
3
- //# sourceMappingURL=table_node_handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table_node_handlers.d.ts","sourceRoot":"","sources":["../../src/node_handlers/table_node_handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAEhF,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAyBnE"}
@@ -1,24 +0,0 @@
1
- import { iterateChildren } from '../OdtParser.js';
2
- export function getTableNodesHandlers() {
3
- return {
4
- 'table': (ctx, value) => {
5
- ctx.openNode();
6
- for (const item of value['table-row']) {
7
- ctx.handle('table-row', item);
8
- }
9
- ctx.closeNode('table');
10
- },
11
- 'table-row': (ctx, value) => {
12
- ctx.openNode();
13
- for (const item of value['table-cell']) {
14
- ctx.handle('table-cell', item);
15
- }
16
- ctx.closeNode('table_row');
17
- },
18
- 'table-cell': (ctx, value) => {
19
- ctx.openNode();
20
- iterateChildren(value.$value, (child) => ctx.handle(child.tag, child.value));
21
- ctx.closeNode('table_cell');
22
- },
23
- };
24
- }
package/esm/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,3 +0,0 @@
1
- import { Command } from 'prosemirror-state';
2
- export declare const convertCodeParagraphsToCodeBlocks: Command;
3
- //# sourceMappingURL=convertCodeParagraphsToCodeBlocks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertCodeParagraphsToCodeBlocks.d.ts","sourceRoot":"","sources":["../../src/postprocess/convertCodeParagraphsToCodeBlocks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAe,MAAM,mBAAmB,CAAC;AA8BzD,eAAO,MAAM,iCAAiC,EAAE,OAoF/C,CAAC"}
@@ -1,81 +0,0 @@
1
- function onlyHasCodeMarkedText(paragraph, codeMarkType) {
2
- if (paragraph.content.size === 0) {
3
- return paragraph.marks.some((mark) => mark.type.name === codeMarkType.name);
4
- }
5
- let allAreCodeMarked = true;
6
- paragraph.content.forEach((child) => {
7
- if (!child.isText ||
8
- !child.marks.some((mark) => mark.type.name === codeMarkType.name)) {
9
- allAreCodeMarked = false;
10
- }
11
- });
12
- return allAreCodeMarked;
13
- }
14
- export const convertCodeParagraphsToCodeBlocks = (state, dispatch) => {
15
- const doc = state.doc;
16
- const schema = state.schema;
17
- let tr = state.tr;
18
- let paragraphsToMerge = null;
19
- function flushCodeBlock() {
20
- if (paragraphsToMerge === null) {
21
- return;
22
- }
23
- const textNode = schema.text(paragraphsToMerge.innerText);
24
- const codeBlock = schema.nodes.code_block.createAndFill(null, [textNode]);
25
- const startPos = tr.mapping.map(paragraphsToMerge.startPos);
26
- const endPos = tr.mapping.map(paragraphsToMerge.endPos);
27
- if (codeBlock) {
28
- tr.replaceRangeWith(startPos, endPos, codeBlock);
29
- }
30
- paragraphsToMerge = null;
31
- }
32
- function nodesToText(fragment) {
33
- if (fragment.content.length === 0) {
34
- return '';
35
- }
36
- let retVal = '';
37
- fragment.content.forEach((node) => {
38
- if (node.isText) {
39
- retVal += node.text;
40
- }
41
- else {
42
- retVal = '@TODO: node.type ' + node.type;
43
- }
44
- });
45
- return retVal;
46
- }
47
- doc.forEach((node, pos) => {
48
- if (node.type.name === 'paragraph') {
49
- const isCodeOnly = onlyHasCodeMarkedText(node, schema.marks.code);
50
- const isEmpty = node.content.size === 0;
51
- if (isCodeOnly) {
52
- if (paragraphsToMerge === null) {
53
- paragraphsToMerge = {
54
- startPos: pos,
55
- endPos: pos + node.nodeSize,
56
- innerText: nodesToText(node.content),
57
- };
58
- }
59
- else {
60
- paragraphsToMerge = {
61
- startPos: paragraphsToMerge.startPos,
62
- endPos: pos + node.nodeSize,
63
- innerText: paragraphsToMerge.innerText + '\n' +
64
- nodesToText(node.content),
65
- };
66
- }
67
- return;
68
- }
69
- }
70
- if (paragraphsToMerge !== null) {
71
- flushCodeBlock();
72
- }
73
- });
74
- if (paragraphsToMerge !== null) {
75
- flushCodeBlock();
76
- }
77
- if (dispatch) {
78
- dispatch(tr);
79
- }
80
- return tr.steps.length > 0;
81
- };
@@ -1,3 +0,0 @@
1
- import { Command } from 'prosemirror-state';
2
- export declare const convertMathMl: Command;
3
- //# sourceMappingURL=convertMathMl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertMathMl.d.ts","sourceRoot":"","sources":["../../src/postprocess/convertMathMl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI5C,eAAO,MAAM,aAAa,EAAE,OAiD3B,CAAC"}
@@ -1,35 +0,0 @@
1
- // Related tests:
2
- // test ./example-document.md
3
- export const convertMathMl = (state, dispatch) => {
4
- const doc = state.doc;
5
- const schema = state.schema;
6
- const mathType = schema.nodes.math;
7
- const codeBlockType = schema.nodes.code_block;
8
- if (!mathType || !codeBlockType) {
9
- return false;
10
- }
11
- let modified = false;
12
- const tr = state.tr;
13
- doc.forEach((parentNode, offset, index) => {
14
- if (parentNode.childCount !== 1) {
15
- return;
16
- }
17
- const parentPos = offset;
18
- const node = parentNode.child(0);
19
- if (node.type !== mathType)
20
- return;
21
- if (node.attrs.content.length === 0)
22
- return;
23
- const codeBlock = codeBlockType.create({
24
- lang: node.attrs.lang,
25
- }, schema.text(node.attrs.content));
26
- tr.replaceWith(tr.mapping.map(parentPos), tr.mapping.map(parentPos + parentNode.nodeSize), codeBlock);
27
- modified = true;
28
- });
29
- if (!modified)
30
- return false;
31
- if (dispatch) {
32
- dispatch(tr);
33
- }
34
- return true;
35
- };
@@ -1,3 +0,0 @@
1
- import { Command } from 'prosemirror-state';
2
- export declare const fixContinuedLists: Command;
3
- //# sourceMappingURL=fixContinuedLists.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fixContinuedLists.d.ts","sourceRoot":"","sources":["../../src/postprocess/fixContinuedLists.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AA4D5C,eAAO,MAAM,iBAAiB,EAAE,OAmD/B,CAAC"}
@@ -1,80 +0,0 @@
1
- import { Fragment, Slice } from 'prosemirror-model';
2
- const ANY_LIST = ['ordered_list', 'bullet_list'];
3
- function getListEndingMaxDepth(list) {
4
- if (!list) {
5
- return 0;
6
- }
7
- if (ANY_LIST.indexOf(list.type.name) === -1) {
8
- return 0;
9
- }
10
- if (list.lastChild?.type.name === 'list_item') {
11
- return 1 + getListEndingMaxDepth(list.lastChild?.lastChild);
12
- }
13
- return 0;
14
- }
15
- function convertToStitchingLevels(list, array = []) {
16
- if (ANY_LIST.indexOf(list.type.name) === -1) {
17
- throw new Error(`Incorrect list type: ${list.type.name}`);
18
- }
19
- if (!list?.firstChild) {
20
- return array;
21
- }
22
- const firstChildParagraph = list.firstChild.firstChild;
23
- if (firstChildParagraph?.content.size === 0) {
24
- if (list?.firstChild.children.length < 2) {
25
- array.push(new Slice(Fragment.from([]), 0, 0));
26
- // array.push(list.slice(list.firstChild.nodeSize, list.firstChild.nodeSize)) // empty slice
27
- return array;
28
- }
29
- const subList = list?.firstChild.child(1);
30
- array.push(list.slice(list.firstChild.nodeSize, list.content.size));
31
- if (ANY_LIST.indexOf(subList?.type.name) > -1) {
32
- convertToStitchingLevels(subList, array);
33
- }
34
- }
35
- else {
36
- array.push(list.slice(0, list.content.size));
37
- }
38
- return array;
39
- }
40
- export const fixContinuedLists = (state, dispatch) => {
41
- const doc = state.doc;
42
- let tr = state.tr;
43
- let previousList = null;
44
- // console.debug(nodeToTreeString(doc));
45
- doc.forEach((child, childPos) => {
46
- if (child.type.name === 'ordered_list') {
47
- const start = childPos;
48
- const end = start + child.nodeSize;
49
- if (previousList) {
50
- const stitchingLevels = convertToStitchingLevels(child);
51
- if (stitchingLevels.length <= previousList.stitchingDepth) {
52
- const betweenStart = previousList.end;
53
- const betweenNodes = doc.slice(betweenStart, start);
54
- tr = tr.delete(tr.mapping.map(betweenStart), tr.mapping.map(end));
55
- let posToInsert = tr.mapping.map(previousList.end);
56
- for (const level of stitchingLevels) {
57
- posToInsert -= 1; // Before /OL token
58
- tr = tr.replace(posToInsert, posToInsert, level);
59
- posToInsert -= 1; // Before /LI token
60
- }
61
- if (betweenNodes.size > 0) {
62
- tr = tr.replace(posToInsert, posToInsert, betweenNodes);
63
- }
64
- previousList.stitchingDepth = getListEndingMaxDepth(child);
65
- previousList.end = end;
66
- return;
67
- }
68
- }
69
- previousList = {
70
- stitchingDepth: getListEndingMaxDepth(child),
71
- start,
72
- end,
73
- };
74
- }
75
- });
76
- if (dispatch) {
77
- dispatch(tr);
78
- }
79
- return tr.steps.length > 0;
80
- };
@@ -1,8 +0,0 @@
1
- import type { Node } from 'prosemirror-model';
2
- import { Command } from 'prosemirror-state';
3
- export interface PostProcessConfig {
4
- doc: Node;
5
- filesMap: Record<string, Uint8Array>;
6
- }
7
- export declare function getDefaultsPostProcessFilters({ doc, filesMap }: PostProcessConfig): Array<Command>;
8
- //# sourceMappingURL=postProcess.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postProcess.d.ts","sourceRoot":"","sources":["../../src/postprocess/postProcess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAO5C,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,IAAI,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACtC;AAED,wBAAgB,6BAA6B,CAC3C,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GACnC,KAAK,CAAC,OAAO,CAAC,CAOhB"}
@@ -1,12 +0,0 @@
1
- import { convertCodeParagraphsToCodeBlocks } from './convertCodeParagraphsToCodeBlocks.js';
2
- import { removeUnusedBookmarks } from './removeUnusedBookmarks.js';
3
- import { fixContinuedLists } from './fixContinuedLists.js';
4
- import { convertMathMl } from './convertMathMl.js';
5
- export function getDefaultsPostProcessFilters({ doc, filesMap }) {
6
- return [
7
- convertCodeParagraphsToCodeBlocks,
8
- removeUnusedBookmarks,
9
- fixContinuedLists,
10
- convertMathMl,
11
- ];
12
- }
@@ -1,3 +0,0 @@
1
- import { Command } from 'prosemirror-state';
2
- export declare const removeUnusedBookmarks: Command;
3
- //# sourceMappingURL=removeUnusedBookmarks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"removeUnusedBookmarks.d.ts","sourceRoot":"","sources":["../../src/postprocess/removeUnusedBookmarks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,qBAAqB,EAAE,OAgCnC,CAAC"}
@@ -1,27 +0,0 @@
1
- export const removeUnusedBookmarks = (state, dispatch) => {
2
- return false;
3
- function condition(mark) {
4
- console.log('rrrr', mark.type.name);
5
- return mark.type.name === 'bookmark';
6
- }
7
- if (node.marks) {
8
- // For text nodes, filter out the marks that match the condition
9
- const newMarks = node.marks.filter((mark) => !condition(mark));
10
- // If marks were removed, return a new text node with the remaining marks
11
- if (newMarks.length !== node.marks.length) {
12
- return node.mark(newMarks);
13
- }
14
- // Otherwise, return the original text node
15
- return node;
16
- }
17
- // if (Array.isArray(node.content)) {
18
- // const content: Node[] = node.content.content.map(childNode => removeUnusedBookmarks(childNode));
19
- // return node.copy(content);
20
- // } else {
21
- // console.log('node.content', node.content);
22
- // }
23
- if (dispatch) {
24
- dispatch(tr);
25
- }
26
- return tr.steps.length > 0;
27
- };