oasis-editor 0.0.96 → 0.0.97

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.
@@ -6,7 +6,7 @@
6
6
  * statements that pointed there continue to work via the barrel
7
7
  * re-export in `src/core/model.ts`.
8
8
  */
9
- export type { EditorUnderlineStyle, EditorLigatures, EditorNumberSpacing, EditorNumberForm, EditorTextLanguage, EditorBorderStyle, EditorEmphasisMark, EditorTabStop, EditorParagraphListStyle, EditorImageCrop, EditorImageFillMode, EditorImageFloatingPosition, EditorImageFloatingLayout, EditorImageRunData, EditorWrapPolygonPoint, EditorFieldData, EditorFieldChar, EditorFootnoteReferenceData, EditorEndnoteReferenceData, EditorRevision, EditorRevisionMetadata, EditorStructuralRevision, EditorPropertyRevision, EditorAsset, EditorFootnoteNumberFormat, EditorFootnoteRestart, EditorDocxWidthValue, EditorTableLayout, EditorTableRowHeightRule, EditorGradientStop, EditorTextFill, EditorTextOutline, } from './types/primitives.js';
9
+ export type { EditorUnderlineStyle, EditorLigatures, EditorNumberSpacing, EditorNumberForm, EditorTextLanguage, EditorBorderStyle, EditorEmphasisMark, EditorTabStop, EditorParagraphListStyle, EditorImageCrop, EditorImageFillMode, EditorImageFloatingPosition, EditorImageFloatingLayout, EditorImageRunData, EditorWrapPolygonPoint, EditorFieldData, EditorFieldChar, EditorFootnoteReferenceData, EditorEndnoteReferenceData, EditorRevision, EditorRevisionMetadata, EditorStructuralRevision, EditorPropertyRevision, EditorAsset, EditorFootnoteNumberFormat, EditorFootnoteRestart, EditorDocxWidthValue, EditorTableLayout, EditorTableRowHeightRule, EditorGradientStop, EditorTextFill, EditorTextOutline, EditorTextShadow, EditorGlow, EditorReflection, } from './types/primitives.js';
10
10
  export type { EditorTextStyle, EditorParagraphStyle, EditorTableStyle, EditorTableFloatingLayout, EditorTableConditionalFormat, EditorConditionalRowStyle, EditorTableConditionalType, EditorTableConditionalFlags, EditorTableCellStyle, EditorNamedStyle, } from './types/styles.js';
11
11
  export type { EditorRunBase, EditorTextRun, EditorTextBoxShape, EditorTextBoxBody, EditorTextBoxData, EditorDropCap, EditorParagraphNode, EditorTableCellNode, EditorTableRowStyle, EditorTableRowNode, EditorTableNode, EditorBlockNode, } from './types/nodes.js';
12
12
  export type { RunKind, RunOfKind, RunVisitor } from './runKind.js';
@@ -44,6 +44,29 @@ export interface EditorTextOutline {
44
44
  color?: string;
45
45
  fill?: EditorTextFill;
46
46
  }
