oasis-editor 0.0.30 → 0.0.32

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 (34) hide show
  1. package/dist/{OasisEditorApp-Bvkbr1KZ.js → OasisEditorApp-D6NxTc6l.js} +603 -307
  2. package/dist/app/services/indexedDbPersistence.d.ts +20 -0
  3. package/dist/assets/{importDocxWorker-DVvaVtgj.js → importDocxWorker-xRrspiYv.js} +1 -1
  4. package/dist/core/editorState.d.ts +7 -1
  5. package/dist/core/endnotes.d.ts +0 -2
  6. package/dist/core/footnotes.d.ts +0 -2
  7. package/dist/core/model/index.d.ts +1 -0
  8. package/dist/core/model/listNumbering.d.ts +5 -0
  9. package/dist/core/model/types/primitives.d.ts +10 -0
  10. package/dist/export/docx/docxTypes.d.ts +10 -3
  11. package/dist/export/pdf/draw/drawBlockList.d.ts +1 -1
  12. package/dist/export/pdf/draw/drawParagraph.d.ts +1 -1
  13. package/dist/export/pdf/draw/drawTable.d.ts +1 -1
  14. package/dist/export/pdf/draw/lists.d.ts +2 -2
  15. package/dist/i18n/I18nContext.d.ts +9 -0
  16. package/dist/i18n/index.d.ts +7 -3
  17. package/dist/import/docx/numbering.d.ts +19 -28
  18. package/dist/{index-BVAzjJsg.js → index-CDi9hs5T.js} +1264 -1540
  19. package/dist/index.d.ts +1 -1
  20. package/dist/oasis-editor.js +54 -54
  21. package/dist/oasis-editor.umd.cjs +4 -4
  22. package/dist/ui/OasisEditorAppProps.d.ts +6 -0
  23. package/dist/ui/app/useEditorContextMenuClipboard.d.ts +2 -0
  24. package/dist/ui/app/useEditorRuntimeBootstrap.d.ts +1 -0
  25. package/dist/ui/app/useEditorRuntimePlugins.d.ts +2 -0
  26. package/dist/ui/canvas/listNumbering.d.ts +2 -1
  27. package/dist/ui/components/Menubar/Menubar.d.ts +1 -1
  28. package/dist/ui/components/Menubar/menuRegistry.d.ts +0 -1
  29. package/dist/ui/components/Toolbar/presets/defaultToolbar.d.ts +2 -1
  30. package/dist/ui/components/Toolbar/ribbon/ribbonModel.d.ts +4 -3
  31. package/dist/ui/components/Toolbar/state/createToolbarApi.d.ts +2 -1
  32. package/dist/ui/textMeasurement/indentation.d.ts +2 -0
  33. package/package.json +1 -1
  34. package/dist/app/services/PersistenceService.d.ts +0 -11
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { n as normalizeSelection, g as getParagraphs, c as createEditorParagraphFromRuns, a as getParagraphLength, b as createEditorRun, d as getDocumentSections, e as createEditorStyledRun, f as getParagraphText, h as getActiveZone, i as getActiveSectionIndex, p as positionToParagraphOffset, j as paragraphOffsetToPosition, k as clampPosition, l as findParagraphIndex, m as createCollapsedSelection, o as isSelectionCollapsed, q as createEditorParagraph, r as getBlockParagraphs, s as findParagraphTableLocation, t as buildTableCellLayout, u as createEditorTableCell, v as createEditorTable, w as createEditorTableRow, x as underlineStyleToCssDecorationStyle, y as resolveImageSrc, z as createEditorFootnote, A as createFootnoteReferenceRun, B as renumberFootnotes, C as iterateFootnoteReferenceRuns, D as getFootnoteDisplayMarker, E as createSignal, F as createEffect, G as onCleanup, H as buildCanvasLayoutSnapshot, I as on, J as onMount, K as debounce, L as unwrap, M as getDocumentParagraphs, N as getDocumentSectionsCanonical, O as createEditorDocument, P as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveTextBoxRenderHeight, U as resolveEffectiveParagraphStyle, V as resolveEffectiveTextStyleForParagraph, W as iterateEndnoteReferenceRuns, X as JSZip, Y as imageContentTypeDefaults, Z as imageExtensionFromMime, _ as pxToPt$1, $ as buildSegmentTable, a0 as buildCanvasTableLayout, a1 as resolveFloatingObjectRect, a2 as getTextBoxFloatingGeometry, a3 as getPresetPathSegments, a4 as projectBlocksLayout, a5 as textStyleToFontSizePt, a6 as PX_PER_POINT, a7 as DEFAULT_FONT_SIZE_PX, a8 as isDoubleUnderlineStyle, a9 as isWavyUnderlineStyle, aa as underlineStyleLineWidthPx, ab as underlineStyleDashArray, ac as getListLabelInset, ad as getParagraphBorderInsets, ae as normalizeFamily, af as ROBOTO_FONT_FILES, ag as loadFontAsset, ah as OFFICE_COMPAT_FONT_FAMILIES, ai as buildSfnt, aj as defaultFontDecoderRegistry, ak as SfntFontProgram, al as collectPdfFontFamilies, am as projectDocumentLayout, an as getPageHeaderZoneTop, ao as getPageBodyTop, ap as getPageColumnRects, aq as findFootnoteReference, ar as FOOTNOTE_MARKER_GUTTER_PX, as as resolveImporterForFile, at as createEditorStateFromDocument, au as getDocumentParagraphsCanonical, av as getToolbarStyleState, aw as STANDARD_FONT_SIZES_PT, ax as fontSizePxToPt, ay as probeLocalFontFamilies, az as createInitialEditorState, aA as parseFontSizePtToPx, aB as formatFontSizePt, aC as listKindForTag, aD as isParagraphTag, aE as collectInlineRuns, aF as parseParagraphStyle, aG as t, aH as getHeadingLevel, aI as preciseFontModeVersion, aJ as isPreciseFontModeEnabled, aK as togglePreciseFontMode, aL as nextFontSizePt, aM as previousFontSizePt, aN as fontSizePtToPx, aO as createDefaultToolbarPreset, aP as defaultMenuItems, aQ as MenuRegistry, aR as createToolbarRegistry, aS as Editor, aT as resolveCommandRef, aU as commandRefName, aV as InlineShell, aW as BalloonShell, aX as DocumentShell, aY as createMemo, aZ as getCaretRectFromSnapshot, a_ as getParagraphRectFromSnapshot, a$ as createComponent, b0 as CaretOverlay, b1 as Show, b2 as createRenderEffect, b3 as style, b4 as setAttribute, b5 as setStyleProperty, b6 as memo, b7 as template, b8 as insert, b9 as use, ba as addEventListener, bb as Dialog, bc as delegateEvents, bd as className, be as For, bf as UNDERLINE_STYLE_OPTIONS, bg as Tabs, bh as measureParagraphMinContentWidthPx, bi as getEditableBlocksForZone, bj as findParagraphLocation, bk as createSectionBoundaryParagraph, bl as normalizePageSettings, bm as DEFAULT_EDITOR_PAGE_SETTINGS, bn as markStart, bo as markEnd, bp as getParagraphEntries, bq as getParagraphById, br as PluginUiHost, bs as OasisEditorEditor, bt as perfTimer, bu as OasisBrandMark, bv as setPreciseFontPreference, bw as setWelcomeSeen, bx as enablePreciseFontMode, by as createOasisEditorClient, bz as setLocale, bA as createEditorZoom, bB as startLongTaskObserver, bC as installGlobalReport, bD as applyStoredPreciseFontPreference, bE as getWelcomeSeen, bF as isLocalFontAccessSupported, bG as EDITOR_SCROLL_PADDING_PX, bH as Toolbar, bI as OasisEditorLoading, bJ as createEditorLogger, bK as getCachedCanvasImage, bL as registerDomStatsSurface } from "./index-BVAzjJsg.js";
4
+ import { n as normalizeSelection, g as getParagraphs, c as createEditorParagraphFromRuns, a as getParagraphLength, b as createEditorRun, d as getDocumentSections, e as createEditorStyledRun, f as getParagraphText, h as getActiveZone, i as getActiveSectionIndex, p as positionToParagraphOffset, j as paragraphOffsetToPosition, k as clampPosition, l as findParagraphIndex, m as createCollapsedSelection, o as isSelectionCollapsed, q as createEditorParagraph, r as getBlockParagraphs, s as findParagraphTableLocation, t as buildTableCellLayout, u as createEditorTableCell, v as createEditorTableRow, w as createEditorTable, x as underlineStyleToCssDecorationStyle, y as resolveImageSrc, z as createEditorFootnote, A as createFootnoteReferenceRun, B as renumberFootnotes, C as iterateFootnoteReferenceRuns, D as getFootnoteDisplayMarker, E as createSignal, F as createEffect, G as onCleanup, H as buildCanvasLayoutSnapshot, I as on, J as onMount, K as debounce, L as unwrap, M as getDocumentParagraphs, N as getDocumentSectionsCanonical, O as createEditorDocument, P as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveTextBoxRenderHeight, U as resolveEffectiveParagraphStyle, V as resolveEffectiveTextStyleForParagraph, W as iterateEndnoteReferenceRuns, X as JSZip, Y as imageContentTypeDefaults, Z as imageExtensionFromMime, _ as pxToPt$1, $ as buildSegmentTable, a0 as buildCanvasTableLayout, a1 as resolveFloatingObjectRect, a2 as getTextBoxFloatingGeometry, a3 as getPresetPathSegments, a4 as projectBlocksLayout, a5 as buildListLabels, a6 as textStyleToFontSizePt, a7 as PX_PER_POINT, a8 as DEFAULT_FONT_SIZE_PX, a9 as isDoubleUnderlineStyle, aa as isWavyUnderlineStyle, ab as underlineStyleLineWidthPx, ac as underlineStyleDashArray, ad as resolveListLabel, ae as getListLabelInset, af as getAlignedListLabelInset, ag as getParagraphBorderInsets, ah as normalizeFamily, ai as ROBOTO_FONT_FILES, aj as loadFontAsset, ak as OFFICE_COMPAT_FONT_FAMILIES, al as buildSfnt, am as defaultFontDecoderRegistry, an as SfntFontProgram, ao as collectPdfFontFamilies, ap as projectDocumentLayout, aq as getPageHeaderZoneTop, ar as getPageBodyTop, as as getPageColumnRects, at as findFootnoteReference, au as FOOTNOTE_MARKER_GUTTER_PX, av as resolveImporterForFile, aw as createEditorStateFromDocument, ax as getDocumentParagraphsCanonical, ay as getToolbarStyleState, az as STANDARD_FONT_SIZES_PT, aA as fontSizePxToPt, aB as probeLocalFontFamilies, aC as createInitialEditorState, aD as parseFontSizePtToPx, aE as formatFontSizePt, aF as listKindForTag, aG as isParagraphTag, aH as collectInlineRuns, aI as parseParagraphStyle, aJ as getHeadingLevel, aK as preciseFontModeVersion, aL as isPreciseFontModeEnabled, aM as togglePreciseFontMode, aN as nextFontSizePt, aO as previousFontSizePt, aP as fontSizePtToPx, aQ as createDefaultToolbarPreset, aR as MenuRegistry, aS as createToolbarRegistry, aT as Editor, aU as resolveCommandRef, aV as commandRefName, aW as InlineShell, aX as BalloonShell, aY as DocumentShell, aZ as createMemo, a_ as getCaretRectFromSnapshot, a$ as getParagraphRectFromSnapshot, b0 as createComponent, b1 as CaretOverlay, b2 as Show, b3 as createRenderEffect, b4 as style, b5 as setAttribute, b6 as setStyleProperty, b7 as memo, b8 as template, b9 as useI18n, ba as insert, bb as use, bc as addEventListener, bd as Dialog, be as delegateEvents, bf as className, bg as For, bh as UNDERLINE_STYLE_OPTIONS, bi as Tabs, bj as measureParagraphMinContentWidthPx, bk as getEditableBlocksForZone, bl as findParagraphLocation, bm as createSectionBoundaryParagraph, bn as normalizePageSettings, bo as DEFAULT_EDITOR_PAGE_SETTINGS, bp as markStart, bq as markEnd, br as getParagraphEntries, bs as getParagraphById, bt as PluginUiHost, bu as OasisEditorEditor, bv as perfTimer, bw as OasisBrandMark, bx as setPreciseFontPreference, by as setWelcomeSeen, bz as enablePreciseFontMode, bA as createOasisEditorClient, bB as createEditorZoom, bC as startLongTaskObserver, bD as installGlobalReport, bE as applyStoredPreciseFontPreference, bF as getWelcomeSeen, bG as isLocalFontAccessSupported, bH as EDITOR_SCROLL_PADDING_PX, bI as Toolbar, bJ as OasisEditorLoading, bK as I18nProvider, bL as createEditorLogger, bM as createTranslator, bN as getCachedCanvasImage, bO as registerDomStatsSurface } from "./index-CDi9hs5T.js";
5
5
  function getSelectedObjectRun(state, predicate) {
6
6
  const normalized = normalizeSelection(state);
7
7
  if (normalized.isCollapsed || normalized.startIndex !== normalized.endIndex || normalized.endParagraphOffset - normalized.startParagraphOffset !== 1) {
@@ -5765,49 +5765,48 @@ function deleteItem(db, storeName, key) {
5765
5765
  }
5766
5766
  });
