ooxml-ui 1.18.2 → 1.19.0
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/README.md +54 -0
- package/dist/building-block-styles.d.ts +5 -0
- package/dist/building-block-styles.d.ts.map +1 -0
- package/dist/chunk-6Y7KR2I3.js +299 -0
- package/dist/{chunk-EVL7GFC7.js → chunk-KH2ZG3N6.js} +2 -2
- package/dist/{chunk-MSXUCINT.js → chunk-QEIGB73C.js} +1 -1
- package/dist/docx/building-blocks.d.ts +31 -0
- package/dist/docx/component.d.ts +1 -1
- package/dist/docx/editor-core.d.ts +3 -0
- package/dist/docx/element-api.d.ts +8 -0
- package/dist/docx/index.d.ts +1 -0
- package/dist/docx/styles/index.d.ts +0 -4
- package/dist/docx.js +154 -38
- package/dist/index.js +3 -3
- package/dist/pptx/chunk-NDAE3JFO.cjs +1014 -0
- package/dist/pptx/{chunk-AUCJIB3M.mjs → chunk-NLUVYOKN.mjs} +113 -381
- package/dist/pptx/{chunk-S2Y3VUNC.cjs → chunk-OQQQ2GBW.cjs} +134 -402
- package/dist/pptx/chunk-UTFFX4M7.mjs +989 -0
- package/dist/pptx/dom/index.cjs +205 -205
- package/dist/pptx/dom/index.mjs +3 -3
- package/dist/pptx/index.cjs +2888 -2880
- package/dist/pptx/index.mjs +2 -2
- package/dist/pptx/render/morph-predicates.d.ts.map +1 -1
- package/dist/pptx/theme/index.cjs +24 -16
- package/dist/pptx/theme/index.d.ts +1 -0
- package/dist/pptx/theme/index.d.ts.map +1 -1
- package/dist/pptx/theme/index.mjs +1 -1
- package/dist/pptx/theme/office-css.d.ts +6 -0
- package/dist/pptx/theme/office-css.d.ts.map +1 -0
- package/dist/pptx/web-components/chart-format-pane-styles.d.ts +1 -1
- package/dist/pptx/web-components/chart-format-pane-styles.d.ts.map +1 -1
- package/dist/pptx/web-components/control-styles.d.ts.map +1 -1
- package/dist/pptx/web-components/index.d.ts.map +1 -1
- package/dist/pptx/web-components/mobile-bar-styles.d.ts +2 -2
- package/dist/pptx/web-components/mobile-bar-styles.d.ts.map +1 -1
- package/dist/pptx/web-components/mobile-insert-styles.d.ts +1 -1
- package/dist/pptx/web-components/mobile-insert-styles.d.ts.map +1 -1
- package/dist/pptx/web-components/notes-toolbar-styles.d.ts +1 -1
- package/dist/pptx/web-components/notes-toolbar-styles.d.ts.map +1 -1
- package/dist/pptx/web-components/office-token-bridge.d.ts.map +1 -1
- package/dist/pptx/web-components/subtitle-settings-styles.d.ts +1 -1
- package/dist/pptx/web-components/subtitle-settings-styles.d.ts.map +1 -1
- package/dist/pptx/web-components/theme-editor-styles.d.ts +1 -1
- package/dist/pptx/web-components/theme-editor-styles.d.ts.map +1 -1
- package/dist/teams.js +2 -2
- package/dist/theme-bridge.d.ts +28 -0
- package/dist/theme-bridge.d.ts.map +1 -0
- package/dist/theme.d.ts +10 -3
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +1 -1
- package/dist/visio/building-blocks.d.ts +37 -0
- package/dist/visio/controller.d.ts +6 -0
- package/dist/visio/index.d.ts +1 -0
- package/dist/visio/styles/theme.d.ts +1 -1
- package/dist/visio/styles.d.ts +1 -1
- package/dist/visio/viewer-element.d.ts +2 -0
- package/dist/visio.js +7446 -7321
- package/dist/xlsx/building-blocks.d.ts +55 -0
- package/dist/xlsx/component.d.ts +3 -1
- package/dist/xlsx/dialogs/styles.d.ts +1 -1
- package/dist/xlsx/editor-core.d.ts +1 -0
- package/dist/xlsx/element-api.d.ts +6 -0
- package/dist/xlsx/formula-bar/styles.d.ts +1 -1
- package/dist/xlsx/grid/page-break-layer.d.ts +1 -1
- package/dist/xlsx/grid/styles.d.ts +1 -1
- package/dist/xlsx/index.d.ts +1 -0
- package/dist/xlsx/page-views/page-layout-css.d.ts +1 -1
- package/dist/xlsx/sheet-tabs/styles.d.ts +1 -1
- package/dist/xlsx/surface-shell.d.ts +3 -0
- package/dist/xlsx/theme/styles.d.ts +1 -4
- package/dist/xlsx.js +412 -268
- package/package.json +4 -4
- package/dist/chunk-7E3HU7RL.js +0 -123
- package/dist/pptx/chunk-BDXQX6RA.cjs +0 -373
- package/dist/pptx/chunk-ZAOD6O2D.mjs +0 -357
package/README.md
CHANGED
|
@@ -122,10 +122,64 @@ PowerPoint continues to use the same component for ribbon galleries.
|
|
|
122
122
|
|
|
123
123
|
Every entry declares an `import` and a `default` export condition, so CommonJS consumers on Node 20.19+ or 22.12+ load it through `require(esm)`.
|
|
124
124
|
|
|
125
|
+
`installOfficeUiTheme()` installs one theme stylesheet in the document by default. Pass a
|
|
126
|
+
`ShadowRoot` to install scoped mode and control rules inside an embedding app's shadow tree.
|
|
127
|
+
`installOfficeUiThemeFor(element)` installs document defaults plus rules in every enclosing shadow
|
|
128
|
+
root. Product canvases and `prepareOfficeUiBlock()` use this host-aware installation automatically;
|
|
129
|
+
the latter checks again after native framework insertion. Theme attributes inside Angular shadow
|
|
130
|
+
views and other shadow containers therefore work alongside inherited custom properties.
|
|
131
|
+
|
|
132
|
+
Use semantic `--office-*` palette tokens on a shared ancestor to theme all controls. When overriding
|
|
133
|
+
a specific derived control token, such as `--office-select-background`, apply it to the actual
|
|
134
|
+
control. Product compatibility bridges recompute dependent defaults on their inner chrome so those
|
|
135
|
+
controls follow the product palette.
|
|
136
|
+
|
|
125
137
|
Importing an entry never touches the DOM (SSR-safe). Elements are defined by the `define*` /
|
|
126
138
|
`register*` functions, which are idempotent, no-ops without a `window`, and refuse to coexist
|
|
127
139
|
with an incompatible build of this package.
|
|
128
140
|
|
|
141
|
+
## One theme for composed editors
|
|
142
|
+
|
|
143
|
+
Use the shared `--office-*` CSS tokens on a common ancestor of the canvas and its standalone
|
|
144
|
+
controls. `data-office-theme="light"`, `"dark"`, or `"auto"` works on the document root or a
|
|
145
|
+
scoped container, so two editors on the same page can use different modes. `auto` follows the
|
|
146
|
+
system colour scheme. Nested mode scopes retain inherited typography, spacing and radii.
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<section class="office-scope" data-office-theme="dark">
|
|
150
|
+
<!-- Mount the framework's standalone toolbar, canvas and other controls here. -->
|
|
151
|
+
</section>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```css
|
|
155
|
+
.office-scope {
|
|
156
|
+
--office-accent: #0d9488;
|
|
157
|
+
--office-accent-foreground: #ffffff;
|
|
158
|
+
--office-ring: #0f766e;
|
|
159
|
+
--office-font: 'Inter', system-ui, sans-serif;
|
|
160
|
+
--office-radius: 6px;
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Change the attribute or CSS tokens through your framework's normal bindings. Theme changes do
|
|
165
|
+
not require remounting the editor. The semantic palette includes `--office-background` (fields
|
|
166
|
+
and application background), `--office-surface` (toolbar and panel surfaces), `--office-foreground`,
|
|
167
|
+
`--office-muted-foreground`, `--office-border`, `--office-selected`, and the accent and focus tokens
|
|
168
|
+
above. Document paper, cell fills and slide artwork remain document content.
|
|
169
|
+
|
|
170
|
+
Library-supplied native building blocks opt into `BUILDING_BLOCKS_CSS` through
|
|
171
|
+
`prepareOfficeUiBlock(element, kind, product)`, exported by `ooxml-ui/theme`. It installs the shared
|
|
172
|
+
theme in the element's owner document and marks only that control root with `data-office-block`
|
|
173
|
+
and `data-office-product`. Hosts' own unmarked controls are unaffected. Shadow-root controls
|
|
174
|
+
inherit the same tokens. The installed stylesheet is idempotent and supports forced colours and
|
|
175
|
+
touch targets.
|
|
176
|
+
|
|
177
|
+
Existing product overrides (`--dve-*`, `--xve-*`, `--vv-*`, `--pptx-*`, and legacy theme options)
|
|
178
|
+
remain compatibility inputs. An explicit product override wins for that product. For a uniform
|
|
179
|
+
composition, put the shared tokens and mode on the common ancestor instead of configuring only
|
|
180
|
+
the canvas: a canvas's local theme cannot change the CSS inherited by a sibling toolbar. This UI
|
|
181
|
+
theme contract is separate from an Office document's embedded theme.
|
|
182
|
+
|
|
129
183
|
## Features: elements
|
|
130
184
|
|
|
131
185
|
`office-ui-menu-button` accepts `submenu` when nested inside another menu.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type OfficeUiBlockKind = 'toolbar' | 'formula-bar' | 'tabs' | 'inspector';
|
|
2
|
+
export type OfficeUiProduct = 'docx' | 'xlsx' | 'visio' | 'pptx';
|
|
3
|
+
/** Opt-in styles for native framework controls. They never target host-owned controls implicitly. */
|
|
4
|
+
export declare const BUILDING_BLOCKS_CSS: string;
|
|
5
|
+
//# sourceMappingURL=building-block-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"building-block-styles.d.ts","sourceRoot":"","sources":["../src/building-block-styles.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,WAAW,CAAC;AACjF,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAiDjE,qGAAqG;AACrG,eAAO,MAAM,mBAAmB,QAsD/B,CAAC"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { OFFICE_TOKENS, TOUCH } from './chunk-LD3K2RDN.js';
|
|
2
|
+
|
|
3
|
+
// src/theme-bridge.ts
|
|
4
|
+
var LEGACY_OFFICE_THEME_TOKENS = {
|
|
5
|
+
background: "--office-background",
|
|
6
|
+
foreground: "--office-foreground",
|
|
7
|
+
card: "--office-surface",
|
|
8
|
+
"card-foreground": "--office-foreground",
|
|
9
|
+
popover: "--office-popover",
|
|
10
|
+
"popover-foreground": "--office-popover-foreground",
|
|
11
|
+
primary: "--office-accent",
|
|
12
|
+
"primary-foreground": "--office-accent-foreground",
|
|
13
|
+
secondary: "--office-surface",
|
|
14
|
+
"secondary-foreground": "--office-foreground",
|
|
15
|
+
muted: "--office-surface",
|
|
16
|
+
"muted-foreground": "--office-muted-foreground",
|
|
17
|
+
accent: "--office-selected",
|
|
18
|
+
"accent-foreground": "--office-foreground",
|
|
19
|
+
destructive: "--office-danger",
|
|
20
|
+
"destructive-foreground": "--office-danger-foreground",
|
|
21
|
+
border: "--office-border",
|
|
22
|
+
input: "--office-border",
|
|
23
|
+
ring: "--office-ring",
|
|
24
|
+
radius: "--office-radius",
|
|
25
|
+
font: "--office-font"
|
|
26
|
+
};
|
|
27
|
+
function legacyThemeAliases(selector, prefix, privatePrefix) {
|
|
28
|
+
return `${selector} {
|
|
29
|
+
${Object.entries(LEGACY_OFFICE_THEME_TOKENS).map(
|
|
30
|
+
([name, canonical]) => `${privatePrefix}${name}: var(${prefix}${name}, var(${canonical}, ${OFFICE_TOKENS[canonical]}));`
|
|
31
|
+
).join("\n")}
|
|
32
|
+
}`;
|
|
33
|
+
}
|
|
34
|
+
function legacyThemeBridge(selector, privatePrefix) {
|
|
35
|
+
return shadcnBridge(selector, privatePrefix, {
|
|
36
|
+
extra: {
|
|
37
|
+
"--office-font": `var(${privatePrefix}font)`,
|
|
38
|
+
"--office-radius": `var(${privatePrefix}radius)`
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
var SHADCN_NAMES = [
|
|
43
|
+
"foreground",
|
|
44
|
+
"muted-foreground",
|
|
45
|
+
"background",
|
|
46
|
+
"card",
|
|
47
|
+
"accent",
|
|
48
|
+
"border",
|
|
49
|
+
"primary",
|
|
50
|
+
"primary-foreground",
|
|
51
|
+
"ring",
|
|
52
|
+
"popover",
|
|
53
|
+
"popover-foreground",
|
|
54
|
+
"destructive",
|
|
55
|
+
"destructive-foreground"
|
|
56
|
+
].map((name) => {
|
|
57
|
+
const token = LEGACY_OFFICE_THEME_TOKENS[name];
|
|
58
|
+
return name === "popover-foreground" ? [token, name, "foreground"] : [token, name];
|
|
59
|
+
});
|
|
60
|
+
var reads = (value2) => [...value2.matchAll(/var\((--office-[\w-]+)/g)].map((m) => m[1]);
|
|
61
|
+
function derivedTokens(bridged) {
|
|
62
|
+
const derived = /* @__PURE__ */ new Map();
|
|
63
|
+
let grew = true;
|
|
64
|
+
while (grew) {
|
|
65
|
+
grew = false;
|
|
66
|
+
for (const [name, value2] of Object.entries(OFFICE_TOKENS)) {
|
|
67
|
+
if (bridged.has(name) || derived.has(name)) continue;
|
|
68
|
+
if (reads(value2).some((token) => bridged.has(token) || derived.has(token))) {
|
|
69
|
+
derived.set(name, value2);
|
|
70
|
+
grew = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [...derived];
|
|
75
|
+
}
|
|
76
|
+
function themeBridge(selector, map) {
|
|
77
|
+
const mapped = Object.entries(map).filter((entry) => !!entry[1]);
|
|
78
|
+
const lines = [...mapped, ...derivedTokens(new Set(mapped.map(([name]) => name)))].map(
|
|
79
|
+
([name, value2]) => ` ${name}: ${value2};`
|
|
80
|
+
);
|
|
81
|
+
return `${selector} {
|
|
82
|
+
${lines.join("\n")}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
function shadcnBridge(selector, prefix, options = {}) {
|
|
87
|
+
const map = {};
|
|
88
|
+
for (const [token, name, fallbackName] of SHADCN_NAMES) {
|
|
89
|
+
const fallback = options.fallbacks?.[name];
|
|
90
|
+
const inner = fallbackName ? `var(${prefix}${fallbackName})` : fallback;
|
|
91
|
+
map[token] = `var(${prefix}${name}${inner ? `, ${inner}` : ""})`;
|
|
92
|
+
}
|
|
93
|
+
return themeBridge(selector, { ...map, ...options.extra });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/building-block-styles.ts
|
|
97
|
+
var value = (name) => `var(${name}, ${OFFICE_TOKENS[name]})`;
|
|
98
|
+
var palette = {
|
|
99
|
+
foreground: "--office-foreground",
|
|
100
|
+
background: "--office-background",
|
|
101
|
+
surface: "--office-surface",
|
|
102
|
+
border: "--office-border",
|
|
103
|
+
accent: "--office-accent",
|
|
104
|
+
selected: "--office-selected",
|
|
105
|
+
ring: "--office-ring",
|
|
106
|
+
font: "--office-font",
|
|
107
|
+
radius: "--office-radius"
|
|
108
|
+
};
|
|
109
|
+
function productAliases(product) {
|
|
110
|
+
const names = product === "visio" ? {
|
|
111
|
+
foreground: "ink",
|
|
112
|
+
background: "surface",
|
|
113
|
+
surface: "surface",
|
|
114
|
+
border: "border",
|
|
115
|
+
accent: "accent",
|
|
116
|
+
selected: "accent-soft",
|
|
117
|
+
ring: "focus",
|
|
118
|
+
font: "font",
|
|
119
|
+
radius: "radius"
|
|
120
|
+
} : {
|
|
121
|
+
foreground: "foreground",
|
|
122
|
+
background: "background",
|
|
123
|
+
surface: "card",
|
|
124
|
+
border: "border",
|
|
125
|
+
accent: "primary",
|
|
126
|
+
selected: "accent",
|
|
127
|
+
ring: "ring",
|
|
128
|
+
font: "font",
|
|
129
|
+
radius: "radius"
|
|
130
|
+
};
|
|
131
|
+
const prefix = { docx: "--dve-", xlsx: "--xve-", visio: "--vv-", pptx: "--pptx-" }[product];
|
|
132
|
+
return `:where([data-office-block][data-office-product="${product}"]) {
|
|
133
|
+
${Object.entries(palette).map(
|
|
134
|
+
([key, token]) => `--_office-block-${key}: var(${prefix}${names[key]}, ${value(token)});`
|
|
135
|
+
).join("\n")}
|
|
136
|
+
}`;
|
|
137
|
+
}
|
|
138
|
+
var BUILDING_BLOCKS_CSS = `
|
|
139
|
+
:where([data-office-block]) {
|
|
140
|
+
${Object.entries(palette).map(([key, token]) => `--_office-block-${key}: ${value(token)};`).join("\n")}
|
|
141
|
+
box-sizing: border-box;
|
|
142
|
+
color: var(--_office-block-foreground);
|
|
143
|
+
background: var(--_office-block-surface);
|
|
144
|
+
font-family: var(--_office-block-font);
|
|
145
|
+
font-size: ${value("--office-font-size")};
|
|
146
|
+
line-height: ${value("--office-line-height")};
|
|
147
|
+
}
|
|
148
|
+
${["docx", "xlsx", "visio", "pptx"].map(productAliases).join("\n")}
|
|
149
|
+
:where([data-office-block="toolbar"], [data-office-block="formula-bar"], [data-office-block="tabs"]:not(select)) {
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-wrap: wrap;
|
|
152
|
+
align-items: center;
|
|
153
|
+
gap: ${value("--office-space-1")};
|
|
154
|
+
padding: ${value("--office-space-1")};
|
|
155
|
+
border: ${value("--office-border-width")} solid var(--_office-block-border);
|
|
156
|
+
border-radius: var(--_office-block-radius);
|
|
157
|
+
}
|
|
158
|
+
:where([data-office-block] button, [data-office-block] input, [data-office-block] select,
|
|
159
|
+
button[data-office-block], input[data-office-block], select[data-office-block]) {
|
|
160
|
+
box-sizing: border-box;
|
|
161
|
+
font-family: var(--_office-block-font);
|
|
162
|
+
font-size: ${value("--office-font-size")};
|
|
163
|
+
line-height: ${value("--office-line-height")};
|
|
164
|
+
color: var(--_office-block-foreground);
|
|
165
|
+
background: var(--_office-block-background);
|
|
166
|
+
border: ${value("--office-border-width")} solid var(--_office-block-border);
|
|
167
|
+
border-radius: var(--_office-block-radius);
|
|
168
|
+
min-height: ${value("--office-target-size")};
|
|
169
|
+
padding: ${value("--office-space-1")} ${value("--office-space-2")};
|
|
170
|
+
}
|
|
171
|
+
:where([data-office-block] button, button[data-office-block]) { cursor: pointer; }
|
|
172
|
+
:where([data-office-block] button:hover:not(:disabled)) { background: var(--_office-block-selected); }
|
|
173
|
+
:where([data-office-block] [aria-pressed="true"], [data-office-block] [aria-pressed="mixed"],
|
|
174
|
+
[data-office-block] [aria-selected="true"]) {
|
|
175
|
+
background: var(--_office-block-selected);
|
|
176
|
+
border-color: var(--_office-block-accent);
|
|
177
|
+
}
|
|
178
|
+
:where([data-office-block] :focus-visible, [data-office-block]:focus-visible) {
|
|
179
|
+
outline: ${value("--office-focus-width")} solid var(--_office-block-ring);
|
|
180
|
+
outline-offset: ${value("--office-focus-offset")};
|
|
181
|
+
}
|
|
182
|
+
:where([data-office-block] :disabled, [data-office-block]:disabled) { opacity: .55; cursor: default; }
|
|
183
|
+
:where([data-office-block] [aria-invalid="true"]) { border-color: ${value("--office-danger")}; }
|
|
184
|
+
:where([data-office-block="formula-bar"] input:last-child) { flex: 1; min-width: 8em; }
|
|
185
|
+
:where([data-office-block="inspector"]) { padding: ${value("--office-space-2")}; }
|
|
186
|
+
:where([data-office-block="inspector"] dl) { display: grid; grid-template-columns: auto 1fr; gap: ${value("--office-space-1")}; }
|
|
187
|
+
:where([data-office-block="inspector"] dt) { font-weight: ${value("--office-font-weight-bold")}; }
|
|
188
|
+
:where([data-office-block="inspector"] dd) { margin: 0; overflow-wrap: anywhere; }
|
|
189
|
+
:where([data-office-block="inspector"] a) { color: var(--_office-block-accent); }
|
|
190
|
+
`;
|
|
191
|
+
|
|
192
|
+
// src/theme.ts
|
|
193
|
+
var THEME_STYLE_ID = "office-ui-theme";
|
|
194
|
+
var DARK = `
|
|
195
|
+
--office-foreground: #f9fafb;
|
|
196
|
+
--office-muted-foreground: #9ca3af;
|
|
197
|
+
--office-background: #111827;
|
|
198
|
+
--office-surface: #1f2937;
|
|
199
|
+
--office-border: #374151;
|
|
200
|
+
--office-accent: #6366f1;
|
|
201
|
+
--office-ring: #818cf8;
|
|
202
|
+
--office-danger: #f87171;
|
|
203
|
+
--office-selected: #374151;
|
|
204
|
+
--office-notice-background: rgb(120 53 15 / 20%);
|
|
205
|
+
--office-notice-foreground: #fde68a;
|
|
206
|
+
--office-notice-accent: #fbbf24;
|
|
207
|
+
--office-info: #60a5fa;
|
|
208
|
+
--office-warning: #f59e0b;
|
|
209
|
+
--office-teams-brand: #7f85f5;
|
|
210
|
+
--office-teams-brand-hover: #96a0ff;
|
|
211
|
+
--office-teams-brand-subtle: #2f2f4a;
|
|
212
|
+
--office-teams-rail: #141414;
|
|
213
|
+
--office-teams-panel: #1f1f1f;
|
|
214
|
+
--office-teams-bubble: #2d2d2d;
|
|
215
|
+
--office-teams-bubble-own: #2f2f4a;
|
|
216
|
+
--office-teams-divider: #3d3d3d;
|
|
217
|
+
--office-teams-text-subtle: #adadad;
|
|
218
|
+
--office-shadow: 0 6px 20px rgb(0 0 0 / 45%);
|
|
219
|
+
--office-shadow-lg: 0 10px 25px rgb(0 0 0 / 45%);`;
|
|
220
|
+
var LIGHT = Object.entries(OFFICE_TOKENS).map(([name, value2]) => ` ${name}: ${value2};`).join("\n");
|
|
221
|
+
var darkEntries = [...DARK.matchAll(/(--office-[\w-]+): ([^;]+);/g)].map(
|
|
222
|
+
(match) => [match[1], match[2]]
|
|
223
|
+
);
|
|
224
|
+
var lightPalette = Object.fromEntries(
|
|
225
|
+
darkEntries.map(([name]) => [name, OFFICE_TOKENS[name]])
|
|
226
|
+
);
|
|
227
|
+
var darkPalette = Object.fromEntries(darkEntries);
|
|
228
|
+
var modeCss = (selector, dark) => themeBridge(selector, {
|
|
229
|
+
...lightPalette,
|
|
230
|
+
...dark ? darkPalette : {},
|
|
231
|
+
"--office-accent-foreground": OFFICE_TOKENS["--office-accent-foreground"]
|
|
232
|
+
}) + `${selector} { color-scheme: ${dark ? "dark" : "light"}; }`;
|
|
233
|
+
var THEME_CSS = `
|
|
234
|
+
:where(:root) {
|
|
235
|
+
${LIGHT}
|
|
236
|
+
color-scheme: light;
|
|
237
|
+
}
|
|
238
|
+
${modeCss(':where([data-office-theme="light"], [data-office-theme="auto"])', false)}
|
|
239
|
+
${modeCss(':where([data-office-theme="dark"])', true)}
|
|
240
|
+
@media (prefers-color-scheme: dark) {
|
|
241
|
+
${modeCss(':where(:root:not([data-office-theme="light"]), [data-office-theme="auto"])', true)}
|
|
242
|
+
}
|
|
243
|
+
@media ${TOUCH} {
|
|
244
|
+
:where(:root) { --office-target-size: var(--office-target-size-touch); }
|
|
245
|
+
}
|
|
246
|
+
@media (forced-colors: active) {
|
|
247
|
+
:where(:root, [data-office-theme]) {
|
|
248
|
+
--office-foreground: CanvasText;
|
|
249
|
+
--office-muted-foreground: GrayText;
|
|
250
|
+
--office-background: Canvas;
|
|
251
|
+
--office-surface: Canvas;
|
|
252
|
+
--office-border: CanvasText;
|
|
253
|
+
--office-accent: Highlight;
|
|
254
|
+
--office-accent-foreground: HighlightText;
|
|
255
|
+
--office-ring: Highlight;
|
|
256
|
+
--office-danger: CanvasText;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
${BUILDING_BLOCKS_CSS}
|
|
260
|
+
`;
|
|
261
|
+
function installOfficeUiTheme(root = globalThis.document) {
|
|
262
|
+
if (!root) return false;
|
|
263
|
+
const documentRoot = root.nodeType === 9;
|
|
264
|
+
if (!documentRoot && !("host" in root)) return false;
|
|
265
|
+
const doc = documentRoot ? root : root.ownerDocument;
|
|
266
|
+
const container = documentRoot ? root.head : root;
|
|
267
|
+
if (!doc || !container) return false;
|
|
268
|
+
if (!root.getElementById(THEME_STYLE_ID)) {
|
|
269
|
+
const style = doc.createElement("style");
|
|
270
|
+
style.id = THEME_STYLE_ID;
|
|
271
|
+
style.textContent = THEME_CSS;
|
|
272
|
+
container.append(style);
|
|
273
|
+
}
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
function installOfficeUiThemeRoots(host) {
|
|
277
|
+
let installed = installOfficeUiTheme(host.ownerDocument);
|
|
278
|
+
let root = host.getRootNode();
|
|
279
|
+
while (root.nodeType === 11 && "host" in root) {
|
|
280
|
+
const shadow = root;
|
|
281
|
+
installed = installOfficeUiTheme(shadow) && installed;
|
|
282
|
+
root = shadow.host.getRootNode();
|
|
283
|
+
}
|
|
284
|
+
return installed;
|
|
285
|
+
}
|
|
286
|
+
function installOfficeUiThemeFor(host) {
|
|
287
|
+
const installed = installOfficeUiThemeRoots(host);
|
|
288
|
+
queueMicrotask(() => {
|
|
289
|
+
installOfficeUiThemeRoots(host);
|
|
290
|
+
});
|
|
291
|
+
return installed;
|
|
292
|
+
}
|
|
293
|
+
function prepareOfficeUiBlock(host, kind, product) {
|
|
294
|
+
host.setAttribute("data-office-block", kind);
|
|
295
|
+
if (product) host.setAttribute("data-office-product", product);
|
|
296
|
+
installOfficeUiThemeFor(host);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export { BUILDING_BLOCKS_CSS, LEGACY_OFFICE_THEME_TOKENS, THEME_CSS, THEME_STYLE_ID, installOfficeUiTheme, installOfficeUiThemeFor, legacyThemeAliases, legacyThemeBridge, prepareOfficeUiBlock, shadcnBridge, themeBridge };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineSmartArt } from './chunk-ANPFMQ6E.js';
|
|
2
|
-
import { TEAMS_TAGS, registerTeams } from './chunk-
|
|
3
|
-
import { installOfficeUiTheme } from './chunk-
|
|
2
|
+
import { TEAMS_TAGS, registerTeams } from './chunk-QEIGB73C.js';
|
|
3
|
+
import { installOfficeUiTheme } from './chunk-6Y7KR2I3.js';
|
|
4
4
|
import { registerControls } from './chunk-SPRZIHUH.js';
|
|
5
5
|
import { definePresence } from './chunk-KNC2UEUR.js';
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TeamsLitElement, LOCALE_HOST, teamsI18n, inheritLocale, pushLocale } from './chunk-FHO7TEWA.js';
|
|
2
|
-
import { THEME_CSS, installOfficeUiTheme } from './chunk-
|
|
2
|
+
import { THEME_CSS, installOfficeUiTheme } from './chunk-6Y7KR2I3.js';
|
|
3
3
|
import { defineMenuButton, defineMenuItem, registerControls, defineSwitch } from './chunk-SPRZIHUH.js';
|
|
4
4
|
import { registerIcon, getIcon } from './chunk-M6GF5ED2.js';
|
|
5
5
|
import { initialsOf, definePresence } from './chunk-KNC2UEUR.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { EditorCore } from './editor-core.js';
|
|
2
|
+
/** A snapshot of the current editor selection, with commands bound to the same editor. */
|
|
3
|
+
export declare function wordToolbarProps(core: EditorCore): {
|
|
4
|
+
labels: {
|
|
5
|
+
[k: string]: string;
|
|
6
|
+
};
|
|
7
|
+
canEdit: boolean;
|
|
8
|
+
list: 'bullet' | 'decimal' | 'other' | null;
|
|
9
|
+
selection: {
|
|
10
|
+
from: number;
|
|
11
|
+
to: number;
|
|
12
|
+
} | null;
|
|
13
|
+
bold: boolean | null;
|
|
14
|
+
italic: boolean | null;
|
|
15
|
+
underline: boolean | null;
|
|
16
|
+
fontFamily: string | null;
|
|
17
|
+
fontSize: number | null;
|
|
18
|
+
alignment: string | null;
|
|
19
|
+
canUndo: boolean;
|
|
20
|
+
canRedo: boolean;
|
|
21
|
+
onBold: () => boolean;
|
|
22
|
+
onItalic: () => boolean;
|
|
23
|
+
onUnderline: () => boolean;
|
|
24
|
+
onFontFamilyChange: (family: string) => boolean;
|
|
25
|
+
onFontSizeChange: (size: number) => boolean;
|
|
26
|
+
onAlignmentChange: (alignment: 'left' | 'center' | 'right' | 'justify') => boolean;
|
|
27
|
+
onListChange: (kind: 'bullet' | 'number' | 'remove') => boolean;
|
|
28
|
+
onUndo: () => boolean;
|
|
29
|
+
onRedo: () => boolean;
|
|
30
|
+
};
|
|
31
|
+
export type WordToolbarProps = ReturnType<typeof wordToolbarProps>;
|
package/dist/docx/component.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare class DocxEditorElement extends DocxEditorApi {
|
|
|
30
30
|
/** File name shown in the title bar and used for downloads from the built-in File commands. */
|
|
31
31
|
get fileName(): string;
|
|
32
32
|
set fileName(value: string);
|
|
33
|
-
/** `light`, `dark`, or `auto` (default, follows the OS). Reflected to the `theme` attribute. */
|
|
33
|
+
/** `light`, `dark`, or `auto` (default, inherits the Office theme, then follows the OS). Reflected to the `theme` attribute. */
|
|
34
34
|
get theme(): EditorThemeMode;
|
|
35
35
|
set theme(value: EditorThemeMode);
|
|
36
36
|
/** Token overrides applied as inline `--dve-*` custom properties on the host. */
|
|
@@ -57,7 +57,10 @@ export declare class EditorCore {
|
|
|
57
57
|
view?: EditorView | undefined;
|
|
58
58
|
loaded?: LoadedDocument | undefined;
|
|
59
59
|
loadGeneration: number;
|
|
60
|
+
loading: boolean;
|
|
60
61
|
readOnly: boolean;
|
|
62
|
+
/** Set before mounting to render only the document surface. */
|
|
63
|
+
surfaceOnly: boolean;
|
|
61
64
|
locale: EditorLocale;
|
|
62
65
|
reviewAuthor: string;
|
|
63
66
|
theme: EditorThemeMode;
|
|
@@ -3,12 +3,20 @@ import type { CollabSession } from 'ooxml-core/collab';
|
|
|
3
3
|
import type { WordYjsOptions } from 'ooxml-core/docx/ui';
|
|
4
4
|
import type { EditorCore } from './editor-core.js';
|
|
5
5
|
import { type RibbonActionId, type RibbonActionInput } from 'ooxml-core/docx/ui';
|
|
6
|
+
import { type WordToolbarProps } from './building-blocks.js';
|
|
6
7
|
declare const HTMLElementBase: typeof HTMLElement;
|
|
7
8
|
/**
|
|
8
9
|
* Save, collaboration, dirty-tracking and UI-customisation surface of `<docx-editor>`.
|
|
9
10
|
* the shared `EditorCore`, so the element class stays a thin lifecycle facade.
|
|
10
11
|
*/
|
|
11
12
|
export declare abstract class DocxEditorApi extends HTMLElementBase {
|
|
13
|
+
/** Choose before connecting. This mode mounts only the document and its editing surface. */
|
|
14
|
+
get surfaceOnly(): boolean;
|
|
15
|
+
set surfaceOnly(value: boolean);
|
|
16
|
+
getToolbarProps(): WordToolbarProps;
|
|
17
|
+
get loading(): boolean;
|
|
18
|
+
/** Selection and formatting updates, including changes which do not dirty the document. */
|
|
19
|
+
subscribeEditorState(listener: () => void): () => void;
|
|
12
20
|
protected abstract readonly core: EditorCore;
|
|
13
21
|
abstract fileName: string;
|
|
14
22
|
abstract reviewAuthor: string;
|
package/dist/docx/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { DocxEditorElement, registerDocxEditor } from './component.js';
|
|
2
|
+
export type { WordToolbarProps } from './building-blocks.js';
|
|
2
3
|
export { DOCX_EDITOR_EVENTS } from './events.js';
|
|
3
4
|
export type { RibbonAction } from './ribbon.js';
|
|
4
5
|
export { RIBBON_ACTION_IDS, RIBBON_ACTION_LABELS, normalizeRibbonActions, isRibbonActionId, } from 'ooxml-core/docx/ui';
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token presets are generated from theme/defaults.ts so the TypeScript presets and the shadow-root
|
|
3
|
-
* CSS cannot drift. `theme="auto"` (the default) follows the OS; explicit values always win.
|
|
4
|
-
*/
|
|
5
1
|
export declare const themeTokenText: string;
|
|
6
2
|
export declare const editorStyleText: string;
|