47
+ /** `w14:shadow` — text shadow with blur, distance, direction, and color. */
48
+ export interface EditorTextShadow {
49
+ color: string;
50
+ alpha?: number;
51
+ blurPt: number;
52
+ distPt: number;
53
+ dirDeg: number;
54
+ }
55
+ /** `w14:glow` — glow halo radiating from glyphs. */
56
+ export interface EditorGlow {
57
+ color: string;
58
+ alpha?: number;
59
+ radiusPt: number;
60
+ }
61
+ /** `w14:reflection` — mirrored copy of glyphs fading below the baseline. */
62
+ export interface EditorReflection {
63
+ blurPt: number;
64
+ startAlpha: number;
65
+ startPos: number;
66
+ endAlpha: number;
67
+ endPos: number;
68
+ distPt: number;
69
+ }
47
70
  export interface EditorTabStop {
48
71
  position: number;
49
72
  type: "left" | "center" | "right" | "decimal" | "bar" | "clear";
@@ -1,4 +1,4 @@
1
- import { EditorBorderStyle, EditorDocxWidthValue, EditorEmphasisMark, EditorLigatures, EditorNumberForm, EditorNumberSpacing, EditorPropertyRevision, EditorStructuralRevision, EditorTabStop, EditorTextFill, EditorTextLanguage, EditorTextOutline, EditorUnderlineStyle } from './primitives.js';
1
+ import { EditorBorderStyle, EditorDocxWidthValue, EditorEmphasisMark, EditorGlow, EditorLigatures, EditorNumberForm, EditorNumberSpacing, EditorPropertyRevision, EditorReflection, EditorStructuralRevision, EditorTabStop, EditorTextFill, EditorTextLanguage, EditorTextOutline, EditorTextShadow, EditorUnderlineStyle } from './primitives.js';
2
2
 
3
3
  export interface EditorTextStyle {
4
4
  styleId?: string;
@@ -54,6 +54,12 @@ export interface EditorTextStyle {
54
54
  textFill?: EditorTextFill | null;
55
55
  /** `w14:textOutline` — real stroke on glyphs, supersedes the boolean `outline` when present. */
56
56
  textOutline?: EditorTextOutline | null;
57
+ /** `w14:shadow` — text shadow with blur, distance, direction, and color. */
58
+ textShadow?: EditorTextShadow | null;
59
+ /** `w14:glow` — glow halo radiating from glyphs. */
60
+ glow?: EditorGlow | null;
61
+ /** `w14:reflection` — mirrored copy of glyphs fading below the baseline. */
62
+ reflection?: EditorReflection | null;
57
63
  highlight?: string | null;
58
64
  shading?: string | null;
59
65
  language?: EditorTextLanguage | null;
@@ -2519,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
2519
2519
  onCleanup(() => {
2520
2520
  cancelled = true;
2521
2521
  });
2522
- import("./OasisEditorApp-CMTq6BTy.js").then((m) => {
2522
+ import("./OasisEditorApp-m8k4gBW1.js").then((m) => {
2523
2523
  cancelled = true;
2524
2524
  setProgress(1);
2525
2525
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -21295,6 +21295,17 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
21295
21295
  originX,
21296
21296
  baselineY + renderMetrics.baselineOffset
21297
21297
  );
21298
+ if (styles.reflection) {
21299
+ drawFragmentReflection(
21300
+ ctx,
21301
+ fragment,
21302
+ slotByOffset,
21303
+ styles,
21304
+ originX,
21305
+ baselineY + renderMetrics.baselineOffset,
21306
+ styles.reflection
21307
+ );
21308
+ }
21298
21309
  }
21299
21310
  if (styles.underline) {
21300
21311
  drawTextDecoration(
@@ -21476,7 +21487,7 @@ function resolveCanvasTextFill(ctx, styles, line, fragment, originX, originY) {
21476
21487
  return gradient;
21477
21488
  }
21478
21489
  function drawStyledText(ctx, text, x, y, scale, styles) {
21479
- const hasEffects = styles.outline || styles.shadow || styles.emboss || styles.imprint || styles.textOutline;
21490
+ const hasEffects = styles.outline || styles.shadow || styles.textShadow || styles.glow || styles.emboss || styles.imprint || styles.textOutline;
21480
21491
  if (!hasEffects) {
21481
21492
  drawScaledText(ctx, text, x, y, scale);
21482
21493
  return;
@@ -21490,7 +21501,29 @@ function drawStyledText(ctx, text, x, y, scale, styles) {
21490
21501
  ctx.restore();
21491
21502
  }
21492
21503
  ctx.save();
21493
- if (styles.shadow) {
21504
+ if (styles.textShadow) {
21505
+ const ts = styles.textShadow;
21506
+ const dirRad = ts.dirDeg * Math.PI / 180;
21507
+ const distPx = ts.distPt * PX_PER_POINT;
21508
+ const alpha = ts.alpha ?? 1;
21509
+ const r = Number.parseInt(ts.color.slice(1, 3), 16);
21510
+ const g2 = Number.parseInt(ts.color.slice(3, 5), 16);
21511
+ const b = Number.parseInt(ts.color.slice(5, 7), 16);
21512
+ ctx.shadowColor = `rgba(${r},${g2},${b},${alpha})`;
21513
+ ctx.shadowBlur = ts.blurPt * PX_PER_POINT;
21514
+ ctx.shadowOffsetX = Math.cos(dirRad) * distPx;
21515
+ ctx.shadowOffsetY = Math.sin(dirRad) * distPx;
21516
+ } else if (styles.glow) {
21517
+ const gl = styles.glow;
21518
+ const alpha = gl.alpha ?? 0.7;
21519
+ const r = Number.parseInt(gl.color.slice(1, 3), 16);
21520
+ const g2 = Number.parseInt(gl.color.slice(3, 5), 16);
21521
+ const b = Number.parseInt(gl.color.slice(5, 7), 16);
21522
+ ctx.shadowColor = `rgba(${r},${g2},${b},${alpha})`;
21523
+ ctx.shadowBlur = gl.radiusPt * PX_PER_POINT;
21524
+ ctx.shadowOffsetX = 0;
21525
+ ctx.shadowOffsetY = 0;
21526
+ } else if (styles.shadow) {
21494
21527
  ctx.shadowColor = "rgba(0,0,0,0.45)";
21495
21528
  ctx.shadowOffsetX = 1;
21496
21529
  ctx.shadowOffsetY = 1;
@@ -21639,6 +21672,39 @@ function drawTextFragment(ctx, paragraph, line, fragment, slotByOffset, state, s
21639
21672
  }
21640
21673
  flushSegment();
21641
21674
  }
21675
+ function drawFragmentReflection(ctx, fragment, slotByOffset, styles, originX, baselineY, reflection) {
21676
+ const firstChar = fragment.chars.find(
21677
+ (c) => c.char !== "\n" && c.char !== " "
21678
+ );
21679
+ if (!firstChar) return;
21680
+ const firstSlot = slotByOffset.get(firstChar.paragraphOffset);
21681
+ if (!firstSlot) return;
21682
+ const text = fragment.chars.filter((c) => c.char !== "\n" && c.char !== " ").map((c) => styles.allCaps ? c.char.toUpperCase() : c.char).join("");
21683
+ if (!text) return;
21684
+ const scale = styles.characterScale && styles.characterScale > 0 ? styles.characterScale / 100 : 1;
21685
+ const avgAlpha = (reflection.startAlpha + reflection.endAlpha) / 2;
21686
+ const distPx = reflection.distPt * PX_PER_POINT;
21687
+ const reflectY = baselineY + distPx;
21688
+ ctx.save();
21689
+ ctx.globalAlpha = (ctx.globalAlpha ?? 1) * avgAlpha;
21690
+ ctx.shadowColor = "transparent";
21691
+ ctx.shadowBlur = 0;
21692
+ ctx.shadowOffsetX = 0;
21693
+ ctx.shadowOffsetY = 0;
21694
+ ctx.translate(0, 2 * reflectY);
21695
+ ctx.scale(1, -1);
21696
+ const x = originX + firstSlot.left;
21697
+ if (scale === 1) {
21698
+ ctx.fillText(text, x, baselineY);
21699
+ } else {
21700
+ ctx.save();
21701
+ ctx.translate(x, baselineY);
21702
+ ctx.scale(scale, 1);
21703
+ ctx.fillText(text, 0, 0);
21704
+ ctx.restore();
21705
+ }
21706
+ ctx.restore();
21707
+ }
21642
21708
  function drawTextDecoration(ctx, line, fragment, originX, originY, kind, underlineStyle, underlineColor) {
21643
21709
  const bounds = resolveFragmentPaintBounds(line, fragment);
21644
21710
  if (!bounds) return;
@@ -33340,6 +33406,61 @@ function parseW14TextFill(fillEl) {
33340
33406
  }
33341
33407
  return null;
33342
33408
  }
33409
+ function parseW14ColorEl(el) {
33410
+ const srgbClr = getFirstChildByTagNameNS(el, WORD14_NS, "srgbClr");
33411
+ if (!srgbClr) return null;
33412
+ const val = getAttributeValue(srgbClr, "val");
33413
+ const color = val ? normalizeImportedHexColor(val) ?? null : null;
33414
+ if (!color) return null;
33415
+ const alphaEl = getFirstChildByTagNameNS(srgbClr, WORD14_NS, "alpha");
33416
+ const alphaRaw = alphaEl ? getAttributeValue(alphaEl, "val") : null;
33417
+ const alpha = alphaRaw !== null && Number.isFinite(Number(alphaRaw)) ? Number(alphaRaw) / 1e5 : void 0;
33418
+ return { color, ...alpha !== void 0 ? { alpha } : {} };
33419
+ }
33420
+ function parseW14Shadow(el) {
33421
+ const colorData = parseW14ColorEl(el);
33422
+ if (!colorData) return null;
33423
+ const blurRaw = el.getAttributeNS(WORD14_NS, "blurRad");
33424
+ const distRaw = el.getAttributeNS(WORD14_NS, "dist");
33425
+ const dirRaw = el.getAttributeNS(WORD14_NS, "dir");
33426
+ const blurPt = blurRaw ? Number(blurRaw) / 12700 : 0;
33427
+ const distPt = distRaw ? Number(distRaw) / 12700 : 0;
33428
+ const dirDeg = dirRaw ? Number(dirRaw) / 6e4 : 0;
33429
+ return {
33430
+ color: colorData.color,
33431
+ ...colorData.alpha !== void 0 ? { alpha: colorData.alpha } : {},
33432
+ blurPt,
33433
+ distPt,
33434
+ dirDeg
33435
+ };
33436
+ }
33437
+ function parseW14Glow(el) {
33438
+ const colorData = parseW14ColorEl(el);
33439
+ if (!colorData) return null;
33440
+ const radRaw = el.getAttributeNS(WORD14_NS, "rad");
33441
+ const radiusPt = radRaw ? Number(radRaw) / 12700 : 0;
33442
+ return {
33443
+ color: colorData.color,
33444
+ ...colorData.alpha !== void 0 ? { alpha: colorData.alpha } : {},
33445
+ radiusPt
33446
+ };
33447
+ }
33448
+ function parseW14Reflection(el) {
33449
+ const blurRaw = el.getAttributeNS(WORD14_NS, "blurRad");
33450
+ const stARaw = el.getAttributeNS(WORD14_NS, "stA");
33451
+ const stPosRaw = el.getAttributeNS(WORD14_NS, "stPos");
33452
+ const endARaw = el.getAttributeNS(WORD14_NS, "endA");
33453
+ const endPosRaw = el.getAttributeNS(WORD14_NS, "endPos");
33454
+ const distRaw = el.getAttributeNS(WORD14_NS, "dist");
33455
+ return {
33456
+ blurPt: blurRaw ? Number(blurRaw) / 12700 : 0,
33457
+ startAlpha: stARaw !== null ? Number(stARaw) / 1e5 : 0.55,
33458
+ startPos: stPosRaw !== null ? Number(stPosRaw) / 1e5 : 0,
33459
+ endAlpha: endARaw !== null ? Number(endARaw) / 1e5 : 0,
33460
+ endPos: endPosRaw !== null ? Number(endPosRaw) / 1e5 : 1,
33461
+ distPt: distRaw ? Number(distRaw) / 12700 : 0
33462
+ };
33463
+ }
33343
33464
  function normalizeImportedRunStyle(style2, paragraphStyleId) {
33344
33465
  if (!style2) {
33345
33466
  return void 0;
@@ -33444,6 +33565,9 @@ function normalizeImportedRunStyle(style2, paragraphStyleId) {
33444
33565
  color: dd(effective.color, defaultEffective.color),
33445
33566
  textFill: dd(effective.textFill, defaultEffective.textFill),
33446
33567
  textOutline: dd(effective.textOutline, defaultEffective.textOutline),
33568
+ textShadow: dd(effective.textShadow, defaultEffective.textShadow),
33569
+ glow: dd(effective.glow, defaultEffective.glow),
33570
+ reflection: dd(effective.reflection, defaultEffective.reflection),
33447
33571
  highlight: dd(effective.highlight, defaultEffective.highlight),
33448
33572
  shading: dd(effective.shading, defaultEffective.shading),
33449
33573
  language: dd(effective.language, defaultEffective.language),
@@ -33715,6 +33839,20 @@ function parseRunStyle(runProperties, theme) {
33715
33839
  }
33716
33840
  styles.textOutline = textOutline;
33717
33841
  }
33842
+ const shadowEl = getFirstW14Child(runProperties, "shadow");
33843
+ if (shadowEl) {
33844
+ const textShadow = parseW14Shadow(shadowEl);
33845
+ if (textShadow) styles.textShadow = textShadow;
33846
+ }
33847
+ const glowEl = getFirstW14Child(runProperties, "glow");
33848
+ if (glowEl) {
33849
+ const glow = parseW14Glow(glowEl);
33850
+ if (glow) styles.glow = glow;
33851
+ }
33852
+ const reflectionEl = getFirstW14Child(runProperties, "reflection");
33853
+ if (reflectionEl) {
33854
+ styles.reflection = parseW14Reflection(reflectionEl);
33855
+ }
33718
33856
  const highlight = getFirstChildByTagNameNS(
33719
33857
  runProperties,
33720
33858
  WORD_NS,
@@ -37288,7 +37426,7 @@ function importDocxInWorker(buffer, options = {}) {
37288
37426
  const worker = new Worker(
37289
37427
  new URL(
37290
37428
  /* @vite-ignore */
37291
- "" + new URL("assets/importDocxWorker-M34STPYy.js", import.meta.url).href,
37429
+ "" + new URL("assets/importDocxWorker-BV6LezJZ.js", import.meta.url).href,
37292
37430
  import.meta.url
37293
37431
  ),
37294
37432
  {
@@ -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-D0bOD23M.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-BiTnt_yD.js";
2
2
  export {
3
3
  O as BalloonShell,
4
4
  c6 as Button,