oasis-editor 0.0.101 → 0.0.102
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/{OasisEditorApp-B421ezvO.js → OasisEditorApp-DDtlPHus.js} +46 -16
- package/dist/assets/{importDocxWorker-DkjxuxwM.js → importDocxWorker-GkXQ7kFj.js} +1 -1
- package/dist/core/model/index.d.ts +1 -1
- package/dist/core/model/types/document.d.ts +27 -0
- package/dist/export/docx/docxPackageXml.d.ts +9 -3
- package/dist/import/docx/fontTable.d.ts +13 -0
- package/dist/{index-BPpHyg6q.js → index-CNtAFUVS.js} +70 -10
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +2 -2
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ export type { EditorFootnote } from './types/documentFootnotes.js';
|
|
|
15
15
|
export type { EditorEndnote } from './types/documentEndnotes.js';
|
|
16
16
|
export type { EditorBookmark, EditorBookmarkAnchor, EditorBookmarks, } from './types/documentBookmarks.js';
|
|
17
17
|
export type { EditorComment, EditorCommentAnchor, EditorComments, } from './types/documentComments.js';
|
|
18
|
-
export type { EditorPageMargins, EditorPageSettings, EditorColumnsSettings, EditorSection, EditorFootnoteSettings, EditorFootnotes, EditorEndnoteSettings, EditorEndnotes, EditorDocument, } from './types/document.js';
|
|
18
|
+
export type { EditorPageMargins, EditorPageSettings, EditorColumnsSettings, EditorSection, EditorFontInfo, EditorFootnoteSettings, EditorFootnotes, EditorEndnoteSettings, EditorEndnotes, EditorDocument, } from './types/document.js';
|
|
19
19
|
export type { EditorPosition, EditorSelection, EditorEditingZone, } from './types/selection.js';
|
|
20
20
|
export type { EditorCaretSlot, EditorLayoutFragmentChar, EditorLayoutFragment, EditorLayoutLine, EditorLayoutParagraph, EditorLayoutBlock, TableCellBlockPosition, EditorLayoutPage, EditorLayoutDocument, } from './types/layout.js';
|
|
21
21
|
export type { EditorState } from './editorState.js';
|
|
@@ -53,6 +53,28 @@ export interface EditorSection {
|
|
|
53
53
|
evenPageFooter?: EditorBlockNode[];
|
|
54
54
|
breakType?: "nextPage" | "continuous";
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* One `w:font` entry from `word/fontTable.xml`: the document's declaration of a
|
|
58
|
+
* font it uses, with substitution metadata. Preserved for round-trip (and as the
|
|
59
|
+
* basis for future font-substitution decisions). Embedded font references
|
|
60
|
+
* (`w:embedRegular`/etc.) are intentionally not modeled.
|
|
61
|
+
*/
|
|
62
|
+
export interface EditorFontInfo {
|
|
63
|
+
/** `w:font/@w:name`: the font's primary name (e.g. "Calibri"). */
|
|
64
|
+
name: string;
|
|
65
|
+
/** `w:altName/@w:val`: fallback font name when `name` is unavailable. */
|
|
66
|
+
altName?: string;
|
|
67
|
+
/** `w:family/@w:val`: roman | swiss | modern | script | decorative | auto. */
|
|
68
|
+
family?: string;
|
|
69
|
+
/** `w:pitch/@w:val`: fixed | variable | default. */
|
|
70
|
+
pitch?: string;
|
|
71
|
+
/** `w:charset/@w:val`: character set (hex). */
|
|
72
|
+
charset?: string;
|
|
73
|
+
/** `w:panose1/@w:val`: PANOSE classification (10-byte hex). */
|
|
74
|
+
panose1?: string;
|
|
75
|
+
/** `w:sig` attributes (Unicode/codepage signature bits) preserved verbatim. */
|
|
76
|
+
sig?: Record<string, string>;
|
|
77
|
+
}
|
|
56
78
|
export interface EditorFootnoteSettings {
|
|
57
79
|
numberFormat?: EditorFootnoteNumberFormat;
|
|
58
80
|
restart?: EditorFootnoteRestart;
|
|
@@ -116,6 +138,11 @@ export interface EditorDocument {
|
|
|
116
138
|
* body shown in a hover/click popup.
|
|
117
139
|
*/
|
|
118
140
|
comments?: EditorComments;
|
|
141
|
+
/**
|
|
142
|
+
* `word/fontTable.xml` entries: the fonts the document declares, with
|
|
143
|
+
* substitution metadata. Preserved on import and re-emitted on export.
|
|
144
|
+
*/
|
|
145
|
+
fontTable?: EditorFontInfo[];
|
|
119
146
|
metadata?: {
|
|
120
147
|
title?: string;
|
|
121
148
|
[key: string]: unknown;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { EditorFootnoteSettings } from '../../core/model.js';
|
|
1
|
+
import { EditorFontInfo, EditorFootnoteSettings } from '../../core/model.js';
|
|
2
2
|
import { DocContext, PartDefinition } from './docxTypes.js';
|
|
3
3
|
|
|
4
|
-
export declare function buildContentTypesXml(hasNumbering: boolean, imageExtensions: Iterable<string>, hasSettings: boolean, parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean): string;
|
|
4
|
+
export declare function buildContentTypesXml(hasNumbering: boolean, imageExtensions: Iterable<string>, hasSettings: boolean, parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean, hasFontTable: boolean): string;
|
|
5
5
|
export declare function buildRootRelationshipsXml(): string;
|
|
6
|
-
export declare function buildDocumentRelationshipsXml(hasNumbering: boolean, hasSettings: boolean, images: DocContext["images"], hyperlinks: DocContext["hyperlinks"], parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean): string;
|
|
6
|
+
export declare function buildDocumentRelationshipsXml(hasNumbering: boolean, hasSettings: boolean, images: DocContext["images"], hyperlinks: DocContext["hyperlinks"], parts: PartDefinition[], hasFootnotes: boolean, hasEndnotes: boolean, hasStyles: boolean, hasComments: boolean, hasFontTable: boolean): string;
|
|
7
|
+
/**
|
|
8
|
+
* Serialize the document's font declarations to `word/fontTable.xml`. Mirrors the
|
|
9
|
+
* structured {@link EditorFontInfo} back to `<w:font>` entries (substitution
|
|
10
|
+
* metadata only; embedded font references are not emitted).
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildFontTableXml(fonts: EditorFontInfo[]): string;
|
|
7
13
|
export interface HyphenationSettingsXml {
|
|
8
14
|
autoHyphenation?: boolean;
|
|
9
15
|
consecutiveHyphenLimit?: number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EditorFontInfo } from '../../core/model.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parse `word/fontTable.xml` into the document's font declarations. Each
|
|
5
|
+
* `<w:font w:name="…">` carries substitution metadata (alternative name, family,
|
|
6
|
+
* pitch, charset, PANOSE, and the Unicode/codepage signature). Embedded font
|
|
7
|
+
* references (`w:embedRegular`/etc., which point at obfuscated `.odttf` parts)
|
|
8
|
+
* are intentionally not read.
|
|
9
|
+
*
|
|
10
|
+
* Returns `undefined` when there is no usable font table so the document field
|
|
11
|
+
* stays absent (and export skips the part).
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseFontTable(xml: string | null): EditorFontInfo[] | undefined;
|
|
@@ -2519,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
|
|
|
2519
2519
|
onCleanup(() => {
|
|
2520
2520
|
cancelled = true;
|
|
2521
2521
|
});
|
|
2522
|
-
import("./OasisEditorApp-
|
|
2522
|
+
import("./OasisEditorApp-DDtlPHus.js").then((m) => {
|
|
2523
2523
|
cancelled = true;
|
|
2524
2524
|
setProgress(1);
|
|
2525
2525
|
setTimeout(() => setApp(() => m.OasisEditorApp), 180);
|
|
@@ -34870,6 +34870,60 @@ function parseImportedStyles(stylesXml, theme) {
|
|
|
34870
34870
|
}
|
|
34871
34871
|
return emptyOrUndefined(styles);
|
|
34872
34872
|
}
|
|
34873
|
+
function parseFontTable(xml) {
|
|
34874
|
+
if (!xml) {
|
|
34875
|
+
return void 0;
|
|
34876
|
+
}
|
|
34877
|
+
const root = new DOMParser$1().parseFromString(xml, "application/xml");
|
|
34878
|
+
const fontsEl = root.getElementsByTagNameNS(WORD_NS, "fonts")[0];
|
|
34879
|
+
if (!fontsEl) {
|
|
34880
|
+
return void 0;
|
|
34881
|
+
}
|
|
34882
|
+
const fonts = [];
|
|
34883
|
+
for (const fontEl of getChildrenByTagNameNS(fontsEl, WORD_NS, "font")) {
|
|
34884
|
+
const name = getAttributeValue(fontEl, "name");
|
|
34885
|
+
if (!name) {
|
|
34886
|
+
continue;
|
|
34887
|
+
}
|
|
34888
|
+
const info = { name };
|
|
34889
|
+
const altName = getAttributeValue(
|
|
34890
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "altName"),
|
|
34891
|
+
"val"
|
|
34892
|
+
);
|
|
34893
|
+
if (altName) info.altName = altName;
|
|
34894
|
+
const family = getAttributeValue(
|
|
34895
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "family"),
|
|
34896
|
+
"val"
|
|
34897
|
+
);
|
|
34898
|
+
if (family) info.family = family;
|
|
34899
|
+
const pitch = getAttributeValue(
|
|
34900
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "pitch"),
|
|
34901
|
+
"val"
|
|
34902
|
+
);
|
|
34903
|
+
if (pitch) info.pitch = pitch;
|
|
34904
|
+
const charset = getAttributeValue(
|
|
34905
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "charset"),
|
|
34906
|
+
"val"
|
|
34907
|
+
);
|
|
34908
|
+
if (charset) info.charset = charset;
|
|
34909
|
+
const panose1 = getAttributeValue(
|
|
34910
|
+
getFirstChildByTagNameNS(fontEl, WORD_NS, "panose1"),
|
|
34911
|
+
"val"
|
|
34912
|
+
);
|
|
34913
|
+
if (panose1) info.panose1 = panose1;
|
|
34914
|
+
const sigEl = getFirstChildByTagNameNS(fontEl, WORD_NS, "sig");
|
|
34915
|
+
if (sigEl) {
|
|
34916
|
+
const sig = {};
|
|
34917
|
+
for (let i = 0; i < sigEl.attributes.length; i += 1) {
|
|
34918
|
+
const attr = sigEl.attributes[i];
|
|
34919
|
+
sig[attr.localName ?? attr.name] = attr.value;
|
|
34920
|
+
}
|
|
34921
|
+
if (Object.keys(sig).length > 0) info.sig = sig;
|
|
34922
|
+
}
|
|
34923
|
+
fonts.push(info);
|
|
34924
|
+
}
|
|
34925
|
+
return fonts.length > 0 ? fonts : void 0;
|
|
34926
|
+
}
|
|
34873
34927
|
function isXmlTrue(value) {
|
|
34874
34928
|
return value === "1" || value === "true" || value === "on";
|
|
34875
34929
|
}
|
|
@@ -37059,7 +37113,7 @@ function parseCommentsXml(commentsXml, commentsExtendedXml) {
|
|
|
37059
37113
|
return byDocxId;
|
|
37060
37114
|
}
|
|
37061
37115
|
async function importDocxToEditorDocument(buffer, options = {}) {
|
|
37062
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
37116
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
37063
37117
|
(_a = options.onProgress) == null ? void 0 : _a.call(options, "opening-docx");
|
|
37064
37118
|
const zip = await JSZip.loadAsync(buffer);
|
|
37065
37119
|
const documentXml = await ((_b = zip.file("word/document.xml")) == null ? void 0 : _b.async("string"));
|
|
@@ -37073,10 +37127,13 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37073
37127
|
const settingsXml = await ((_e = zip.file("word/settings.xml")) == null ? void 0 : _e.async("string")) ?? null;
|
|
37074
37128
|
const docSettings = parseSettings(settingsXml);
|
|
37075
37129
|
const stylesXml = await ((_f = zip.file("word/styles.xml")) == null ? void 0 : _f.async("string")) ?? null;
|
|
37076
|
-
const
|
|
37130
|
+
const fontTable = parseFontTable(
|
|
37131
|
+
await ((_g = zip.file("word/fontTable.xml")) == null ? void 0 : _g.async("string")) ?? null
|
|
37132
|
+
);
|
|
37133
|
+
const themeXml = await ((_h = zip.file("word/theme/theme1.xml")) == null ? void 0 : _h.async("string")) ?? null;
|
|
37077
37134
|
const theme = parseDocxTheme(themeXml);
|
|
37078
37135
|
const importedStyles = parseImportedStyles(stylesXml, theme);
|
|
37079
|
-
(
|
|
37136
|
+
(_i = options.onProgress) == null ? void 0 : _i.call(options, "parsing-document");
|
|
37080
37137
|
const document2 = new DOMParser$1().parseFromString(
|
|
37081
37138
|
documentXml,
|
|
37082
37139
|
"application/xml"
|
|
@@ -37208,7 +37265,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37208
37265
|
}
|
|
37209
37266
|
);
|
|
37210
37267
|
}
|
|
37211
|
-
(
|
|
37268
|
+
(_j = options.onProgress) == null ? void 0 : _j.call(options, "parsing-headers-footers");
|
|
37212
37269
|
const sections = [];
|
|
37213
37270
|
const hasHeaderFooterReferences = (props) => Object.keys(props.headerRIds).length > 0 || Object.keys(props.footerRIds).length > 0;
|
|
37214
37271
|
const totalSectionsWithHeaders = sectionProps.filter(
|
|
@@ -37307,7 +37364,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37307
37364
|
evenPageFooter: evenPageFooter.length > 0 ? evenPageFooter : void 0
|
|
37308
37365
|
});
|
|
37309
37366
|
}
|
|
37310
|
-
const footnotesXml = await ((
|
|
37367
|
+
const footnotesXml = await ((_k = zip.file("word/footnotes.xml")) == null ? void 0 : _k.async("string")) ?? null;
|
|
37311
37368
|
const footnotesPartRels = footnotesXml ? await loadPartRelationships(zip, "word/footnotes.xml") : /* @__PURE__ */ new Map();
|
|
37312
37369
|
const parsedFootnotes = await parseFootnotesXml(
|
|
37313
37370
|
footnotesXml,
|
|
@@ -37322,7 +37379,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37322
37379
|
}
|
|
37323
37380
|
const editorFootnotes = Object.keys(parsedFootnotes.footnotes.items).length > 0 || parsedFootnotes.footnotes.separator || parsedFootnotes.footnotes.continuationSeparator || parsedFootnotes.footnotes.settings ? parsedFootnotes.footnotes : void 0;
|
|
37324
37381
|
remapImportedFootnoteRefsInSections(sections, parsedFootnotes.byDocxId);
|
|
37325
|
-
const endnotesXml = await ((
|
|
37382
|
+
const endnotesXml = await ((_l = zip.file("word/endnotes.xml")) == null ? void 0 : _l.async("string")) ?? null;
|
|
37326
37383
|
const endnotesPartRels = endnotesXml ? await loadPartRelationships(zip, "word/endnotes.xml") : /* @__PURE__ */ new Map();
|
|
37327
37384
|
const parsedEndnotes = await parseEndnotesXml(
|
|
37328
37385
|
endnotesXml,
|
|
@@ -37339,8 +37396,8 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37339
37396
|
remapImportedEndnoteRefsInSections(sections, parsedEndnotes.byDocxId);
|
|
37340
37397
|
const editorBookmarks = extractBookmarksFromSections(sections);
|
|
37341
37398
|
const commentRanges = extractCommentRangesFromSections(sections);
|
|
37342
|
-
const commentsXml = await ((
|
|
37343
|
-
const commentsExtendedXml = await ((
|
|
37399
|
+
const commentsXml = await ((_m = zip.file("word/comments.xml")) == null ? void 0 : _m.async("string")) ?? null;
|
|
37400
|
+
const commentsExtendedXml = await ((_n = zip.file("word/commentsExtended.xml")) == null ? void 0 : _n.async("string")) ?? null;
|
|
37344
37401
|
const commentBodies = parseCommentsXml(commentsXml, commentsExtendedXml);
|
|
37345
37402
|
const editorComments = buildEditorComments(commentRanges, commentBodies);
|
|
37346
37403
|
const shouldPreserveSections = sections.length > 1 || sections.some(
|
|
@@ -37387,6 +37444,9 @@ async function importDocxToEditorDocument(buffer, options = {}) {
|
|
|
37387
37444
|
hyphenationZone: docSettings.hyphenationZone
|
|
37388
37445
|
};
|
|
37389
37446
|
}
|
|
37447
|
+
if (fontTable) {
|
|
37448
|
+
doc2.fontTable = fontTable;
|
|
37449
|
+
}
|
|
37390
37450
|
let result = doc2;
|
|
37391
37451
|
if (editorFootnotes) {
|
|
37392
37452
|
result.footnotes = editorFootnotes;
|
|
@@ -37574,7 +37634,7 @@ function importDocxInWorker(buffer, options = {}) {
|
|
|
37574
37634
|
const worker = new Worker(
|
|
37575
37635
|
new URL(
|
|
37576
37636
|
/* @vite-ignore */
|
|
37577
|
-
"" + new URL("assets/importDocxWorker-
|
|
37637
|
+
"" + new URL("assets/importDocxWorker-GkXQ7kFj.js", import.meta.url).href,
|
|
37578
37638
|
import.meta.url
|
|
37579
37639
|
),
|
|
37580
37640
|
{
|
package/dist/oasis-editor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O, c8, c9, ca, cb, cc, a8, cd, Q, bT, ce, cf, cg, N, ch, bR, ci, cj, ck, cl, cm, c3, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, ad, cz, c2, cA, ca as ca2, cf as cf2, ch as ch2, cq as cq2, cs as cs2, cx as cx2, cB, bV, bQ, cC, cD, cE, bS, cF, cG, bU } from "./index-
|
|
1
|
+
import { O, c8, c9, ca, cb, cc, a8, cd, Q, bT, ce, cf, cg, N, ch, bR, ci, cj, ck, cl, cm, c3, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, ad, cz, c2, cA, ca as ca2, cf as cf2, ch as ch2, cq as cq2, cs as cs2, cx as cx2, cB, bV, bQ, cC, cD, cE, bS, cF, cG, bU } from "./index-CNtAFUVS.js";
|
|
2
2
|
export {
|
|
3
3
|
O as BalloonShell,
|
|
4
4
|
c8 as Button,
|