5767
5767
  }
5768
- const DB_NAME = "oasis-editor-db";
5769
- const STORE_NAME = "documents";
5770
- const DOCUMENT_KEY = "current-document";
5768
+ const DEFAULT_DB_NAME = "oasis-editor-db";
5769
+ const DEFAULT_STORE_NAME = "documents";
5770
+ const DEFAULT_DOCUMENT_KEY = "current-document";
5771
5771
  const DB_VERSION = 1;
5772
- class PersistenceService {
5773
- constructor() {
5774
- __publicField(this, "db", null);
5775
- }
5776
- async getDB() {
5777
- if (this.db) {
5778
- return this.db;
5779
- }
5780
- this.db = await openDB({
5781
- name: DB_NAME,
5772
+ function createIndexedDbPersistence(options = {}) {
5773
+ const dbName = options.dbName ?? DEFAULT_DB_NAME;
5774
+ const storeName = options.storeName ?? DEFAULT_STORE_NAME;
5775
+ const documentKey = options.key ?? DEFAULT_DOCUMENT_KEY;
5776
+ let db = null;
5777
+ async function getDB() {
5778
+ if (db) {
5779
+ return db;
5780
+ }
5781
+ db = await openDB({
5782
+ name: dbName,
5782
5783
  version: DB_VERSION,
5783
- onUpgrade: (db) => {
5784
- if (!db.objectStoreNames.contains(STORE_NAME)) {
5785
- db.createObjectStore(STORE_NAME);
5784
+ onUpgrade: (database) => {
5785
+ if (!database.objectStoreNames.contains(storeName)) {
5786
+ database.createObjectStore(storeName);
5786
5787
  }
5787
5788
  }
5788
5789
  });
5789
- return this.db;
5790
- }
5791
- async saveDocument(doc) {
5792
- const db = await this.getDB();
5793
- await putItem(db, STORE_NAME, DOCUMENT_KEY, doc);
5790
+ return db;
5794
5791
  }
5795
- async loadDocument() {
5796
- const db = await this.getDB();
5797
- return await getItem(db, STORE_NAME, DOCUMENT_KEY);
5798
- }
5799
- async clearDocument() {
5800
- const db = await this.getDB();
5801
- await deleteItem(db, STORE_NAME, DOCUMENT_KEY);
5802
- }
5803
- close() {
5804
- if (this.db) {
5805
- this.db.close();
5806
- this.db = null;
5792
+ return {
5793
+ async saveDocument(doc) {
5794
+ await putItem(await getDB(), storeName, documentKey, doc);
5795
+ },
5796
+ async loadDocument() {
5797
+ return getItem(await getDB(), storeName, documentKey);
5798
+ },
5799
+ async clearDocument() {
5800
+ await deleteItem(await getDB(), storeName, documentKey);
5801
+ },
5802
+ close() {
5803
+ if (db) {
5804
+ db.close();
5805
+ db = null;
5806
+ }
5807
5807
  }
5808
- }
5808
+ };
5809
5809
  }
5810
- const persistenceService = new PersistenceService();
5811
5810
  function findMatchesInDocument(doc, searchTerm, options = {}) {
5812
5811
  if (!searchTerm) return [];
5813
5812
  const matches = [];
@@ -8808,13 +8807,13 @@ function buildSrcRect(crop) {
8808
8807
  }
8809
8808
  const toUnits = (value) => value ? Math.round(value * OOXML_PERCENT_DENOMINATOR) : 0;
8810
8809
  const l = toUnits(crop.left);
8811
- const t2 = toUnits(crop.top);
8810
+ const t = toUnits(crop.top);
8812
8811
  const r = toUnits(crop.right);
8813
8812
  const b = toUnits(crop.bottom);
8814
- if (l === 0 && t2 === 0 && r === 0 && b === 0) {
8813
+ if (l === 0 && t === 0 && r === 0 && b === 0) {
8815
8814
  return "";
8816
8815
  }
8817
- return `<a:srcRect l="${l}" t="${t2}" r="${r}" b="${b}"/>`;
8816
+ return `<a:srcRect l="${l}" t="${t}" r="${r}" b="${b}"/>`;
8818
8817
  }
8819
8818
  function buildAnchorBool(value, fallback) {
8820
8819
  return value ?? fallback ? "1" : "0";
@@ -9612,18 +9611,27 @@ function buildNumberingContext(document2) {
9612
9611
  }
9613
9612
  const level = Math.max(0, paragraph.list.level ?? 0);
9614
9613
  const bulletGlyph = paragraph.list.bulletGlyph ?? "";
9615
- const key = `${paragraph.list.kind}:${level}:${bulletGlyph}`;
9614
+ const key = paragraph.list.instanceId ? `instance:${paragraph.list.instanceId}` : `legacy:${paragraph.list.kind}:${level}:${bulletGlyph}`;
9616
9615
  let definition = definitionMap.get(key);
9617
9616
  if (!definition) {
9618
- definition = { abstractNumId: nextAbstractNumId++, numId: nextNumId++ };
9617
+ definition = {
9618
+ abstractNumId: nextAbstractNumId++,
9619
+ numId: nextNumId++,
9620
+ levels: []
9621
+ };
9619
9622
  definitionMap.set(key, definition);
9620
- definitions.push({
9623
+ definitions.push(definition);
9624
+ }
9625
+ if (!definition.levels.some((candidate) => candidate.level === level)) {
9626
+ definition.levels.push({
9621
9627
  kind: paragraph.list.kind,
9622
9628
  level,
9623
- abstractNumId: definition.abstractNumId,
9624
- numId: definition.numId,
9625
9629
  format: paragraph.list.format,
9626
9630
  startAt: paragraph.list.startAt,
9631
+ levelText: paragraph.list.levelText,
9632
+ suffix: paragraph.list.suffix,
9633
+ alignment: paragraph.list.alignment,
9634
+ legal: paragraph.list.legal,
9627
9635
  bulletGlyph: paragraph.list.bulletGlyph,
9628
9636
  bulletFont: paragraph.list.bulletFont
9629
9637
  });
@@ -9733,24 +9741,32 @@ function buildPartContext(blocks, numberingContext, state, document2) {
9733
9741
  };
9734
9742
  }
9735
9743
  function buildNumberingXml(definitions) {
9736
- const abstractNums = definitions.map(
9737
- ({
9738
- kind,
9739
- level,
9740
- abstractNumId,
9741
- format,
9742
- startAt,
9743
- bulletGlyph,
9744
- bulletFont
9745
- }) => {
9746
- const numFmtVal = kind === "bullet" ? "bullet" : format ?? "decimal";
9747
- const levelText = kind === "bullet" ? bulletGlyph ?? "" : `%${level + 1}.`;
9748
- const startVal = startAt ?? 1;
9749
- const fontName = kind === "bullet" ? bulletFont ?? "Symbol" : void 0;
9750
- const runFonts = fontName ? `<w:rPr><w:rFonts w:ascii="${escapeXml(fontName)}" w:hAnsi="${escapeXml(fontName)}" w:hint="default"/></w:rPr>` : "";
9751
- return `<w:abstractNum w:abstractNumId="${abstractNumId}"><w:lvl w:ilvl="${level}"><w:start w:val="${startVal}"/><w:numFmt w:val="${numFmtVal}"/><w:lvlText w:val="${escapeXml(levelText)}"/><w:lvlJc w:val="left"/>${runFonts}</w:lvl></w:abstractNum>`;
9752
- }
9753
- ).join("");
9744
+ const abstractNums = definitions.map(({ abstractNumId, levels }) => {
9745
+ const levelsXml = levels.sort((a, b) => a.level - b.level).map(
9746
+ ({
9747
+ kind,
9748
+ level,
9749
+ format,
9750
+ startAt,
9751
+ levelText,
9752
+ suffix,
9753
+ alignment,
9754
+ legal,
9755
+ bulletGlyph,
9756
+ bulletFont
9757
+ }) => {
9758
+ const numFmtVal = kind === "bullet" ? "bullet" : format ?? "decimal";
9759
+ const effectiveLevelText = levelText ?? (kind === "bullet" ? bulletGlyph ?? "" : `%${level + 1}.`);
9760
+ const startVal = startAt ?? 1;
9761
+ const fontName = kind === "bullet" ? bulletFont ?? "Symbol" : void 0;
9762
+ const runFonts = fontName ? `<w:rPr><w:rFonts w:ascii="${escapeXml(fontName)}" w:hAnsi="${escapeXml(fontName)}" w:hint="default"/></w:rPr>` : "";
9763
+ const suffixXml = suffix && suffix !== "tab" ? `<w:suff w:val="${suffix}"/>` : "";
9764
+ const legalXml = legal ? "<w:isLgl/>" : "";
9765
+ return `<w:lvl w:ilvl="${level}"><w:start w:val="${startVal}"/><w:numFmt w:val="${numFmtVal}"/><w:lvlText w:val="${escapeXml(effectiveLevelText)}"/><w:lvlJc w:val="${alignment ?? "left"}"/>${suffixXml}${legalXml}${runFonts}</w:lvl>`;
9766
+ }
9767
+ ).join("");
9768
+ return `<w:abstractNum w:abstractNumId="${abstractNumId}">${levelsXml}</w:abstractNum>`;
9769
+ }).join("");
9754
9770
  const nums = definitions.map(
9755
9771
  ({ abstractNumId, numId }) => `<w:num w:numId="${numId}"><w:abstractNumId w:val="${abstractNumId}"/></w:num>`
9756
9772
  ).join("");
@@ -10272,7 +10288,7 @@ async function drawTextBoxContent(writer, textBox, ctx, xPx, yPx, widthPx, heigh
10272
10288
  if (blocks.length === 0) {
10273
10289
  return;
10274
10290
  }
10275
- const listOrdinals = /* @__PURE__ */ new Map();
10291
+ const listOrdinals = buildListLabels(ctx.document);
10276
10292
  writer.saveGraphicsState(ctx.pageIndex);
10277
10293
  writer.clipRect(
10278
10294
  ctx.pageIndex,
@@ -10948,118 +10964,15 @@ async function drawFragmentText(writer, pageIndex, paragraph, line, fragment, do
10948
10964
  );
10949
10965
  }
10950
10966
  }
10951
- const BULLET_GLYPHS = ["•", "○", "▪", "•", "○", "▪"];
10952
- const ORDERED_DEFAULT_FORMATS = [
10953
- "decimal",
10954
- "lowerLetter",
10955
- "lowerRoman",
10956
- "decimal",
10957
- "lowerLetter",
10958
- "lowerRoman"
10959
- ];
10960
- function toAlpha(value) {
10961
- if (value <= 0) {
10962
- return String(value);
10963
- }
10964
- let remaining = value;
10965
- let output = "";
10966
- while (remaining > 0) {
10967
- const rem = (remaining - 1) % 26;
10968
- output = String.fromCharCode(65 + rem) + output;
10969
- remaining = Math.floor((remaining - 1) / 26);
10970
- }
10971
- return output;
10972
- }
10973
- function toRoman(value) {
10974
- if (value <= 0 || value >= 4e3) {
10975
- return String(value);
10976
- }
10977
- const map = [
10978
- [1e3, "M"],
10979
- [900, "CM"],
10980
- [500, "D"],
10981
- [400, "CD"],
10982
- [100, "C"],
10983
- [90, "XC"],
10984
- [50, "L"],
10985
- [40, "XL"],
10986
- [10, "X"],
10987
- [9, "IX"],
10988
- [5, "V"],
10989
- [4, "IV"],
10990
- [1, "I"]
10991
- ];
10992
- let remaining = value;
10993
- let output = "";
10994
- for (const [amount, text] of map) {
10995
- while (remaining >= amount) {
10996
- output += text;
10997
- remaining -= amount;
10998
- }
10999
- }
11000
- return output;
11001
- }
11002
- function formatOrdinal(value, format) {
11003
- switch (format) {
11004
- case "lowerLetter":
11005
- return toAlpha(value).toLowerCase();
11006
- case "upperLetter":
11007
- return toAlpha(value).toUpperCase();
11008
- case "lowerRoman":
11009
- return toRoman(value).toLowerCase();
11010
- case "upperRoman":
11011
- return toRoman(value).toUpperCase();
11012
- case "decimal":
11013
- default:
11014
- return String(value);
11015
- }
11016
- }
11017
10967
  function getListOrdinals(document2) {
11018
- const result = /* @__PURE__ */ new Map();
11019
- const paragraphs = getDocumentParagraphs(document2);
11020
- let counters = [];
11021
- let previousWasOrdered = false;
11022
- for (const paragraph of paragraphs) {
11023
- const list = paragraph.list;
11024
- if (!list || list.kind !== "ordered") {
11025
- counters = [];
11026
- previousWasOrdered = false;
11027
- continue;
11028
- }
11029
- const level = list.level ?? 0;
11030
- if (!previousWasOrdered) {
11031
- counters = [];
11032
- }
11033
- if (counters.length > level + 1) {
11034
- counters.length = level + 1;
11035
- }
11036
- while (counters.length <= level) {
11037
- counters.push(0);
11038
- }
11039
- counters[level] = counters[level] === 0 && typeof list.startAt === "number" ? list.startAt : counters[level] + 1;
11040
- result.set(paragraph.id, counters[level]);
11041
- previousWasOrdered = true;
11042
- }
11043
- return result;
11044
- }
11045
- function resolveListPrefix(paragraph, listOrdinals) {
11046
- if (!paragraph.list) {
11047
- return "";
11048
- }
11049
- const level = Math.max(0, paragraph.list.level ?? 0);
11050
- if (paragraph.list.kind === "bullet") {
11051
- return BULLET_GLYPHS[level % BULLET_GLYPHS.length];
11052
- }
11053
- const value = listOrdinals.get(paragraph.id) ?? paragraph.list.startAt ?? 1;
11054
- const format = paragraph.list.format && paragraph.list.format !== "bullet" ? paragraph.list.format : ORDERED_DEFAULT_FORMATS[level % ORDERED_DEFAULT_FORMATS.length];
11055
- return `${formatOrdinal(value, format)}.`;
10968
+ return buildListLabels(document2);
11056
10969
  }
11057
10970
  function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX, originY, fontRegistry, listOrdinals) {
11058
10971
  var _a;
11059
10972
  if (line.index !== 0) {
11060
10973
  return;
11061
10974
  }
11062
- const prefix = resolveListPrefix(paragraph, listOrdinals);
10975
+ const prefix = resolveListLabel(paragraph, listOrdinals);
11063
10976
  if (!prefix) {
11064
10977
  return;
11065
10978
  }
@@ -11078,11 +10991,19 @@ function drawListPrefix(writer, pageIndex, paragraph, line, document2, originX,
11078
10991
  italic: styles.italic
11079
10992
  });
11080
10993
  const labelInset = getListLabelInset(paragraph, document2.styles);
10994
+ const fontSizePt = textStyleToFontSizePt(styles);
10995
+ const estimatedLabelWidthPx = prefix.length * fontSizePt * 0.62 * (96 / 72);
10996
+ const alignedInset = getAlignedListLabelInset(
10997
+ paragraph,
10998
+ document2.styles,
10999
+ firstSlot.left,
11000
+ estimatedLabelWidthPx
11001
+ );
11081
11002
  writer.drawText(pageIndex, {
11082
- x: pxToPt$1(originX + Math.max(0, labelInset)),
11003
+ x: pxToPt$1(originX + Math.max(0, alignedInset || labelInset)),
11083
11004
  y: pxToPt$1(originY + line.top + line.height * 0.8),
11084
11005
  text: prefix,
11085
- fontSize: textStyleToFontSizePt(styles),
11006
+ fontSize: fontSizePt,
11086
11007
  color: styles.color ?? "#000000",
11087
11008
  bold: styles.bold,
11088
11009
  italic: styles.italic,
@@ -40650,6 +40571,7 @@ function parseEditorClipboardHtmlWithDom(html) {
40650
40571
  return paragraphs;
40651
40572
  }
40652
40573
  function createEditorContextMenuClipboard(deps) {
40574
+ const t = deps.t;
40653
40575
  const programmaticCopy = async () => {
40654
40576
  var _a;
40655
40577
  const state = deps.state();
@@ -42042,6 +41964,361 @@ function createEditorEssentialsRuntimePlugin(options) {
42042
41964
  table: essentialsTable
42043
41965
  });
42044
41966
  }
41967
+ const defaultMenuItems = [
41968
+ // File
41969
+ {
41970
+ id: "file_new",
41971
+ path: "File/New",
41972
+ labelKey: "menu.file.new",
41973
+ shortcut: "Ctrl+N",
41974
+ hidden: true,
41975
+ icon: "file-plus"
41976
+ },
41977
+ {
41978
+ id: "file_import",
41979
+ path: "File/Import",
41980
+ labelKey: "toolbar.import",
41981
+ shortcut: "Ctrl+O",
41982
+ command: "importDocument",
41983
+ icon: "upload"
41984
+ },
41985
+ {
41986
+ id: "file_save",
41987
+ path: "File/Save",
41988
+ labelKey: "generic.save",
41989
+ shortcut: "Ctrl+S",
41990
+ hidden: true,
41991
+ icon: "save"
41992
+ },
41993
+ {
41994
+ id: "file_export",
41995
+ path: "File/Export",
41996
+ labelKey: "menu.file.export",
41997
+ icon: "download"
41998
+ },
41999
+ {
42000
+ id: "file_export_pdf",
42001
+ path: "File/Export/PDF",
42002
+ command: "exportPdf",
42003
+ icon: "file-down"
42004
+ },
42005
+ {
42006
+ id: "file_export_docx",
42007
+ path: "File/Export/DOCX",
42008
+ command: "exportDocx",
42009
+ icon: "file-text"
42010
+ },
42011
+ { id: "file_export_html", path: "File/Export/HTML", hidden: true },
42012
+ { id: "file_export_md", path: "File/Export/MD", hidden: true },
42013
+ {
42014
+ id: "file_print",
42015
+ path: "File/Print",
42016
+ labelKey: "menu.file.print",
42017
+ shortcut: "Ctrl+P",
42018
+ command: "print",
42019
+ icon: "printer"
42020
+ },
42021
+ // Edit
42022
+ {
42023
+ id: "edit_undo",
42024
+ path: "Edit/Undo",
42025
+ labelKey: "toolbar.undo",
42026
+ shortcut: "Ctrl+Z",
42027
+ command: "undo",
42028
+ icon: "undo-2"
42029
+ },
42030
+ {
42031
+ id: "edit_redo",
42032
+ path: "Edit/Redo",
42033
+ labelKey: "toolbar.redo",
42034
+ shortcut: "Ctrl+Y",
42035
+ command: "redo",
42036
+ icon: "redo-2"
42037
+ },
42038
+ {
42039
+ id: "edit_cut",
42040
+ path: "Edit/Cut",
42041
+ labelKey: "menu.edit.cut",
42042
+ shortcut: "Ctrl+X",
42043
+ hidden: true
42044
+ },
42045
+ {
42046
+ id: "edit_copy",
42047
+ path: "Edit/Copy",
42048
+ labelKey: "menu.edit.copy",
42049
+ shortcut: "Ctrl+C",
42050
+ command: "copy",
42051
+ icon: "copy"
42052
+ },
42053
+ {
42054
+ id: "edit_paste",
42055
+ path: "Edit/Paste",
42056
+ labelKey: "menu.edit.paste",
42057
+ shortcut: "Ctrl+V",
42058
+ hidden: true
42059
+ },
42060
+ {
42061
+ id: "edit_find",
42062
+ path: "Edit/Find & Replace",
42063
+ labelKey: "find.title",
42064
+ shortcut: "Ctrl+F",
42065
+ command: "find",
42066
+ icon: "search"
42067
+ },
42068
+ {
42069
+ id: "edit_selectAll",
42070
+ path: "Edit/Select All",
42071
+ labelKey: "menu.edit.selectAll",
42072
+ shortcut: "Ctrl+A",
42073
+ hidden: true
42074
+ },
42075
+ // View
42076
+ {
42077
+ id: "view_outline",
42078
+ path: "View/Show Outline",
42079
+ labelKey: "menu.view.outline",
42080
+ hidden: true
42081
+ },
42082
+ { id: "view_ruler", path: "View/Show Ruler", hidden: true },
42083
+ {
42084
+ id: "view_margins",
42085
+ path: "View/Show Margins",
42086
+ labelKey: "menu.view.margins",
42087
+ command: "toggleShowMargins",
42088
+ icon: (host) => host.commands.state("toggleShowMargins").isActive ? "check-square" : "square"
42089
+ },
42090
+ {
42091
+ id: "view_paragraph_marks",
42092
+ path: "View/Show Paragraph Marks",
42093
+ labelKey: "menu.view.paragraphMarks",
42094
+ command: "toggleShowParagraphMarks",
42095
+ icon: (host) => host.commands.state("toggleShowParagraphMarks").isActive ? "check-square" : "square"
42096
+ },
42097
+ {
42098
+ id: "view_precise_fonts",
42099
+ path: "View/Precise Fonts",
42100
+ labelKey: "menu.view.preciseFonts",
42101
+ command: "togglePreciseFonts",
42102
+ icon: (host) => host.commands.state("togglePreciseFonts").isActive ? "check-square" : "square"
42103
+ },
42104
+ {
42105
+ id: "view_fullscreen",
42106
+ path: "View/Full Screen",
42107
+ labelKey: "menu.view.fullscreen",
42108
+ hidden: true
42109
+ },
42110
+ { id: "view_zoom", path: "View/Zoom", labelKey: "status.zoom", hidden: true },
42111
+ { id: "view_zoom_50", path: "View/Zoom/50%", hidden: true },
42112
+ { id: "view_zoom_75", path: "View/Zoom/75%", hidden: true },
42113
+ { id: "view_zoom_100", path: "View/Zoom/100%", hidden: true },
42114
+ { id: "view_zoom_125", path: "View/Zoom/125%", hidden: true },
42115
+ { id: "view_zoom_150", path: "View/Zoom/150%", hidden: true },
42116
+ { id: "view_zoom_200", path: "View/Zoom/200%", hidden: true },
42117
+ // Insert
42118
+ {
42119
+ id: "insert_image",
42120
+ path: "Insert/Image",
42121
+ labelKey: "toolbar.image",
42122
+ command: "insertImage",
42123
+ icon: "image"
42124
+ },
42125
+ {
42126
+ id: "insert_image_caption",
42127
+ path: "Insert/Image Caption",
42128
+ labelKey: "toolbar.imageCaption",
42129
+ command: "insertImageCaption",
42130
+ icon: "subtitles"
42131
+ },
42132
+ {
42133
+ id: "insert_table",
42134
+ path: "Insert/Table",
42135
+ labelKey: "toolbar.table",
42136
+ command: { name: "insertTable", payload: { rows: 3, cols: 3 } },
42137
+ icon: "table"
42138
+ },
42139
+ {
42140
+ id: "insert_link",
42141
+ path: "Insert/Link",
42142
+ labelKey: "toolbar.link",
42143
+ command: "link",
42144
+ icon: "link"
42145
+ },
42146
+ {
42147
+ id: "insert_footnote",
42148
+ path: "Insert/Footnote",
42149
+ labelKey: "toolbar.footnote",
42150
+ shortcut: "Ctrl+Alt+F",
42151
+ command: "insertFootnote",
42152
+ icon: "footnote"
42153
+ },
42154
+ {
42155
+ id: "insert_toc",
42156
+ path: "Insert/Table of Contents",
42157
+ labelKey: "menu.insert.toc",
42158
+ command: "insertTableOfContents",
42159
+ icon: "list"
42160
+ },
42161
+ {
42162
+ id: "insert_toc_update",
42163
+ path: "Insert/Update Table of Contents",
42164
+ labelKey: "menu.insert.updateToc",
42165
+ command: "updateTableOfContents",
42166
+ icon: "refresh-cw"
42167
+ },
42168
+ { id: "insert_hr", path: "Insert/Horizontal Rule", hidden: true },
42169
+ {
42170
+ id: "insert_pageBreak",
42171
+ path: "Insert/Page Break",
42172
+ labelKey: "metric.pageBreak",
42173
+ command: "pageBreak",
42174
+ icon: "file-minus"
42175
+ },
42176
+ { id: "insert_specialChar", path: "Insert/Special Character", hidden: true },
42177
+ { id: "insert_comment", path: "Insert/Comment", hidden: true },
42178
+ // Format
42179
+ {
42180
+ id: "format_text",
42181
+ path: "Format/Text",
42182
+ labelKey: "menu.format.text",
42183
+ icon: "type"
42184
+ },
42185
+ {
42186
+ id: "format_text_bold",
42187
+ path: "Format/Text/Bold",
42188
+ labelKey: "toolbar.bold",
42189
+ shortcut: "Ctrl+B",
42190
+ command: "bold",
42191
+ icon: "bold"
42192
+ },
42193
+ {
42194
+ id: "format_text_italic",
42195
+ path: "Format/Text/Italic",
42196
+ labelKey: "toolbar.italic",
42197
+ shortcut: "Ctrl+I",
42198
+ command: "italic",
42199
+ icon: "italic"
42200
+ },
42201
+ {
42202
+ id: "format_text_underline",
42203
+ path: "Format/Text/Underline",
42204
+ labelKey: "toolbar.underline",
42205
+ shortcut: "Ctrl+U",
42206
+ command: "underline",
42207
+ icon: "underline"
42208
+ },
42209
+ {
42210
+ id: "format_text_strike",
42211
+ path: "Format/Text/Strikethrough",
42212
+ labelKey: "toolbar.strike",
42213
+ command: "strike",
42214
+ icon: "strikethrough"
42215
+ },
42216
+ {
42217
+ id: "format_paragraphStyles",
42218
+ path: "Format/Paragraph styles",
42219
+ labelKey: "toolbar.style",
42220
+ hidden: true
42221
+ },
42222
+ {
42223
+ id: "format_align",
42224
+ path: "Format/Align",
42225
+ labelKey: "menu.format.align",
42226
+ icon: "align-left"
42227
+ },
42228
+ {
42229
+ id: "format_align_left",
42230
+ path: "Format/Align/Left",
42231
+ labelKey: "toolbar.alignLeft",
42232
+ command: "alignLeft",
42233
+ icon: "align-left"
42234
+ },
42235
+ {
42236
+ id: "format_align_center",
42237
+ path: "Format/Align/Center",
42238
+ labelKey: "toolbar.alignCenter",
42239
+ command: "alignCenter",
42240
+ icon: "align-center"
42241
+ },
42242
+ {
42243
+ id: "format_align_right",
42244
+ path: "Format/Align/Right",
42245
+ labelKey: "toolbar.alignRight",
42246
+ command: "alignRight",
42247
+ icon: "align-right"
42248
+ },
42249
+ {
42250
+ id: "format_align_justify",
42251
+ path: "Format/Align/Justify",
42252
+ labelKey: "toolbar.justify",
42253
+ command: "alignJustify",
42254
+ icon: "align-justify"
42255
+ },
42256
+ { id: "format_lineSpacing", path: "Format/Line spacing", hidden: true },
42257
+ {
42258
+ id: "format_lists",
42259
+ path: "Format/Lists",
42260
+ labelKey: "menu.format.lists",
42261
+ icon: "list"
42262
+ },
42263
+ {
42264
+ id: "format_lists_bullet",
42265
+ path: "Format/Lists/Bullet List",
42266
+ labelKey: "toolbar.bulletList",
42267
+ command: "bulletList",
42268
+ icon: "list"
42269
+ },
42270
+ {
42271
+ id: "format_lists_numbered",
42272
+ path: "Format/Lists/Numbered List",
42273
+ labelKey: "toolbar.numberedList",
42274
+ command: "orderedList",
42275
+ icon: "list-ordered"
42276
+ },
42277
+ { id: "format_clear", path: "Format/Clear formatting", hidden: true },
42278
+ // Layout
42279
+ {
42280
+ id: "layout_orientation",
42281
+ path: "Layout/Orientation",
42282
+ labelKey: "section.orientation",
42283
+ icon: "layout"
42284
+ },
42285
+ {
42286
+ id: "layout_orientation_portrait",
42287
+ path: "Layout/Orientation/Portrait",
42288
+ labelKey: "section.portrait",
42289
+ command: { name: "setOrientation", payload: "portrait" },
42290
+ icon: (host) => host.commands.state("toggleOrientation").isActive ? "" : "check"
42291
+ },
42292
+ {
42293
+ id: "layout_orientation_landscape",
42294
+ path: "Layout/Orientation/Landscape",
42295
+ labelKey: "section.landscape",
42296
+ command: { name: "setOrientation", payload: "landscape" },
42297
+ icon: (host) => host.commands.state("toggleOrientation").isActive ? "check" : ""
42298
+ },
42299
+ // Tools
42300
+ {
42301
+ id: "tools_wordcount",
42302
+ path: "Tools/Word count",
42303
+ labelKey: "menu.tools.wordcount",
42304
+ hidden: true
42305
+ },
42306
+ { id: "tools_spelling", hidden: true, path: "Tools/Spelling" },
42307
+ { id: "tools_preferences", path: "Tools/Preferences", hidden: true },
42308
+ // Help
42309
+ {
42310
+ id: "help_shortcuts",
42311
+ path: "Help/Keyboard shortcuts",
42312
+ labelKey: "menu.help.shortcuts",
42313
+ hidden: true
42314
+ },
42315
+ {
42316
+ id: "help_about",
42317
+ path: "Help/About",
42318
+ labelKey: "menu.help.about",
42319
+ hidden: true
42320
+ }
42321
+ ];
42045
42322
  function useEditorRuntimePlugins(options) {
42046
42323
  var _a, _b;
42047
42324
  const runtimePlugins = [
@@ -42052,7 +42329,7 @@ function useEditorRuntimePlugins(options) {
42052
42329
  const contributedMenuIds = [];
42053
42330
  const toolbarRegistry = createToolbarRegistry();
42054
42331
  const menuRegistry = new MenuRegistry();
42055
- for (const item of createDefaultToolbarPreset()) {
42332
+ for (const item of createDefaultToolbarPreset(options.t)) {
42056
42333
  toolbarRegistry.register(item);
42057
42334
  }
42058
42335
  for (const item of defaultMenuItems) {
@@ -42194,6 +42471,7 @@ function useEditorRuntimeBootstrap(ctx) {
42194
42471
  } = useEditorRuntimePlugins({
42195
42472
  essentialsPlugin,
42196
42473
  externalPlugins: ctx.externalPlugins,
42474
+ t: ctx.t,
42197
42475
  customizeToolbar: ctx.customizeToolbar,
42198
42476
  customizeMenubar: ctx.customizeMenubar
42199
42477
  });
@@ -42481,6 +42759,7 @@ function EditorDragLayers(props) {
42481
42759
  }
42482
42760
  var _tmpl$$d = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input data-testid=editor-link-dialog-input>`), _tmpl$2$8 = /* @__PURE__ */ template(`<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-link-dialog-cancel>`), _tmpl$3$6 = /* @__PURE__ */ template(`<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-link-dialog-apply>`);
42483
42761
  function LinkDialog(props) {
42762
+ const t = useI18n();
42484
42763
  const [href, setHref] = createSignal(props.initialHref);
42485
42764
  let inputRef;
42486
42765
  createEffect(() => {
@@ -42532,6 +42811,7 @@ function LinkDialog(props) {
42532
42811
  delegateEvents(["input", "keydown", "click"]);
42533
42812
  var _tmpl$$c = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input>`), _tmpl$2$7 = /* @__PURE__ */ template(`<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary">`), _tmpl$3$5 = /* @__PURE__ */ template(`<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary">`);
42534
42813
  function ImageAltDialog(props) {
42814
+ const t = useI18n();
42535
42815
  const [alt, setAlt] = createSignal(props.initialAlt);
42536
42816
  let inputRef;
42537
42817
  createEffect(() => {
@@ -42583,6 +42863,7 @@ function ImageAltDialog(props) {
42583
42863
  delegateEvents(["input", "keydown", "click"]);
42584
42864
  var _tmpl$$b = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=text class=oasis-editor-dialog-input>`), _tmpl$2$6 = /* @__PURE__ */ template(`<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary">`), _tmpl$3$4 = /* @__PURE__ */ template(`<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary">`);
42585
42865
  function ImageCaptionDialog(props) {
42866
+ const t = useI18n();
42586
42867
  const [caption, setCaption] = createSignal(props.initialCaption);
42587
42868
  let inputRef;
42588
42869
  createEffect(() => {
@@ -42848,6 +43129,7 @@ function buildFontDialogApplyValues(font, advanced) {
42848
43129
  };
42849
43130
  }
42850
43131
  function useFontDialogController(props) {
43132
+ const t = useI18n();
42851
43133
  const [activeTab, setActiveTab] = createSignal("font");
42852
43134
  const [fontTabValues, setFontTabValues] = createSignal(
42853
43135
  createFontTabValuesFromInitial(props.initial)
@@ -42951,6 +43233,7 @@ function useFontDialogController(props) {
42951
43233
  }
42952
43234
  var _tmpl$$a = /* @__PURE__ */ template(`<div>`);
42953
43235
  function FontPreview(props) {
43236
+ const t = useI18n();
42954
43237
  return (() => {
42955
43238
  var _el$ = _tmpl$$a();
42956
43239
  insert(_el$, () => t("dialog.font.previewText"));
@@ -42970,6 +43253,7 @@ function FontPreview(props) {
42970
43253
  }
42971
43254
  var _tmpl$$9 = /* @__PURE__ */ template(`<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-font-panel"><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><input class=oasis-editor-dialog-input data-testid=editor-font-dialog-family-filter></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-family><option value>—</option></select></div><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-size-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-size><option value>—</option></select></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-custom-size-group"><label class=oasis-editor-dialog-label></label><input class=oasis-editor-dialog-input data-testid=editor-font-dialog-custom-size><span class=oasis-editor-dialog-help-text></span></div><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-style-list-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-style-list><option value=regular></option><option value=italic></option><option value=bold></option><option value=boldItalic></option></select></div></div><div class="oasis-editor-dialog-row oasis-editor-font-dialog-color-row"><div class="oasis-editor-dialog-input-group oasis-editor-font-dialog-color-mode-group"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-color-mode><option value=automatic></option><option value=custom></option></select><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-color></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-highlight></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-shading></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-underline-style><option value=none></option></select></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label></label><input type=color class=oasis-editor-dialog-color data-testid=editor-font-dialog-underline-color></div></div><div class=oasis-editor-dialog-row><div class="oasis-editor-dialog-input-group oasis-editor-dialog-input-group-grow"><label class=oasis-editor-dialog-label></label><div class=oasis-editor-dialog-style-row><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-bold><span style=font-weight:700></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-italic><span style=font-style:italic></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-underline><span style=text-decoration:underline></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-strike><span style=text-decoration:line-through></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-double-strike><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-superscript><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-subscript><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-small-caps><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-all-caps><span></span></label><label class=oasis-editor-dialog-style-toggle><input type=checkbox data-testid=editor-font-dialog-hidden><span></span></label></div></div></div><div class=oasis-editor-dialog-input-group><label class=oasis-editor-dialog-label>`), _tmpl$2$5 = /* @__PURE__ */ template(`<option>`);
42972
43255
  function FontTab(props) {
43256
+ const t = useI18n();
42973
43257
  const {
42974
43258
  ctrl
42975
43259
  } = props;
@@ -43135,6 +43419,7 @@ function FontTab(props) {
43135
43419
  delegateEvents(["input"]);
43136
43420
  var _tmpl$$8 = /* @__PURE__ */ template(`<div class="oasis-editor-font-dialog-panel oasis-editor-font-dialog-advanced-panel"><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-scale></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-spacing-mode><option value=normal></option><option value=expanded></option><option value=condensed></option></select><label class="oasis-editor-dialog-label oasis-editor-font-dialog-by-label"></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-small-input"data-testid=editor-font-dialog-advanced-spacing-amount></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-position-mode><option value=normal></option><option value=raised></option><option value=lowered></option></select><label class="oasis-editor-dialog-label oasis-editor-font-dialog-by-label"></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-small-input"data-testid=editor-font-dialog-advanced-position-amount></div><div class="oasis-editor-font-dialog-word-row oasis-editor-font-dialog-kerning-row"><label class="oasis-editor-dialog-style-toggle oasis-editor-font-dialog-kerning-toggle"><input type=checkbox data-testid=editor-font-dialog-advanced-kerning-enabled><span></span></label><input class="oasis-editor-dialog-input oasis-editor-font-dialog-kerning-input"data-testid=editor-font-dialog-advanced-kerning><span class="oasis-editor-dialog-help-text oasis-editor-font-dialog-kerning-suffix"></span></div></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-ligatures><option value></option><option value=none></option><option value=standard></option><option value=contextual></option><option value=historical></option><option value=standardContextual></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-number-spacing><option value></option><option value=proportional></option><option value=tabular></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-number-form><option value></option><option value=lining></option><option value=oldStyle></option></select></div><div class=oasis-editor-font-dialog-word-row><label class=oasis-editor-dialog-label></label><select class=oasis-editor-dialog-input data-testid=editor-font-dialog-advanced-stylistic-set><option value></option></select></div><label class="oasis-editor-dialog-style-toggle oasis-editor-font-dialog-contextual-toggle"><input type=checkbox data-testid=editor-font-dialog-advanced-contextual-alternates><span></span></label></fieldset><fieldset class=oasis-editor-font-dialog-fieldset><legend></legend></fieldset><p class=oasis-editor-dialog-help-text data-testid=editor-font-dialog-advanced-placeholder>`), _tmpl$2$4 = /* @__PURE__ */ template(`<option>%`), _tmpl$3$3 = /* @__PURE__ */ template(`<option>`);
43137
43421
  function AdvancedFontTab(props) {
43422
+ const t = useI18n();
43138
43423
  const {
43139
43424
  ctrl
43140
43425
  } = props;
@@ -43249,6 +43534,7 @@ function AdvancedFontTab(props) {
43249
43534
  delegateEvents(["input"]);
43250
43535
  var _tmpl$$7 = /* @__PURE__ */ template(`<button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-font-dialog-cancel>`), _tmpl$2$3 = /* @__PURE__ */ template(`<button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-font-dialog-apply>`);
43251
43536
  function FontDialog(props) {
43537
+ const t = useI18n();
43252
43538
  const ctrl = useFontDialogController(props);
43253
43539
  return createComponent(Dialog, {
43254
43540
  get isOpen() {
@@ -43317,6 +43603,7 @@ function parseNumber$1(value) {
43317
43603
  return Number.isFinite(num) ? num : null;
43318
43604
  }
43319
43605
  function ParagraphDialog(props) {
43606
+ const t = useI18n();
43320
43607
  const [align, setAlign] = createSignal("");
43321
43608
  const [indentLeft, setIndentLeft] = createSignal("");
43322
43609
  const [indentRight, setIndentRight] = createSignal("");
@@ -43601,6 +43888,7 @@ function resolveBorder(style2, widthValue, colorValue) {
43601
43888
  };
43602
43889
  }
43603
43890
  function TablePropertiesDialog(props) {
43891
+ const t = useI18n();
43604
43892
  const [activeTab, setActiveTab] = createSignal("table");
43605
43893
  const [tableWidth, setTableWidth] = createSignal("");
43606
43894
  const [tableWidthUnit, setTableWidthUnit] = createSignal("points");
@@ -43921,6 +44209,7 @@ function TablePropertiesDialog(props) {
43921
44209
  delegateEvents(["input", "click"]);
43922
44210
  var _tmpl$$4 = /* @__PURE__ */ template(`<div class=oasis-editor-find-replace-dialog><div class=oasis-editor-fr-header><span></span><button class=oasis-editor-fr-close><i data-lucide=x></i></button></div><div class=oasis-editor-fr-body><div class=oasis-editor-fr-input-group><div class=oasis-editor-fr-input-wrapper><input type=text autofocus class=oasis-editor-fr-input><span class=oasis-editor-fr-counter></span></div><div class=oasis-editor-fr-actions><button><i data-lucide=chevron-up></i></button><button><i data-lucide=chevron-down></i></button></div></div><div class=oasis-editor-fr-input-group><input type=text class=oasis-editor-fr-input><div class=oasis-editor-fr-actions><button class=oasis-editor-fr-btn-text></button><button class=oasis-editor-fr-btn-text></button></div></div><div class=oasis-editor-fr-options><label class=oasis-editor-fr-checkbox><input type=checkbox><span></span></label><label class=oasis-editor-fr-checkbox><input type=checkbox><span>`);
43923
44211
  function FindReplaceDialog(props) {
44212
+ const t = useI18n();
43924
44213
  const {
43925
44214
  fr
43926
44215
  } = props;
@@ -46554,6 +46843,7 @@ function useEditorTransactions(ctx) {
46554
46843
  }
46555
46844
  var _tmpl$$1 = /* @__PURE__ */ template(`<div class=oasis-editor-welcome-overlay role=dialog aria-modal=true aria-labelledby=oasis-editor-welcome-title><div class=oasis-editor-welcome-card><h2 id=oasis-editor-welcome-title class=oasis-editor-welcome-title></h2><p class=oasis-editor-welcome-body></p><p class=oasis-editor-welcome-note></p><div class=oasis-editor-welcome-actions><button class="oasis-editor-dialog-button oasis-editor-dialog-button-secondary"data-testid=editor-welcome-skip></button><button class="oasis-editor-dialog-button oasis-editor-dialog-button-primary"data-testid=editor-welcome-enable>`);
46556
46845
  function WelcomeOverlay(props) {
46846
+ const t = useI18n();
46557
46847
  const handleEnable = () => {
46558
46848
  void enablePreciseFontMode();
46559
46849
  setWelcomeSeen();
@@ -46594,9 +46884,7 @@ function OasisEditorApp(props = {}) {
46594
46884
  const documentOptions = () => props.document ?? {};
46595
46885
  const runtimeOptions = () => props.runtime ?? {};
46596
46886
  syncCanvasDebugApiVisibility();
46597
- createEffect(() => {
46598
- setLocale(ui().locale ?? "pt-BR");
46599
- });
46887
+ const translator = createTranslator(() => ui().locale ?? "pt-BR");
46600
46888
  const logger = createEditorLogger("app");
46601
46889
  const {
46602
46890
  state,
@@ -46695,6 +46983,9 @@ function OasisEditorApp(props = {}) {
46695
46983
  isImporting: isImportInProgress,
46696
46984
  zoomFactor: zoom.zoomFactor
46697
46985
  });
46986
+ const fallbackPersistence = createIndexedDbPersistence({
46987
+ key: documentOptions().persistenceKey
46988
+ });
46698
46989
  const {
46699
46990
  status: persistenceStatus
46700
46991
  } = useEditorPersistence(state, (loadedDoc) => {
@@ -46706,7 +46997,7 @@ function OasisEditorApp(props = {}) {
46706
46997
  resetEditorChromeState();
46707
46998
  }, {
46708
46999
  enabled: documentOptions().persistenceEnabled ?? false,
46709
- persistence: documentOptions().persistence ?? persistenceService,
47000
+ persistence: documentOptions().persistence ?? fallbackPersistence,
46710
47001
  logger
46711
47002
  });
46712
47003
  let forcePlainTextPaste = false;
@@ -46993,6 +47284,7 @@ function OasisEditorApp(props = {}) {
46993
47284
  }
46994
47285
  },
46995
47286
  externalPlugins: runtimeOptions().plugins,
47287
+ t: translator,
46996
47288
  customizeToolbar: runtimeOptions().customizeToolbar,
46997
47289
  customizeMenubar: runtimeOptions().customizeMenubar,
46998
47290
  initialDocument: getStateSnapshot().document,
@@ -47023,7 +47315,7 @@ function OasisEditorApp(props = {}) {
47023
47315
  focusInput();
47024
47316
  },
47025
47317
  saveDocument: async () => {
47026
- const persistence = documentOptions().persistence ?? persistenceService;
47318
+ const persistence = documentOptions().persistence ?? fallbackPersistence;
47027
47319
  await persistence.saveDocument(cloneState(getStateSnapshot()).document);
47028
47320
  },
47029
47321
  getSelection: () => cloneState(getStateSnapshot()).selection,
@@ -47159,6 +47451,7 @@ function OasisEditorApp(props = {}) {
47159
47451
  const contextMenuClipboard = createEditorContextMenuClipboard({
47160
47452
  state: () => state,
47161
47453
  isReadOnly,
47454
+ t: translator,
47162
47455
  logger,
47163
47456
  setContextMenu,
47164
47457
  clearPreferredColumn,
@@ -47256,137 +47549,140 @@ function OasisEditorApp(props = {}) {
47256
47549
  textBoxOps.stopTextBoxResize();
47257
47550
  stopIconObserver();
47258
47551
  });
47259
- return (() => {
47260
- var _el$ = _tmpl$();
47261
- setStyleProperty(_el$, "--oasis-editor-gutter-x", `${EDITOR_SCROLL_PADDING_PX}px`);
47262
- insert(_el$, createComponent(Show, {
47263
- get when() {
47264
- return memo(() => !!(!useComposedShell() && showChrome()))() && showToolbar();
47265
- },
47266
- get children() {
47267
- return createComponent(Toolbar, {
47268
- host: toolbarHost,
47269
- registry: toolbarRegistry,
47270
- get view() {
47271
- return toolbarView();
47272
- },
47273
- get layout() {
47274
- return toolbarLayout();
47275
- }
47276
- });
47277
- }
47278
- }), null);
47279
- insert(_el$, createComponent(EditorDialogsLayer, {
47280
- dialogs: {
47281
- linkDialog,
47282
- setLinkDialog,
47283
- imageAltDialog,
47284
- setImageAltDialog,
47285
- imageCaptionDialog,
47286
- setImageCaptionDialog,
47287
- contextMenu,
47288
- setContextMenu,
47289
- fontDialog,
47290
- setFontDialog,
47291
- paragraphDialog,
47292
- setParagraphDialog,
47293
- tablePropertiesDialog,
47294
- setTablePropertiesDialog
47295
- },
47296
- findReplace: fr,
47297
- fontFamilyOptions: computeFontFamilyOptions2,
47298
- fontSizeOptions: computeFontSizeOptions2,
47299
- contextMenuItems: buildContextMenuItems,
47300
- focusInput,
47301
- get applyLinkCommand() {
47302
- return commandsController.applyLinkCommand;
47303
- },
47304
- get applyImageAltCommand() {
47305
- return commandsController.applyImageAltCommand;
47306
- },
47307
- get applyImageCaptionCommand() {
47308
- return commandsController.applyImageCaptionCommand;
47309
- },
47310
- applyFontDialogValues,
47311
- applyParagraphDialogValues,
47312
- applyTablePropertiesDialogValues,
47313
- closeContextMenu
47314
- }), null);
47315
- insert(_el$, createComponent(EditorWorkspace, {
47316
- useComposedShell,
47317
- shellComponent,
47318
- state: () => state,
47319
- toolbarHost,
47320
- runtimeEditor,
47321
- persistenceStatus,
47322
- toolbarRegistry,
47323
- menuRegistry,
47324
- showChrome,
47325
- showTitleBar,
47326
- showMenubar,
47327
- showToolbar,
47328
- showOutline,
47329
- toolbarView,
47330
- toolbarLayout,
47331
- isReadOnly,
47332
- viewportHeight: () => ui().viewportHeight,
47333
- measuredBlockHeights,
47334
- measuredParagraphLayouts,
47335
- showFloatingTableToolbar: () => !isReadOnly() && commandStateOf("tableContext").value !== null,
47336
- layout: editorLayoutProps,
47337
- overlays: editorOverlayProps,
47338
- refs: editorRefs,
47339
- surfaceHandlers: editorSurfaceHandlers,
47340
- inputHandlers: editorInputHandlers,
47341
- fileHandlers: editorFileHandlers
47342
- }), null);
47343
- insert(_el$, createComponent(EditorDragLayers, {
47344
- state,
47345
- get surfaceRef() {
47346
- return surfaceRef();
47347
- },
47348
- tableResize,
47349
- imageOps,
47350
- tableDrag,
47351
- textDrag
47352
- }), null);
47353
- insert(_el$, createComponent(Show, {
47354
- get when() {
47355
- return initialLoading() || !runtimeReady();
47356
- },
47357
- get children() {
47358
- return createComponent(OasisEditorLoading, {
47359
- get label() {
47360
- return loadingLabel();
47361
- },
47362
- get ["class"]() {
47363
- var _a2;
47364
- return (_a2 = loadingOptions()) == null ? void 0 : _a2.class;
47365
- },
47366
- get style() {
47367
- var _a2;
47368
- return (_a2 = loadingOptions()) == null ? void 0 : _a2.style;
47369
- }
47370
- });
47371
- }
47372
- }), null);
47373
- insert(_el$, createComponent(WelcomeOverlay, {
47374
- get isOpen() {
47375
- return memo(() => !!(welcomeOpen() && !initialLoading()))() && runtimeReady();
47376
- },
47377
- onClose: () => setWelcomeOpen(false)
47378
- }), null);
47379
- createRenderEffect((_p$) => {
47380
- var _v$ = !!useComposedShell(), _v$2 = !!isReadOnly();
47381
- _v$ !== _p$.e && _el$.classList.toggle("oasis-editor-docs", _p$.e = _v$);
47382
- _v$2 !== _p$.t && _el$.classList.toggle("oasis-editor-read-only", _p$.t = _v$2);
47383
- return _p$;
47384
- }, {
47385
- e: void 0,
47386
- t: void 0
47387
- });
47388
- return _el$;
47389
- })();
47552
+ return createComponent(I18nProvider, {
47553
+ translator,
47554
+ get children() {
47555
+ var _el$ = _tmpl$();
47556
+ setStyleProperty(_el$, "--oasis-editor-gutter-x", `${EDITOR_SCROLL_PADDING_PX}px`);
47557
+ insert(_el$, createComponent(Show, {
47558
+ get when() {
47559
+ return memo(() => !!(!useComposedShell() && showChrome()))() && showToolbar();
47560
+ },
47561
+ get children() {
47562
+ return createComponent(Toolbar, {
47563
+ host: toolbarHost,
47564
+ registry: toolbarRegistry,
47565
+ get view() {
47566
+ return toolbarView();
47567
+ },
47568
+ get layout() {
47569
+ return toolbarLayout();
47570
+ }
47571
+ });
47572
+ }
47573
+ }), null);
47574
+ insert(_el$, createComponent(EditorDialogsLayer, {
47575
+ dialogs: {
47576
+ linkDialog,
47577
+ setLinkDialog,
47578
+ imageAltDialog,
47579
+ setImageAltDialog,
47580
+ imageCaptionDialog,
47581
+ setImageCaptionDialog,
47582
+ contextMenu,
47583
+ setContextMenu,
47584
+ fontDialog,
47585
+ setFontDialog,
47586
+ paragraphDialog,
47587
+ setParagraphDialog,
47588
+ tablePropertiesDialog,
47589
+ setTablePropertiesDialog
47590
+ },
47591
+ findReplace: fr,
47592
+ fontFamilyOptions: computeFontFamilyOptions2,
47593
+ fontSizeOptions: computeFontSizeOptions2,
47594
+ contextMenuItems: buildContextMenuItems,
47595
+ focusInput,
47596
+ get applyLinkCommand() {
47597
+ return commandsController.applyLinkCommand;
47598
+ },
47599
+ get applyImageAltCommand() {
47600
+ return commandsController.applyImageAltCommand;
47601
+ },
47602
+ get applyImageCaptionCommand() {
47603
+ return commandsController.applyImageCaptionCommand;
47604
+ },
47605
+ applyFontDialogValues,
47606
+ applyParagraphDialogValues,
47607
+ applyTablePropertiesDialogValues,
47608
+ closeContextMenu
47609
+ }), null);
47610
+ insert(_el$, createComponent(EditorWorkspace, {
47611
+ useComposedShell,
47612
+ shellComponent,
47613
+ state: () => state,
47614
+ toolbarHost,
47615
+ runtimeEditor,
47616
+ persistenceStatus,
47617
+ toolbarRegistry,
47618
+ menuRegistry,
47619
+ showChrome,
47620
+ showTitleBar,
47621
+ showMenubar,
47622
+ showToolbar,
47623
+ showOutline,
47624
+ toolbarView,
47625
+ toolbarLayout,
47626
+ isReadOnly,
47627
+ viewportHeight: () => ui().viewportHeight,
47628
+ measuredBlockHeights,
47629
+ measuredParagraphLayouts,
47630
+ showFloatingTableToolbar: () => !isReadOnly() && commandStateOf("tableContext").value !== null,
47631
+ layout: editorLayoutProps,
47632
+ overlays: editorOverlayProps,
47633
+ refs: editorRefs,
47634
+ surfaceHandlers: editorSurfaceHandlers,
47635
+ inputHandlers: editorInputHandlers,
47636
+ fileHandlers: editorFileHandlers
47637
+ }), null);
47638
+ insert(_el$, createComponent(EditorDragLayers, {
47639
+ state,
47640
+ get surfaceRef() {
47641
+ return surfaceRef();
47642
+ },
47643
+ tableResize,
47644
+ imageOps,
47645
+ tableDrag,
47646
+ textDrag
47647
+ }), null);
47648
+ insert(_el$, createComponent(Show, {
47649
+ get when() {
47650
+ return initialLoading() || !runtimeReady();
47651
+ },
47652
+ get children() {
47653
+ return createComponent(OasisEditorLoading, {
47654
+ get label() {
47655
+ return loadingLabel();
47656
+ },
47657
+ get ["class"]() {
47658
+ var _a2;
47659
+ return (_a2 = loadingOptions()) == null ? void 0 : _a2.class;
47660
+ },
47661
+ get style() {
47662
+ var _a2;
47663
+ return (_a2 = loadingOptions()) == null ? void 0 : _a2.style;
47664
+ }
47665
+ });
47666
+ }
47667
+ }), null);
47668
+ insert(_el$, createComponent(WelcomeOverlay, {
47669
+ get isOpen() {
47670
+ return memo(() => !!(welcomeOpen() && !initialLoading()))() && runtimeReady();
47671
+ },
47672
+ onClose: () => setWelcomeOpen(false)
47673
+ }), null);
47674
+ createRenderEffect((_p$) => {
47675
+ var _v$ = !!useComposedShell(), _v$2 = !!isReadOnly();
47676
+ _v$ !== _p$.e && _el$.classList.toggle("oasis-editor-docs", _p$.e = _v$);
47677
+ _v$2 !== _p$.t && _el$.classList.toggle("oasis-editor-read-only", _p$.t = _v$2);
47678
+ return _p$;
47679
+ }, {
47680
+ e: void 0,
47681
+ t: void 0
47682
+ });
47683
+ return _el$;
47684
+ }
47685
+ });
47390
47686
  }
47391
47687
  export {
47392
47688
  OasisEditorApp