oasis-editor 0.0.95 → 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.
- package/dist/{OasisEditorApp-C_Ao4zIF.js → OasisEditorApp-m8k4gBW1.js} +146 -8
- package/dist/assets/{importDocxWorker-DAbfLHtp.js → importDocxWorker-BV6LezJZ.js} +1 -1
- package/dist/core/model/index.d.ts +1 -1
- package/dist/core/model/types/primitives.d.ts +47 -0
- package/dist/core/model/types/styles.d.ts +11 -1
- package/dist/export/pdf/writer/pdfTypes.d.ts +4 -0
- package/dist/import/docx/xmlHelpers.d.ts +8 -0
- package/dist/{index-BQEtsRa0.js → index-BiTnt_yD.js} +295 -6
- package/dist/oasis-editor.js +1 -1
- package/dist/oasis-editor.umd.cjs +4 -4
- package/package.json +1 -1
|
@@ -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, } 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';
|
|
@@ -20,6 +20,53 @@ export interface EditorBorderStyle {
|
|
|
20
20
|
}
|
|
21
21
|
/** `w:em/@w:val`: the emphasis mark drawn over each glyph of a run. */
|
|
22
22
|
export type EditorEmphasisMark = "dot" | "comma" | "circle" | "underDot" | "none";
|
|
23
|
+
/** One color stop in a `w14:gradFill` gradient. `position` is 0–1 (0 = start, 1 = end). */
|
|
24
|
+
export interface EditorGradientStop {
|
|
25
|
+
position: number;
|
|
26
|
+
color: string;
|
|
27
|
+
alpha?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `w14:textFill` — rich glyph fill that supersedes the plain `w:color`.
|
|
31
|
+
* Phase 2b: gradient canvas/PDF rendering is deferred; only solid is fully rendered now.
|
|
32
|
+
*/
|
|
33
|
+
export type EditorTextFill = {
|
|
34
|
+
type: "solid";
|
|
35
|
+
color: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "gradient";
|
|
38
|
+
stops: EditorGradientStop[];
|
|
39
|
+
angle?: number;
|
|
40
|
+
};
|
|
41
|
+
/** `w14:textOutline` — real stroke on glyphs, supersedes the legacy boolean `w:outline`. */
|
|
42
|
+
export interface EditorTextOutline {
|
|
43
|
+
widthPt: number;
|
|
44
|
+
color?: string;
|
|
45
|
+
fill?: EditorTextFill;
|
|
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
|
+
}
|
|
23
70
|
export interface EditorTabStop {
|
|
24
71
|
position: number;
|
|
25
72
|
type: "left" | "center" | "right" | "decimal" | "bar" | "clear";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorBorderStyle, EditorDocxWidthValue, EditorEmphasisMark, EditorLigatures, EditorNumberForm, EditorNumberSpacing, EditorPropertyRevision, EditorStructuralRevision, EditorTabStop, EditorTextLanguage, 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;
|
|
@@ -50,6 +50,16 @@ export interface EditorTextStyle {
|
|
|
50
50
|
fontFamily?: string | null;
|
|
51
51
|
fontSize?: number | null;
|
|
52
52
|
color?: string | null;
|
|
53
|
+
/** `w14:textFill` — supersedes `color` when present (solid or gradient glyph fill). */
|
|
54
|
+
textFill?: EditorTextFill | null;
|
|
55
|
+
/** `w14:textOutline` — real stroke on glyphs, supersedes the boolean `outline` when present. */
|
|
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;
|
|
53
63
|
highlight?: string | null;
|
|
54
64
|
shading?: string | null;
|
|
55
65
|
language?: EditorTextLanguage | null;
|
|
@@ -69,6 +69,10 @@ export interface OasisPdfTextOptions {
|
|
|
69
69
|
horizontalScale?: number;
|
|
70
70
|
/** PDF text render mode (`Tr`): 0 fill (default), 1 stroke, 2 fill+stroke. */
|
|
71
71
|
renderMode?: number;
|
|
72
|
+
/** Stroke color for render modes 1 (stroke) and 2 (fill+stroke). Defaults to `color`. */
|
|
73
|
+
strokeColor?: string;
|
|
74
|
+
/** Stroke line width in pt for render modes 1 and 2. Defaults to 3% of fontSize. */
|
|
75
|
+
strokeWidth?: number;
|
|
72
76
|
}
|
|
73
77
|
export interface OasisPdfImageResource {
|
|
74
78
|
resourceName: string;
|
|
@@ -9,6 +9,14 @@ export type DocxTextDirection = "lrTb" | "tbRl" | "btLr" | "lrTbV" | "tbRlV";
|
|
|
9
9
|
/** Validate a raw `w:textDirection/@w:val` token, or return undefined. */
|
|
10
10
|
export declare function parseTextDirection(value: string | null | undefined): DocxTextDirection | undefined;
|
|
11
11
|
export declare function getFirstChildByTagNameNS(element: XmlElement | null | undefined, namespace: string, localName: string): XmlElement | null;
|
|
12
|
+
/**
|
|
13
|
+
* Finds a direct `w14:localName` child of `element`, also searching inside
|
|
14
|
+
* `mc:AlternateContent/mc:Choice` branches (which carry w14 markup in files
|
|
15
|
+
* produced by modern Word). The `mc:Fallback` branch used by
|
|
16
|
+
* `getChildrenByTagNameNS` would not contain w14 elements, so a separate
|
|
17
|
+
* helper is needed for these extension elements.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getFirstW14Child(element: XmlElement | null | undefined, localName: string): XmlElement | null;
|
|
12
20
|
export declare function getAttributeValue(element: XmlElement | null, localName: string): string | null;
|
|
13
21
|
export declare function findElementDeep(element: XmlElement, localName: string): XmlElement | null;
|
|
14
22
|
/**
|
|
@@ -2519,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
|
|
|
2519
2519
|
onCleanup(() => {
|
|
2520
2520
|
cancelled = true;
|
|
2521
2521
|
});
|
|
2522
|
-
import("./OasisEditorApp-
|
|
2522
|
+
import("./OasisEditorApp-m8k4gBW1.js").then((m) => {
|
|
2523
2523
|
cancelled = true;
|
|
2524
2524
|
setProgress(1);
|
|
2525
2525
|
setTimeout(() => setApp(() => m.OasisEditorApp), 180);
|
|
@@ -21209,7 +21209,14 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
|
|
|
21209
21209
|
italic: Boolean(styles.italic),
|
|
21210
21210
|
sample: fragment.text.slice(0, 80)
|
|
21211
21211
|
});
|
|
21212
|
-
ctx.fillStyle =
|
|
21212
|
+
ctx.fillStyle = resolveCanvasTextFill(
|
|
21213
|
+
ctx,
|
|
21214
|
+
styles,
|
|
21215
|
+
line,
|
|
21216
|
+
fragment,
|
|
21217
|
+
originX,
|
|
21218
|
+
originY
|
|
21219
|
+
);
|
|
21213
21220
|
if (styles.shading) {
|
|
21214
21221
|
drawFragmentShading(
|
|
21215
21222
|
ctx,
|
|
@@ -21288,6 +21295,17 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
|
|
|
21288
21295
|
originX,
|
|
21289
21296
|
baselineY + renderMetrics.baselineOffset
|
|
21290
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
|
+
}
|
|
21291
21309
|
}
|
|
21292
21310
|
if (styles.underline) {
|
|
21293
21311
|
drawTextDecoration(
|
|
@@ -21441,8 +21459,36 @@ function drawScaledText(ctx, text, x, y, scale) {
|
|
|
21441
21459
|
ctx.fillText(text, 0, 0);
|
|
21442
21460
|
ctx.restore();
|
|
21443
21461
|
}
|
|
21462
|
+
function resolveCanvasTextFill(ctx, styles, line, fragment, originX, originY) {
|
|
21463
|
+
const fill = styles.textFill;
|
|
21464
|
+
if (!fill) return styles.color ?? "#000000";
|
|
21465
|
+
if (fill.type === "solid") return fill.color;
|
|
21466
|
+
if (fill.stops.length < 2) return styles.color ?? "#000000";
|
|
21467
|
+
const bounds = resolveFragmentPaintBounds(line, fragment);
|
|
21468
|
+
if (!bounds) return fill.stops[0].color;
|
|
21469
|
+
const x0 = originX + bounds.left;
|
|
21470
|
+
const x1 = originX + bounds.right;
|
|
21471
|
+
const y0 = originY + line.top;
|
|
21472
|
+
const y1 = originY + line.top + line.height;
|
|
21473
|
+
const cx = (x0 + x1) / 2;
|
|
21474
|
+
const cy = (y0 + y1) / 2;
|
|
21475
|
+
const angleDeg = fill.angle ?? 0;
|
|
21476
|
+
const rad = angleDeg * Math.PI / 180;
|
|
21477
|
+
const dx = Math.cos(rad) * (x1 - x0) / 2;
|
|
21478
|
+
const dy = Math.sin(rad) * (y1 - y0) / 2;
|
|
21479
|
+
const gradient = ctx.createLinearGradient(cx - dx, cy - dy, cx + dx, cy + dy);
|
|
21480
|
+
for (const stop of fill.stops) {
|
|
21481
|
+
const alpha = stop.alpha ?? 1;
|
|
21482
|
+
const r = Number.parseInt(stop.color.slice(1, 3), 16);
|
|
21483
|
+
const g2 = Number.parseInt(stop.color.slice(3, 5), 16);
|
|
21484
|
+
const b = Number.parseInt(stop.color.slice(5, 7), 16);
|
|
21485
|
+
gradient.addColorStop(stop.position, `rgba(${r},${g2},${b},${alpha})`);
|
|
21486
|
+
}
|
|
21487
|
+
return gradient;
|
|
21488
|
+
}
|
|
21444
21489
|
function drawStyledText(ctx, text, x, y, scale, styles) {
|
|
21445
|
-
|
|
21490
|
+
const hasEffects = styles.outline || styles.shadow || styles.textShadow || styles.glow || styles.emboss || styles.imprint || styles.textOutline;
|
|
21491
|
+
if (!hasEffects) {
|
|
21446
21492
|
drawScaledText(ctx, text, x, y, scale);
|
|
21447
21493
|
return;
|
|
21448
21494
|
}
|
|
@@ -21455,13 +21501,48 @@ function drawStyledText(ctx, text, x, y, scale, styles) {
|
|
|
21455
21501
|
ctx.restore();
|
|
21456
21502
|
}
|
|
21457
21503
|
ctx.save();
|
|
21458
|
-
if (styles.
|
|
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) {
|
|
21459
21527
|
ctx.shadowColor = "rgba(0,0,0,0.45)";
|
|
21460
21528
|
ctx.shadowOffsetX = 1;
|
|
21461
21529
|
ctx.shadowOffsetY = 1;
|
|
21462
21530
|
ctx.shadowBlur = 1;
|
|
21463
21531
|
}
|
|
21464
|
-
if (styles.
|
|
21532
|
+
if (styles.textOutline) {
|
|
21533
|
+
ctx.strokeStyle = styles.textOutline.color ?? ctx.fillStyle;
|
|
21534
|
+
ctx.lineWidth = styles.textOutline.widthPt * PX_PER_POINT;
|
|
21535
|
+
drawScaledText(ctx, text, x, y, scale);
|
|
21536
|
+
if (scale === 1) {
|
|
21537
|
+
ctx.strokeText(text, x, y);
|
|
21538
|
+
} else {
|
|
21539
|
+
ctx.save();
|
|
21540
|
+
ctx.translate(x, y);
|
|
21541
|
+
ctx.scale(scale, 1);
|
|
21542
|
+
ctx.strokeText(text, 0, 0);
|
|
21543
|
+
ctx.restore();
|
|
21544
|
+
}
|
|
21545
|
+
} else if (styles.outline) {
|
|
21465
21546
|
ctx.strokeStyle = ctx.fillStyle;
|
|
21466
21547
|
ctx.lineWidth = 0.75;
|
|
21467
21548
|
if (scale === 1) {
|
|
@@ -21591,6 +21672,39 @@ function drawTextFragment(ctx, paragraph, line, fragment, slotByOffset, state, s
|
|
|
21591
21672
|
}
|
|
21592
21673
|
flushSegment();
|
|
21593
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
|
+
}
|
|
21594
21708
|
function drawTextDecoration(ctx, line, fragment, originX, originY, kind, underlineStyle, underlineColor) {
|
|
21595
21709
|
const bounds = resolveFragmentPaintBounds(line, fragment);
|
|
21596
21710
|
if (!bounds) return;
|
|
@@ -32507,6 +32621,35 @@ function parseTextDirection(value) {
|
|
|
32507
32621
|
function getFirstChildByTagNameNS(element, namespace, localName) {
|
|
32508
32622
|
return getChildrenByTagNameNS(element, namespace, localName)[0] ?? null;
|
|
32509
32623
|
}
|
|
32624
|
+
function getFirstW14Child(element, localName) {
|
|
32625
|
+
if (!element) return null;
|
|
32626
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
32627
|
+
const node = element.childNodes[i];
|
|
32628
|
+
if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) continue;
|
|
32629
|
+
const el = node;
|
|
32630
|
+
if (el.namespaceURI === WORD14_NS && el.localName === localName) {
|
|
32631
|
+
return el;
|
|
32632
|
+
}
|
|
32633
|
+
if (el.namespaceURI === MARKUP_COMPAT_NS && el.localName === "AlternateContent") {
|
|
32634
|
+
for (let j = 0; j < el.childNodes.length; j++) {
|
|
32635
|
+
const child = el.childNodes[j];
|
|
32636
|
+
if ((child == null ? void 0 : child.nodeType) !== child.ELEMENT_NODE) continue;
|
|
32637
|
+
const choiceEl = child;
|
|
32638
|
+
if (choiceEl.namespaceURI === MARKUP_COMPAT_NS && choiceEl.localName === "Choice") {
|
|
32639
|
+
for (let k = 0; k < choiceEl.childNodes.length; k++) {
|
|
32640
|
+
const gc = choiceEl.childNodes[k];
|
|
32641
|
+
if ((gc == null ? void 0 : gc.nodeType) !== gc.ELEMENT_NODE) continue;
|
|
32642
|
+
const gcEl = gc;
|
|
32643
|
+
if (gcEl.namespaceURI === WORD14_NS && gcEl.localName === localName) {
|
|
32644
|
+
return gcEl;
|
|
32645
|
+
}
|
|
32646
|
+
}
|
|
32647
|
+
}
|
|
32648
|
+
}
|
|
32649
|
+
}
|
|
32650
|
+
}
|
|
32651
|
+
return null;
|
|
32652
|
+
}
|
|
32510
32653
|
function getAttributeValue(element, localName) {
|
|
32511
32654
|
if (!element) {
|
|
32512
32655
|
return null;
|
|
@@ -33213,6 +33356,111 @@ function mergeStyles(base, local) {
|
|
|
33213
33356
|
function parseShdFill(element) {
|
|
33214
33357
|
return normalizeImportedHexColor(getAttributeValue(element, "fill"));
|
|
33215
33358
|
}
|
|
33359
|
+
function parseW14SolidFillColor(solidFillEl) {
|
|
33360
|
+
const srgbClr = getFirstChildByTagNameNS(solidFillEl, WORD14_NS, "srgbClr");
|
|
33361
|
+
if (!srgbClr) return null;
|
|
33362
|
+
const val = getAttributeValue(srgbClr, "val");
|
|
33363
|
+
return val ? normalizeImportedHexColor(val) ?? null : null;
|
|
33364
|
+
}
|
|
33365
|
+
function parseW14TextFill(fillEl) {
|
|
33366
|
+
const solidFill = getFirstChildByTagNameNS(fillEl, WORD14_NS, "solidFill");
|
|
33367
|
+
if (solidFill) {
|
|
33368
|
+
const color = parseW14SolidFillColor(solidFill);
|
|
33369
|
+
if (color) return { type: "solid", color };
|
|
33370
|
+
}
|
|
33371
|
+
const gradFill = getFirstChildByTagNameNS(fillEl, WORD14_NS, "gradFill");
|
|
33372
|
+
if (gradFill) {
|
|
33373
|
+
const gsLst = getFirstChildByTagNameNS(gradFill, WORD14_NS, "gsLst");
|
|
33374
|
+
if (gsLst) {
|
|
33375
|
+
const stops = [];
|
|
33376
|
+
for (let i = 0; i < gsLst.childNodes.length; i++) {
|
|
33377
|
+
const node = gsLst.childNodes[i];
|
|
33378
|
+
if ((node == null ? void 0 : node.nodeType) !== node.ELEMENT_NODE) continue;
|
|
33379
|
+
const gs = node;
|
|
33380
|
+
if (gs.namespaceURI !== WORD14_NS || gs.localName !== "gs") continue;
|
|
33381
|
+
const posVal = getAttributeValue(gs, "pos");
|
|
33382
|
+
const pos = posVal !== null ? Number(posVal) / 1e5 : NaN;
|
|
33383
|
+
if (!Number.isFinite(pos)) continue;
|
|
33384
|
+
const srgbClr = getFirstChildByTagNameNS(gs, WORD14_NS, "srgbClr");
|
|
33385
|
+
if (!srgbClr) continue;
|
|
33386
|
+
const colorVal = getAttributeValue(srgbClr, "val");
|
|
33387
|
+
if (!colorVal) continue;
|
|
33388
|
+
const color = normalizeImportedHexColor(colorVal);
|
|
33389
|
+
if (!color) continue;
|
|
33390
|
+
const alphaEl = getFirstChildByTagNameNS(srgbClr, WORD14_NS, "alpha");
|
|
33391
|
+
const alphaRaw = alphaEl ? getAttributeValue(alphaEl, "val") : null;
|
|
33392
|
+
const alpha = alphaRaw !== null ? Number(alphaRaw) / 1e5 : void 0;
|
|
33393
|
+
const stop = { position: pos, color };
|
|
33394
|
+
if (alpha !== void 0 && Number.isFinite(alpha)) stop.alpha = alpha;
|
|
33395
|
+
stops.push(stop);
|
|
33396
|
+
}
|
|
33397
|
+
if (stops.length > 0) {
|
|
33398
|
+
const linEl = getFirstChildByTagNameNS(gradFill, WORD14_NS, "lin");
|
|
33399
|
+
const angRaw = linEl ? getAttributeValue(linEl, "ang") : null;
|
|
33400
|
+
const angle = angRaw !== null ? Number(angRaw) / 6e4 : void 0;
|
|
33401
|
+
const result = { type: "gradient", stops };
|
|
33402
|
+
if (angle !== void 0 && Number.isFinite(angle)) result.angle = angle;
|
|
33403
|
+
return result;
|
|
33404
|
+
}
|
|
33405
|
+
}
|
|
33406
|
+
}
|
|
33407
|
+
return null;
|
|
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
|
+
}
|
|
33216
33464
|
function normalizeImportedRunStyle(style2, paragraphStyleId) {
|
|
33217
33465
|
if (!style2) {
|
|
33218
33466
|
return void 0;
|
|
@@ -33315,6 +33563,11 @@ function normalizeImportedRunStyle(style2, paragraphStyleId) {
|
|
|
33315
33563
|
),
|
|
33316
33564
|
fontSize: hd(style2.fontSize, effective.fontSize, defaultEffective.fontSize),
|
|
33317
33565
|
color: dd(effective.color, defaultEffective.color),
|
|
33566
|
+
textFill: dd(effective.textFill, defaultEffective.textFill),
|
|
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),
|
|
33318
33571
|
highlight: dd(effective.highlight, defaultEffective.highlight),
|
|
33319
33572
|
shading: dd(effective.shading, defaultEffective.shading),
|
|
33320
33573
|
language: dd(effective.language, defaultEffective.language),
|
|
@@ -33564,6 +33817,42 @@ function parseRunStyle(runProperties, theme) {
|
|
|
33564
33817
|
styles.color = themeColor;
|
|
33565
33818
|
}
|
|
33566
33819
|
}
|
|
33820
|
+
const textFillEl = getFirstW14Child(runProperties, "textFill");
|
|
33821
|
+
if (textFillEl) {
|
|
33822
|
+
const textFill = parseW14TextFill(textFillEl);
|
|
33823
|
+
if (textFill) styles.textFill = textFill;
|
|
33824
|
+
}
|
|
33825
|
+
const textOutlineEl = getFirstW14Child(runProperties, "textOutline");
|
|
33826
|
+
if (textOutlineEl) {
|
|
33827
|
+
const wAttr = textOutlineEl.getAttributeNS(WORD14_NS, "w");
|
|
33828
|
+
const widthEmu = wAttr !== null ? Number(wAttr) : NaN;
|
|
33829
|
+
const widthPt = Number.isFinite(widthEmu) && widthEmu > 0 ? widthEmu / 12700 : 0.5;
|
|
33830
|
+
const textOutline = { widthPt };
|
|
33831
|
+
const outlineFill = parseW14TextFill(textOutlineEl);
|
|
33832
|
+
if (outlineFill) {
|
|
33833
|
+
textOutline.fill = outlineFill;
|
|
33834
|
+
if (outlineFill.type === "solid") {
|
|
33835
|
+
textOutline.color = outlineFill.color;
|
|
33836
|
+
} else if (outlineFill.type === "gradient" && outlineFill.stops[0]) {
|
|
33837
|
+
textOutline.color = outlineFill.stops[0].color;
|
|
33838
|
+
}
|
|
33839
|
+
}
|
|
33840
|
+
styles.textOutline = textOutline;
|
|
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
|
+
}
|
|
33567
33856
|
const highlight = getFirstChildByTagNameNS(
|
|
33568
33857
|
runProperties,
|
|
33569
33858
|
WORD_NS,
|
|
@@ -37137,7 +37426,7 @@ function importDocxInWorker(buffer, options = {}) {
|
|
|
37137
37426
|
const worker = new Worker(
|
|
37138
37427
|
new URL(
|
|
37139
37428
|
/* @vite-ignore */
|
|
37140
|
-
"" + new URL("assets/importDocxWorker-
|
|
37429
|
+
"" + new URL("assets/importDocxWorker-BV6LezJZ.js", import.meta.url).href,
|
|
37141
37430
|
import.meta.url
|
|
37142
37431
|
),
|
|
37143
37432
|
{
|
package/dist/oasis-editor.js
CHANGED
|
@@ -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-
|
|
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,
|