oasis-editor 0.0.89 → 0.0.90

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.
@@ -2519,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
2519
2519
  onCleanup(() => {
2520
2520
  cancelled = true;
2521
2521
  });
2522
- import("./OasisEditorApp-cKm4OFIF.js").then((m) => {
2522
+ import("./OasisEditorApp-2b7y3aGj.js").then((m) => {
2523
2523
  cancelled = true;
2524
2524
  setProgress(1);
2525
2525
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -3110,6 +3110,16 @@ const DEFAULT_TEXT_STYLE = asRequired({
3110
3110
  noProof: false,
3111
3111
  webHidden: false,
3112
3112
  specVanish: false,
3113
+ rtl: false,
3114
+ complexScript: false,
3115
+ snapToGrid: true,
3116
+ fitText: null,
3117
+ emphasisMark: null,
3118
+ textBorder: null,
3119
+ outline: false,
3120
+ shadow: false,
3121
+ emboss: false,
3122
+ imprint: false,
3113
3123
  textEffect: null,
3114
3124
  characterScale: null,
3115
3125
  characterSpacing: null,
@@ -20568,6 +20578,36 @@ function underlineStyleDashArray(underlineStyle) {
20568
20578
  return void 0;
20569
20579
  }
20570
20580
  }
20581
+ function drawEdge(ctx, border, x1, y1, x2, y2) {
20582
+ if (!border || border.type === "none" || border.width <= 0) {
20583
+ return;
20584
+ }
20585
+ ctx.save();
20586
+ ctx.beginPath();
20587
+ ctx.strokeStyle = border.color;
20588
+ ctx.lineWidth = border.width;
20589
+ if (border.type === "dashed") {
20590
+ ctx.setLineDash([5, 3]);
20591
+ } else if (border.type === "dotted") {
20592
+ ctx.setLineDash([1, 3]);
20593
+ } else {
20594
+ ctx.setLineDash([]);
20595
+ }
20596
+ ctx.moveTo(x1, y1);
20597
+ ctx.lineTo(x2, y2);
20598
+ ctx.stroke();
20599
+ ctx.restore();
20600
+ }
20601
+ function drawBorderBox(ctx, left, top, width, height, borders) {
20602
+ const right = left + width;
20603
+ const bottom = top + height;
20604
+ drawEdge(ctx, borders.top, left, top, right, top);
20605
+ drawEdge(ctx, borders.right, right, top, right, bottom);
20606
+ drawEdge(ctx, borders.bottom, left, bottom, right, bottom);
20607
+ drawEdge(ctx, borders.left, left, top, left, bottom);
20608
+ drawEdge(ctx, borders.topLeftToBottomRight, left, top, right, bottom);
20609
+ drawEdge(ctx, borders.topRightToBottomLeft, right, top, left, bottom);
20610
+ }
20571
20611
  const canvasTextLogger = createEditorLogger("canvas-text");
20572
20612
  const loggedCanvasFontKeys = /* @__PURE__ */ new Set();
20573
20613
  const MAX_CANVAS_FONT_LOGS = 40;
@@ -20824,6 +20864,16 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
20824
20864
  styles.highlight
20825
20865
  );
20826
20866
  }
20867
+ if (styles.textBorder) {
20868
+ drawFragmentBorder(
20869
+ ctx,
20870
+ line,
20871
+ fragment,
20872
+ originX,
20873
+ originY,
20874
+ styles.textBorder
20875
+ );
20876
+ }
20827
20877
  if (fragment.image && !fragment.image.floating) {
20828
20878
  const slot = slotByOffset.get(fragment.startOffset);
20829
20879
  if (slot) {
@@ -20898,6 +20948,18 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
20898
20948
  "doubleStrike"
20899
20949
  );
20900
20950
  }
20951
+ if (styles.emphasisMark) {
20952
+ drawFragmentEmphasis(
20953
+ ctx,
20954
+ line,
20955
+ fragment,
20956
+ slotByOffset,
20957
+ originX,
20958
+ originY,
20959
+ styles.emphasisMark,
20960
+ styles.color ?? "#000000"
20961
+ );
20962
+ }
20901
20963
  ctx.restore();
20902
20964
  }
20903
20965
  const isLastLine = line.index === lines.length - 1;
@@ -20977,6 +21039,82 @@ function drawScaledText(ctx, text, x, y, scale) {
20977
21039
  ctx.fillText(text, 0, 0);
20978
21040
  ctx.restore();
20979
21041
  }
21042
+ function drawStyledText(ctx, text, x, y, scale, styles) {
21043
+ if (!styles.outline && !styles.shadow && !styles.emboss && !styles.imprint) {
21044
+ drawScaledText(ctx, text, x, y, scale);
21045
+ return;
21046
+ }
21047
+ if (styles.emboss || styles.imprint) {
21048
+ const offset = styles.imprint ? 1 : -1;
21049
+ ctx.save();
21050
+ ctx.shadowColor = "transparent";
21051
+ ctx.fillStyle = "rgba(255,255,255,0.75)";
21052
+ drawScaledText(ctx, text, x + offset, y + offset, scale);
21053
+ ctx.restore();
21054
+ }
21055
+ ctx.save();
21056
+ if (styles.shadow) {
21057
+ ctx.shadowColor = "rgba(0,0,0,0.45)";
21058
+ ctx.shadowOffsetX = 1;
21059
+ ctx.shadowOffsetY = 1;
21060
+ ctx.shadowBlur = 1;
21061
+ }
21062
+ if (styles.outline) {
21063
+ ctx.strokeStyle = ctx.fillStyle;
21064
+ ctx.lineWidth = 0.75;
21065
+ if (scale === 1) {
21066
+ ctx.strokeText(text, x, y);
21067
+ } else {
21068
+ ctx.translate(x, y);
21069
+ ctx.scale(scale, 1);
21070
+ ctx.strokeText(text, 0, 0);
21071
+ }
21072
+ } else {
21073
+ drawScaledText(ctx, text, x, y, scale);
21074
+ }
21075
+ ctx.restore();
21076
+ }
21077
+ function drawFragmentBorder(ctx, line, fragment, originX, originY, border) {
21078
+ if (border.type === "none" || border.width <= 0) return;
21079
+ const bounds = resolveFragmentPaintBounds(line, fragment);
21080
+ if (!bounds) return;
21081
+ const edge = { ...border, width: Math.max(0.5, border.width * PX_PER_POINT) };
21082
+ drawBorderBox(
21083
+ ctx,
21084
+ originX + bounds.left,
21085
+ originY + line.top + 1,
21086
+ Math.max(0, bounds.right - bounds.left),
21087
+ Math.max(2, line.height - 2),
21088
+ { top: edge, right: edge, bottom: edge, left: edge }
21089
+ );
21090
+ }
21091
+ const EMPHASIS_GLYPH = {
21092
+ dot: "•",
21093
+ comma: "‚",
21094
+ circle: "○",
21095
+ underDot: "•"
21096
+ };
21097
+ function drawFragmentEmphasis(ctx, line, fragment, slotByOffset, originX, originY, mark, color) {
21098
+ if (mark === "none") return;
21099
+ const glyph = EMPHASIS_GLYPH[mark];
21100
+ if (!glyph) return;
21101
+ const below = mark === "underDot";
21102
+ const y = below ? originY + line.top + line.height + 1 : originY + line.top + 2;
21103
+ ctx.save();
21104
+ ctx.fillStyle = color;
21105
+ ctx.textAlign = "center";
21106
+ ctx.textBaseline = below ? "top" : "bottom";
21107
+ ctx.font = `400 ${Math.max(6, line.height * 0.35)}px Calibri`;
21108
+ for (const char of fragment.chars) {
21109
+ if (char.char === "\n" || char.char === " " || char.char === " ") continue;
21110
+ const slot = slotByOffset.get(char.paragraphOffset);
21111
+ const nextSlot = slotByOffset.get(char.paragraphOffset + 1);
21112
+ if (!slot) continue;
21113
+ const centerX = nextSlot ? (slot.left + nextSlot.left) / 2 : slot.left + line.height * 0.25;
21114
+ ctx.fillText(glyph, originX + centerX, y);
21115
+ }
21116
+ ctx.restore();
21117
+ }
20980
21118
  function drawTextFragment(ctx, paragraph, line, fragment, slotByOffset, state, styles, originX, baselineY) {
20981
21119
  const scale = styles.characterScale && styles.characterScale > 0 ? styles.characterScale / 100 : 1;
20982
21120
  const hasManualCharacterSpacing = styles.characterSpacing !== void 0 && styles.characterSpacing !== null && styles.characterSpacing !== 0;
@@ -20988,7 +21126,14 @@ function drawTextFragment(ctx, paragraph, line, fragment, slotByOffset, state, s
20988
21126
  segmentLeft = null;
20989
21127
  return;
20990
21128
  }
20991
- drawScaledText(ctx, segmentText, originX + segmentLeft, baselineY, scale);
21129
+ drawStyledText(
21130
+ ctx,
21131
+ segmentText,
21132
+ originX + segmentLeft,
21133
+ baselineY,
21134
+ scale,
21135
+ styles
21136
+ );
20992
21137
  segmentText = "";
20993
21138
  segmentLeft = null;
20994
21139
  };
@@ -21020,7 +21165,14 @@ function drawTextFragment(ctx, paragraph, line, fragment, slotByOffset, state, s
21020
21165
  const renderedChar = getRenderedChar(char.char, styles);
21021
21166
  if (hasManualCharacterSpacing) {
21022
21167
  flushSegment();
21023
- drawScaledText(ctx, renderedChar, originX + slot.left, baselineY, scale);
21168
+ drawStyledText(
21169
+ ctx,
21170
+ renderedChar,
21171
+ originX + slot.left,
21172
+ baselineY,
21173
+ scale,
21174
+ styles
21175
+ );
21024
21176
  continue;
21025
21177
  }
21026
21178
  if (char.char === " ") {
@@ -21105,36 +21257,6 @@ function drawWavyLine(ctx, x1, x2, y) {
21105
21257
  }
21106
21258
  ctx.stroke();
21107
21259
  }
21108
- function drawEdge(ctx, border, x1, y1, x2, y2) {
21109
- if (!border || border.type === "none" || border.width <= 0) {
21110
- return;
21111
- }
21112
- ctx.save();
21113
- ctx.beginPath();
21114
- ctx.strokeStyle = border.color;
21115
- ctx.lineWidth = border.width;
21116
- if (border.type === "dashed") {
21117
- ctx.setLineDash([5, 3]);
21118
- } else if (border.type === "dotted") {
21119
- ctx.setLineDash([1, 3]);
21120
- } else {
21121
- ctx.setLineDash([]);
21122
- }
21123
- ctx.moveTo(x1, y1);
21124
- ctx.lineTo(x2, y2);
21125
- ctx.stroke();
21126
- ctx.restore();
21127
- }
21128
- function drawBorderBox(ctx, left, top, width, height, borders) {
21129
- const right = left + width;
21130
- const bottom = top + height;
21131
- drawEdge(ctx, borders.top, left, top, right, top);
21132
- drawEdge(ctx, borders.right, right, top, right, bottom);
21133
- drawEdge(ctx, borders.bottom, left, bottom, right, bottom);
21134
- drawEdge(ctx, borders.left, left, top, left, bottom);
21135
- drawEdge(ctx, borders.topLeftToBottomRight, left, top, right, bottom);
21136
- drawEdge(ctx, borders.topRightToBottomLeft, right, top, left, bottom);
21137
- }
21138
21260
  const __vite_import_meta_env__ = { "DEV": false };
21139
21261
  function drawVerticalCell(ctx, cell, state, pageIndex, onUpdate, painters) {
21140
21262
  const box = {
@@ -32538,6 +32660,66 @@ function parseParagraphList(paragraphProperties, numberingMaps) {
32538
32660
  indent: effective.indent
32539
32661
  };
32540
32662
  }
32663
+ function parseDocxBorder(borderNode) {
32664
+ if (!borderNode) {
32665
+ return void 0;
32666
+ }
32667
+ const value = getAttributeValue(borderNode, "val");
32668
+ if (value === "nil" || value === "none") {
32669
+ return { width: 0, type: "none", color: "transparent" };
32670
+ }
32671
+ const size = Number(getAttributeValue(borderNode, "sz"));
32672
+ const width = Number.isFinite(size) && size > 0 ? Math.round(size / 8 * 1e4) / 1e4 : 0.75;
32673
+ const color = normalizeImportedHexColor(getAttributeValue(borderNode, "color")) ?? "#000000";
32674
+ const normalizedValue = (value == null ? void 0 : value.toLowerCase()) ?? "single";
32675
+ const type = normalizedValue.includes("dotted") || normalizedValue.includes("dot") ? "dotted" : normalizedValue.includes("dash") ? "dashed" : "solid";
32676
+ return { width, type, color };
32677
+ }
32678
+ function parseDocxBoxBorders(container) {
32679
+ if (!container) {
32680
+ return {};
32681
+ }
32682
+ return {
32683
+ borderTop: parseDocxBorder(
32684
+ getFirstChildByTagNameNS(container, WORD_NS, "top")
32685
+ ),
32686
+ borderRight: parseDocxBorder(
32687
+ getFirstChildByTagNameNS(container, WORD_NS, "right")
32688
+ ),
32689
+ borderBottom: parseDocxBorder(
32690
+ getFirstChildByTagNameNS(container, WORD_NS, "bottom")
32691
+ ),
32692
+ borderLeft: parseDocxBorder(
32693
+ getFirstChildByTagNameNS(container, WORD_NS, "left")
32694
+ ),
32695
+ borderStart: parseDocxBorder(
32696
+ getFirstChildByTagNameNS(container, WORD_NS, "start")
32697
+ ),
32698
+ borderEnd: parseDocxBorder(
32699
+ getFirstChildByTagNameNS(container, WORD_NS, "end")
32700
+ ),
32701
+ borderTopLeftToBottomRight: parseDocxBorder(
32702
+ getFirstChildByTagNameNS(container, WORD_NS, "tl2br")
32703
+ ),
32704
+ borderTopRightToBottomLeft: parseDocxBorder(
32705
+ getFirstChildByTagNameNS(container, WORD_NS, "tr2bl")
32706
+ )
32707
+ };
32708
+ }
32709
+ function parseDocxTableBorders(container) {
32710
+ if (!container) {
32711
+ return {};
32712
+ }
32713
+ return {
32714
+ ...parseDocxBoxBorders(container),
32715
+ borderInsideH: parseDocxBorder(
32716
+ getFirstChildByTagNameNS(container, WORD_NS, "insideH")
32717
+ ),
32718
+ borderInsideV: parseDocxBorder(
32719
+ getFirstChildByTagNameNS(container, WORD_NS, "insideV")
32720
+ )
32721
+ };
32722
+ }
32541
32723
  function stripUndefined(value) {
32542
32724
  const entries2 = Object.entries(value).filter(([, v]) => v !== void 0);
32543
32725
  return entries2.length > 0 ? Object.fromEntries(entries2) : void 0;
@@ -32606,6 +32788,24 @@ function normalizeImportedRunStyle(style2, paragraphStyleId) {
32606
32788
  effective.specVanish,
32607
32789
  defaultEffective.specVanish
32608
32790
  ),
32791
+ rtl: hd(style2.rtl, effective.rtl, defaultEffective.rtl),
32792
+ complexScript: hd(
32793
+ style2.complexScript,
32794
+ effective.complexScript,
32795
+ defaultEffective.complexScript
32796
+ ),
32797
+ snapToGrid: hd(
32798
+ style2.snapToGrid,
32799
+ effective.snapToGrid,
32800
+ defaultEffective.snapToGrid
32801
+ ),
32802
+ outline: hd(style2.outline, effective.outline, defaultEffective.outline),
32803
+ shadow: hd(style2.shadow, effective.shadow, defaultEffective.shadow),
32804
+ emboss: hd(style2.emboss, effective.emboss, defaultEffective.emboss),
32805
+ imprint: hd(style2.imprint, effective.imprint, defaultEffective.imprint),
32806
+ fitText: dd(effective.fitText, defaultEffective.fitText),
32807
+ emphasisMark: dd(effective.emphasisMark, defaultEffective.emphasisMark),
32808
+ textBorder: dd(effective.textBorder, defaultEffective.textBorder),
32609
32809
  textEffect: dd(effective.textEffect, defaultEffective.textEffect),
32610
32810
  characterScale: dd(
32611
32811
  effective.characterScale,
@@ -32692,6 +32892,57 @@ function parseRunStyle(runProperties, theme) {
32692
32892
  if (specVanish !== void 0) {
32693
32893
  styles.specVanish = specVanish;
32694
32894
  }
32895
+ const rtl = parseOnOffProperty(runProperties, "rtl");
32896
+ if (rtl !== void 0) {
32897
+ styles.rtl = rtl;
32898
+ }
32899
+ const complexScript = parseOnOffProperty(runProperties, "cs");
32900
+ if (complexScript !== void 0) {
32901
+ styles.complexScript = complexScript;
32902
+ }
32903
+ const snapToGrid = parseOnOffProperty(runProperties, "snapToGrid");
32904
+ if (snapToGrid !== void 0) {
32905
+ styles.snapToGrid = snapToGrid;
32906
+ }
32907
+ const outline = parseOnOffProperty(runProperties, "outline");
32908
+ if (outline !== void 0) {
32909
+ styles.outline = outline;
32910
+ }
32911
+ const shadow = parseOnOffProperty(runProperties, "shadow");
32912
+ if (shadow !== void 0) {
32913
+ styles.shadow = shadow;
32914
+ }
32915
+ const emboss = parseOnOffProperty(runProperties, "emboss");
32916
+ if (emboss !== void 0) {
32917
+ styles.emboss = emboss;
32918
+ }
32919
+ const imprint = parseOnOffProperty(runProperties, "imprint");
32920
+ if (imprint !== void 0) {
32921
+ styles.imprint = imprint;
32922
+ }
32923
+ const emphasisMark = getAttributeValue(
32924
+ getFirstChildByTagNameNS(runProperties, WORD_NS, "em"),
32925
+ "val"
32926
+ );
32927
+ if (emphasisMark === "dot" || emphasisMark === "comma" || emphasisMark === "circle" || emphasisMark === "underDot" || emphasisMark === "none") {
32928
+ styles.emphasisMark = emphasisMark;
32929
+ }
32930
+ const fitText = getAttributeValue(
32931
+ getFirstChildByTagNameNS(runProperties, WORD_NS, "fitText"),
32932
+ "val"
32933
+ );
32934
+ if (fitText) {
32935
+ const parsed = twipsToPoints(fitText);
32936
+ if (parsed !== void 0 && parsed > 0) {
32937
+ styles.fitText = parsed;
32938
+ }
32939
+ }
32940
+ const textBorder = parseDocxBorder(
32941
+ getFirstChildByTagNameNS(runProperties, WORD_NS, "bdr")
32942
+ );
32943
+ if (textBorder) {
32944
+ styles.textBorder = textBorder;
32945
+ }
32695
32946
  const textEffect = getAttributeValue(
32696
32947
  getFirstChildByTagNameNS(runProperties, WORD_NS, "effect"),
32697
32948
  "val"
@@ -32862,66 +33113,6 @@ function parseRunStyle(runProperties, theme) {
32862
33113
  }
32863
33114
  return emptyOrUndefined(styles);
32864
33115
  }
32865
- function parseDocxBorder(borderNode) {
32866
- if (!borderNode) {
32867
- return void 0;
32868
- }
32869
- const value = getAttributeValue(borderNode, "val");
32870
- if (value === "nil" || value === "none") {
32871
- return { width: 0, type: "none", color: "transparent" };
32872
- }
32873
- const size = Number(getAttributeValue(borderNode, "sz"));
32874
- const width = Number.isFinite(size) && size > 0 ? Math.round(size / 8 * 1e4) / 1e4 : 0.75;
32875
- const color = normalizeImportedHexColor(getAttributeValue(borderNode, "color")) ?? "#000000";
32876
- const normalizedValue = (value == null ? void 0 : value.toLowerCase()) ?? "single";
32877
- const type = normalizedValue.includes("dotted") || normalizedValue.includes("dot") ? "dotted" : normalizedValue.includes("dash") ? "dashed" : "solid";
32878
- return { width, type, color };
32879
- }
32880
- function parseDocxBoxBorders(container) {
32881
- if (!container) {
32882
- return {};
32883
- }
32884
- return {
32885
- borderTop: parseDocxBorder(
32886
- getFirstChildByTagNameNS(container, WORD_NS, "top")
32887
- ),
32888
- borderRight: parseDocxBorder(
32889
- getFirstChildByTagNameNS(container, WORD_NS, "right")
32890
- ),
32891
- borderBottom: parseDocxBorder(
32892
- getFirstChildByTagNameNS(container, WORD_NS, "bottom")
32893
- ),
32894
- borderLeft: parseDocxBorder(
32895
- getFirstChildByTagNameNS(container, WORD_NS, "left")
32896
- ),
32897
- borderStart: parseDocxBorder(
32898
- getFirstChildByTagNameNS(container, WORD_NS, "start")
32899
- ),
32900
- borderEnd: parseDocxBorder(
32901
- getFirstChildByTagNameNS(container, WORD_NS, "end")
32902
- ),
32903
- borderTopLeftToBottomRight: parseDocxBorder(
32904
- getFirstChildByTagNameNS(container, WORD_NS, "tl2br")
32905
- ),
32906
- borderTopRightToBottomLeft: parseDocxBorder(
32907
- getFirstChildByTagNameNS(container, WORD_NS, "tr2bl")
32908
- )
32909
- };
32910
- }
32911
- function parseDocxTableBorders(container) {
32912
- if (!container) {
32913
- return {};
32914
- }
32915
- return {
32916
- ...parseDocxBoxBorders(container),
32917
- borderInsideH: parseDocxBorder(
32918
- getFirstChildByTagNameNS(container, WORD_NS, "insideH")
32919
- ),
32920
- borderInsideV: parseDocxBorder(
32921
- getFirstChildByTagNameNS(container, WORD_NS, "insideV")
32922
- )
32923
- };
32924
- }
32925
33116
  function normalizeImportedParagraphStyle(style2) {
32926
33117
  if (!style2) {
32927
33118
  return void 0;
@@ -36389,7 +36580,7 @@ function importDocxInWorker(buffer, options = {}) {
36389
36580
  const worker = new Worker(
36390
36581
  new URL(
36391
36582
  /* @vite-ignore */
36392
- "" + new URL("assets/importDocxWorker-DVDyiqYf.js", import.meta.url).href,
36583
+ "" + new URL("assets/importDocxWorker-BN5o1geV.js", import.meta.url).href,
36393
36584
  import.meta.url
36394
36585
  ),
36395
36586
  {
@@ -1,4 +1,4 @@
1
- import { O, c6, c7, c8, c9, ca, a8, cb, Q, bR, cc, cd, ce, N, cf, bP, cg, ch, ci, cj, ck, c1, cl, cm, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, ad, cx, c0, cy, c8 as c82, cd as cd2, cf as cf2, co as co2, cq as cq2, cv as cv2, cz, bT, bO, cA, cB, cC, bQ, cD, cE, bS } from "./index-BICQTKCZ.js";
1
+ import { O, c6, c7, c8, c9, ca, a8, cb, Q, bR, cc, cd, ce, N, cf, bP, cg, ch, ci, cj, ck, c1, cl, cm, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, ad, cx, c0, cy, c8 as c82, cd as cd2, cf as cf2, co as co2, cq as cq2, cv as cv2, cz, bT, bO, cA, cB, cC, bQ, cD, cE, bS } from "./index-DcElQi6c.js";
2
2
  export {
3
3
  O as BalloonShell,
4
4
  c6 as Button,