@a3s-lab/office 0.28.0 → 0.29.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 +27 -1
- package/dist/0~1403.js +1 -1
- package/dist/0~4980.js +1 -1
- package/dist/0~5093.js +64 -5
- package/dist/0~7043.js +241 -241
- package/dist/0~7048.js +1 -1
- package/dist/0~7614.js +1 -1
- package/dist/0~document-editor.js +433 -10
- package/dist/0~presentation-editor.js +1 -1
- package/dist/0~spreadsheet-editor.js +1 -2
- package/dist/0~work-docx-export.js +141 -3
- package/dist/0~work-docx-import.js +5 -3
- package/dist/0~work-office-diagnostics.js +46 -3
- package/dist/0~work-pptx-export.js +1 -1
- package/dist/0~work-pptx-import.js +1 -1
- package/dist/0~work-presentation-charts.js +1 -1
- package/dist/1544.js +1 -1
- package/dist/4104.js +2 -2
- package/dist/4121.js +1510 -0
- package/dist/6282.js +59 -684
- package/dist/8715.js +1 -1
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +9 -0
- package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +5 -2
- package/dist/internal/features/work/editors/document-font-dialog-run-border-model.d.ts +24 -0
- package/dist/internal/features/work/editors/document-font-dialog-run-border-section.d.ts +10 -0
- package/dist/internal/features/work/work-document-character-formatting.d.ts +4 -0
- package/dist/internal/features/work/work-document-format-changes.d.ts +1 -0
- package/dist/internal/features/work/work-document-run-border.d.ts +11 -0
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +1 -0
- package/dist/internal/features/work/work-docx-run-border-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-run-border-export.d.ts +17 -0
- package/dist/internal/features/work/work-docx-run-border.d.ts +20 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +2 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +31 -0
- package/docs/latest/en/browser-editor-architecture.md +22 -0
- package/package.json +4 -1
- package/dist/5184.js +0 -662
- package/dist/9424.js +0 -16
package/dist/0~7043.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
|
-
import { serializeUtf8Xml, directChildren, xmlNamespacePrefix, parseXml, firstDescendant, decodeXmlBytes, directChild, descendants, attribute as work_ooxml_package_attribute } from "./
|
|
2
|
+
import { serializeUtf8Xml, directChildren, xmlNamespacePrefix, parseXml, firstDescendant, decodeXmlBytes, directChild, descendants, attribute as work_ooxml_package_attribute } from "./4121.js";
|
|
3
3
|
import { normalizeDocumentEmphasisMark, normalizeDocumentCharacterScalePercent, documentCitationStyle, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterSpacingTwips, normalizeDocumentTabStops, createDocumentBibliography, documentCitationStyleDetails } from "./6282.js";
|
|
4
4
|
const BIBLIOGRAPHY_NAMESPACE = 'http://schemas.openxmlformats.org/officeDocument/2006/bibliography';
|
|
5
5
|
const CUSTOM_XML_NAMESPACE = 'http://schemas.openxmlformats.org/officeDocument/2006/customXml';
|
|
@@ -1011,6 +1011,246 @@ function docxEmphasisMarkRunOptions(value) {
|
|
|
1011
1011
|
type: emphasisMark
|
|
1012
1012
|
};
|
|
1013
1013
|
}
|
|
1014
|
+
const WORD_THEME_COLOR_KEYS = new Map([
|
|
1015
|
+
[
|
|
1016
|
+
'dark1',
|
|
1017
|
+
'dk1'
|
|
1018
|
+
],
|
|
1019
|
+
[
|
|
1020
|
+
'light1',
|
|
1021
|
+
'lt1'
|
|
1022
|
+
],
|
|
1023
|
+
[
|
|
1024
|
+
'dark2',
|
|
1025
|
+
'dk2'
|
|
1026
|
+
],
|
|
1027
|
+
[
|
|
1028
|
+
'light2',
|
|
1029
|
+
'lt2'
|
|
1030
|
+
],
|
|
1031
|
+
[
|
|
1032
|
+
'background1',
|
|
1033
|
+
'lt1'
|
|
1034
|
+
],
|
|
1035
|
+
[
|
|
1036
|
+
'text1',
|
|
1037
|
+
'dk1'
|
|
1038
|
+
],
|
|
1039
|
+
[
|
|
1040
|
+
'background2',
|
|
1041
|
+
'lt2'
|
|
1042
|
+
],
|
|
1043
|
+
[
|
|
1044
|
+
'text2',
|
|
1045
|
+
'dk2'
|
|
1046
|
+
],
|
|
1047
|
+
[
|
|
1048
|
+
'hyperlink',
|
|
1049
|
+
'hlink'
|
|
1050
|
+
],
|
|
1051
|
+
[
|
|
1052
|
+
'followedhyperlink',
|
|
1053
|
+
'folhlink'
|
|
1054
|
+
]
|
|
1055
|
+
]);
|
|
1056
|
+
const DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES = new Map([
|
|
1057
|
+
[
|
|
1058
|
+
'background1',
|
|
1059
|
+
'bg1'
|
|
1060
|
+
],
|
|
1061
|
+
[
|
|
1062
|
+
'text1',
|
|
1063
|
+
't1'
|
|
1064
|
+
],
|
|
1065
|
+
[
|
|
1066
|
+
'background2',
|
|
1067
|
+
'bg2'
|
|
1068
|
+
],
|
|
1069
|
+
[
|
|
1070
|
+
'text2',
|
|
1071
|
+
't2'
|
|
1072
|
+
],
|
|
1073
|
+
[
|
|
1074
|
+
'accent1',
|
|
1075
|
+
'accent1'
|
|
1076
|
+
],
|
|
1077
|
+
[
|
|
1078
|
+
'accent2',
|
|
1079
|
+
'accent2'
|
|
1080
|
+
],
|
|
1081
|
+
[
|
|
1082
|
+
'accent3',
|
|
1083
|
+
'accent3'
|
|
1084
|
+
],
|
|
1085
|
+
[
|
|
1086
|
+
'accent4',
|
|
1087
|
+
'accent4'
|
|
1088
|
+
],
|
|
1089
|
+
[
|
|
1090
|
+
'accent5',
|
|
1091
|
+
'accent5'
|
|
1092
|
+
],
|
|
1093
|
+
[
|
|
1094
|
+
'accent6',
|
|
1095
|
+
'accent6'
|
|
1096
|
+
],
|
|
1097
|
+
[
|
|
1098
|
+
'hyperlink',
|
|
1099
|
+
'hyperlink'
|
|
1100
|
+
],
|
|
1101
|
+
[
|
|
1102
|
+
'followedhyperlink',
|
|
1103
|
+
'followedHyperlink'
|
|
1104
|
+
]
|
|
1105
|
+
]);
|
|
1106
|
+
const WORD_COLOR_SCHEME_INDEXES = new Set([
|
|
1107
|
+
'dark1',
|
|
1108
|
+
'light1',
|
|
1109
|
+
'dark2',
|
|
1110
|
+
'light2',
|
|
1111
|
+
'accent1',
|
|
1112
|
+
'accent2',
|
|
1113
|
+
'accent3',
|
|
1114
|
+
'accent4',
|
|
1115
|
+
'accent5',
|
|
1116
|
+
'accent6',
|
|
1117
|
+
'hyperlink',
|
|
1118
|
+
'followedHyperlink'
|
|
1119
|
+
]);
|
|
1120
|
+
const WORDPROCESSING_NAMESPACES = new Set([
|
|
1121
|
+
'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
|
|
1122
|
+
'http://purl.oclc.org/ooxml/wordprocessingml/main'
|
|
1123
|
+
]);
|
|
1124
|
+
const MAX_COLOR_MAPPING_DEPTH = 16;
|
|
1125
|
+
function createDocxThemeResolver(themeDocument, settingsDocument) {
|
|
1126
|
+
const colorMapping = docxColorSchemeMapping(settingsDocument);
|
|
1127
|
+
if (!themeDocument) return {
|
|
1128
|
+
colors: new Map(),
|
|
1129
|
+
colorMapping,
|
|
1130
|
+
fonts: new Map()
|
|
1131
|
+
};
|
|
1132
|
+
const fonts = new Map();
|
|
1133
|
+
const fontScheme = firstDescendant(themeDocument, 'fontScheme');
|
|
1134
|
+
addThemeFontFamily(fonts, 'major', fontScheme ? directChild(fontScheme, 'majorFont') : void 0);
|
|
1135
|
+
addThemeFontFamily(fonts, 'minor', fontScheme ? directChild(fontScheme, 'minorFont') : void 0);
|
|
1136
|
+
const colors = new Map();
|
|
1137
|
+
const colorScheme = firstDescendant(themeDocument, 'clrScheme');
|
|
1138
|
+
if (colorScheme) for (const entry of directChildren(colorScheme)){
|
|
1139
|
+
const color = themeColorValue(directChildren(entry)[0]);
|
|
1140
|
+
if (color) colors.set(entry.localName.toLowerCase(), color);
|
|
1141
|
+
}
|
|
1142
|
+
return {
|
|
1143
|
+
colors,
|
|
1144
|
+
colorMapping,
|
|
1145
|
+
fonts
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
function resolveDocxThemeResolver(source) {
|
|
1149
|
+
return isDocxThemeResolver(source) ? source : createDocxThemeResolver(source);
|
|
1150
|
+
}
|
|
1151
|
+
function docxThemeFont(resolver, key) {
|
|
1152
|
+
return key ? resolver.fonts.get(key.trim().toLowerCase()) : void 0;
|
|
1153
|
+
}
|
|
1154
|
+
function docxThemeColor(resolver, key, tint, shade) {
|
|
1155
|
+
const sourceKey = key?.trim().toLowerCase();
|
|
1156
|
+
const mappedKey = sourceKey ? mappedWordThemeColorKey(sourceKey, resolver.colorMapping) : void 0;
|
|
1157
|
+
const colorKey = mappedKey ? WORD_THEME_COLOR_KEYS.get(mappedKey) ?? mappedKey : void 0;
|
|
1158
|
+
const color = colorKey ? resolver.colors.get(colorKey) : void 0;
|
|
1159
|
+
if (!color) return;
|
|
1160
|
+
const channels = [
|
|
1161
|
+
Number.parseInt(color.slice(0, 2), 16),
|
|
1162
|
+
Number.parseInt(color.slice(2, 4), 16),
|
|
1163
|
+
Number.parseInt(color.slice(4, 6), 16)
|
|
1164
|
+
];
|
|
1165
|
+
const shadeFactor = hexFactor(shade);
|
|
1166
|
+
const tintFactor = hexFactor(tint);
|
|
1167
|
+
const transformed = channels.map((channel)=>{
|
|
1168
|
+
const shaded = void 0 === shadeFactor ? channel : channel * shadeFactor;
|
|
1169
|
+
const tinted = void 0 === tintFactor ? shaded : shaded + (255 - shaded) * tintFactor;
|
|
1170
|
+
return Math.max(0, Math.min(255, Math.round(tinted)));
|
|
1171
|
+
});
|
|
1172
|
+
return transformed.map((channel)=>channel.toString(16).padStart(2, '0')).join('');
|
|
1173
|
+
}
|
|
1174
|
+
function docxColorSchemeMapping(settingsDocument) {
|
|
1175
|
+
const root = settingsDocument?.documentElement;
|
|
1176
|
+
if (!root || 'settings' !== root.localName || !WORDPROCESSING_NAMESPACES.has(root.namespaceURI ?? '')) return new Map();
|
|
1177
|
+
const candidates = directChildren(root, 'clrSchemeMapping').filter((element)=>element.namespaceURI === root.namespaceURI);
|
|
1178
|
+
if (1 !== candidates.length) return new Map();
|
|
1179
|
+
return parseDocxColorSchemeMappingElement(candidates[0]) ?? new Map();
|
|
1180
|
+
}
|
|
1181
|
+
function parseDocxColorSchemeMappingElement(element) {
|
|
1182
|
+
const namespace = element?.namespaceURI ?? '';
|
|
1183
|
+
if (!element || 'clrSchemeMapping' !== element.localName || !WORDPROCESSING_NAMESPACES.has(namespace) || directChildren(element).length || Array.from(element.childNodes).some((node)=>node.nodeType === Node.TEXT_NODE && node.textContent?.trim())) return null;
|
|
1184
|
+
const semanticsByAttribute = new Map(Array.from(DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES).map(([semantic, attributeName])=>[
|
|
1185
|
+
attributeName,
|
|
1186
|
+
semantic
|
|
1187
|
+
]));
|
|
1188
|
+
const mapping = new Map();
|
|
1189
|
+
for (const item of Array.from(element.attributes)){
|
|
1190
|
+
if (item.namespaceURI === XMLNS_NAMESPACE || 'xmlns' === item.name || item.name.startsWith('xmlns:')) continue;
|
|
1191
|
+
const attributeName = xmlAttributeLocalName(item);
|
|
1192
|
+
const semantic = semanticsByAttribute.get(attributeName);
|
|
1193
|
+
const value = item.value.trim();
|
|
1194
|
+
if (xmlAttributeNamespace(element, item) !== namespace || !semantic || mapping.has(semantic) || !WORD_COLOR_SCHEME_INDEXES.has(value)) return null;
|
|
1195
|
+
mapping.set(semantic, value);
|
|
1196
|
+
}
|
|
1197
|
+
return mapping;
|
|
1198
|
+
}
|
|
1199
|
+
function mappedWordThemeColorKey(source, mapping) {
|
|
1200
|
+
let current = source;
|
|
1201
|
+
const visited = new Set();
|
|
1202
|
+
for(let depth = 0; depth < MAX_COLOR_MAPPING_DEPTH; depth += 1){
|
|
1203
|
+
if (visited.has(current)) break;
|
|
1204
|
+
visited.add(current);
|
|
1205
|
+
const next = mapping?.get(current)?.toLowerCase();
|
|
1206
|
+
if (!next || next === current) return current;
|
|
1207
|
+
current = next;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
function addThemeFontFamily(fonts, prefix, family) {
|
|
1211
|
+
if (!family) return;
|
|
1212
|
+
const latin = typeface(directChild(family, 'latin'));
|
|
1213
|
+
const eastAsia = typeface(directChild(family, 'ea')) || scriptTypeface(family, [
|
|
1214
|
+
'Hans',
|
|
1215
|
+
'Hant',
|
|
1216
|
+
'Jpan',
|
|
1217
|
+
'Hang'
|
|
1218
|
+
]) || latin;
|
|
1219
|
+
const complex = typeface(directChild(family, 'cs')) || latin;
|
|
1220
|
+
if (latin) {
|
|
1221
|
+
fonts.set(`${prefix}ascii`, latin);
|
|
1222
|
+
fonts.set(`${prefix}hansi`, latin);
|
|
1223
|
+
}
|
|
1224
|
+
if (eastAsia) fonts.set(`${prefix}eastasia`, eastAsia);
|
|
1225
|
+
if (complex) fonts.set(`${prefix}bidi`, complex);
|
|
1226
|
+
}
|
|
1227
|
+
function scriptTypeface(family, scripts) {
|
|
1228
|
+
const fonts = directChildren(family, 'font');
|
|
1229
|
+
for (const script of scripts){
|
|
1230
|
+
const font = fonts.find((candidate)=>drawingAttribute(candidate, "script") === script);
|
|
1231
|
+
const value = font ? typeface(font) : void 0;
|
|
1232
|
+
if (value) return value;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
function typeface(element) {
|
|
1236
|
+
const value = element ? drawingAttribute(element, 'typeface')?.trim() : void 0;
|
|
1237
|
+
return value || void 0;
|
|
1238
|
+
}
|
|
1239
|
+
function themeColorValue(element) {
|
|
1240
|
+
if (!element) return;
|
|
1241
|
+
const value = 'sysClr' === element.localName ? drawingAttribute(element, 'lastClr') : drawingAttribute(element, 'val');
|
|
1242
|
+
return value && /^[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : void 0;
|
|
1243
|
+
}
|
|
1244
|
+
function drawingAttribute(element, name) {
|
|
1245
|
+
return work_ooxml_package_attribute(element, name) ?? work_ooxml_package_attribute(element, `a:${name}`);
|
|
1246
|
+
}
|
|
1247
|
+
function hexFactor(value) {
|
|
1248
|
+
if (!value || !/^[0-9a-f]{2}$/i.test(value)) return;
|
|
1249
|
+
return Number.parseInt(value, 16) / 255;
|
|
1250
|
+
}
|
|
1251
|
+
function isDocxThemeResolver(source) {
|
|
1252
|
+
return Boolean(source && 'colors' in source && source.colors instanceof Map && 'fonts' in source && source.fonts instanceof Map);
|
|
1253
|
+
}
|
|
1014
1254
|
function paragraphAlignment(element, docx) {
|
|
1015
1255
|
const alignment = element.style.textAlign;
|
|
1016
1256
|
if ('center' === alignment) return docx.AlignmentType.CENTER;
|
|
@@ -1339,244 +1579,4 @@ function isParagraphPartRoot(root, path) {
|
|
|
1339
1579
|
const expected = /^word\/header\d*\.xml$/i.test(path) ? 'hdr' : /^word\/footer\d*\.xml$/i.test(path) ? 'ftr' : /^word\/footnotes\.xml$/i.test(path) ? 'footnotes' : /^word\/endnotes\.xml$/i.test(path) ? 'endnotes' : 'document';
|
|
1340
1580
|
return root.localName === expected && DOCX_WORDPROCESSING_NAMESPACES.has(root.namespaceURI ?? '');
|
|
1341
1581
|
}
|
|
1342
|
-
const WORD_THEME_COLOR_KEYS = new Map([
|
|
1343
|
-
[
|
|
1344
|
-
'dark1',
|
|
1345
|
-
'dk1'
|
|
1346
|
-
],
|
|
1347
|
-
[
|
|
1348
|
-
'light1',
|
|
1349
|
-
'lt1'
|
|
1350
|
-
],
|
|
1351
|
-
[
|
|
1352
|
-
'dark2',
|
|
1353
|
-
'dk2'
|
|
1354
|
-
],
|
|
1355
|
-
[
|
|
1356
|
-
'light2',
|
|
1357
|
-
'lt2'
|
|
1358
|
-
],
|
|
1359
|
-
[
|
|
1360
|
-
'background1',
|
|
1361
|
-
'lt1'
|
|
1362
|
-
],
|
|
1363
|
-
[
|
|
1364
|
-
'text1',
|
|
1365
|
-
'dk1'
|
|
1366
|
-
],
|
|
1367
|
-
[
|
|
1368
|
-
'background2',
|
|
1369
|
-
'lt2'
|
|
1370
|
-
],
|
|
1371
|
-
[
|
|
1372
|
-
'text2',
|
|
1373
|
-
'dk2'
|
|
1374
|
-
],
|
|
1375
|
-
[
|
|
1376
|
-
'hyperlink',
|
|
1377
|
-
'hlink'
|
|
1378
|
-
],
|
|
1379
|
-
[
|
|
1380
|
-
'followedhyperlink',
|
|
1381
|
-
'folhlink'
|
|
1382
|
-
]
|
|
1383
|
-
]);
|
|
1384
|
-
const DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES = new Map([
|
|
1385
|
-
[
|
|
1386
|
-
'background1',
|
|
1387
|
-
'bg1'
|
|
1388
|
-
],
|
|
1389
|
-
[
|
|
1390
|
-
'text1',
|
|
1391
|
-
't1'
|
|
1392
|
-
],
|
|
1393
|
-
[
|
|
1394
|
-
'background2',
|
|
1395
|
-
'bg2'
|
|
1396
|
-
],
|
|
1397
|
-
[
|
|
1398
|
-
'text2',
|
|
1399
|
-
't2'
|
|
1400
|
-
],
|
|
1401
|
-
[
|
|
1402
|
-
'accent1',
|
|
1403
|
-
'accent1'
|
|
1404
|
-
],
|
|
1405
|
-
[
|
|
1406
|
-
'accent2',
|
|
1407
|
-
'accent2'
|
|
1408
|
-
],
|
|
1409
|
-
[
|
|
1410
|
-
'accent3',
|
|
1411
|
-
'accent3'
|
|
1412
|
-
],
|
|
1413
|
-
[
|
|
1414
|
-
'accent4',
|
|
1415
|
-
'accent4'
|
|
1416
|
-
],
|
|
1417
|
-
[
|
|
1418
|
-
'accent5',
|
|
1419
|
-
'accent5'
|
|
1420
|
-
],
|
|
1421
|
-
[
|
|
1422
|
-
'accent6',
|
|
1423
|
-
'accent6'
|
|
1424
|
-
],
|
|
1425
|
-
[
|
|
1426
|
-
'hyperlink',
|
|
1427
|
-
'hyperlink'
|
|
1428
|
-
],
|
|
1429
|
-
[
|
|
1430
|
-
'followedhyperlink',
|
|
1431
|
-
'followedHyperlink'
|
|
1432
|
-
]
|
|
1433
|
-
]);
|
|
1434
|
-
const WORD_COLOR_SCHEME_INDEXES = new Set([
|
|
1435
|
-
'dark1',
|
|
1436
|
-
'light1',
|
|
1437
|
-
'dark2',
|
|
1438
|
-
'light2',
|
|
1439
|
-
'accent1',
|
|
1440
|
-
'accent2',
|
|
1441
|
-
'accent3',
|
|
1442
|
-
'accent4',
|
|
1443
|
-
'accent5',
|
|
1444
|
-
'accent6',
|
|
1445
|
-
'hyperlink',
|
|
1446
|
-
'followedHyperlink'
|
|
1447
|
-
]);
|
|
1448
|
-
const WORDPROCESSING_NAMESPACES = new Set([
|
|
1449
|
-
'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
|
|
1450
|
-
'http://purl.oclc.org/ooxml/wordprocessingml/main'
|
|
1451
|
-
]);
|
|
1452
|
-
const MAX_COLOR_MAPPING_DEPTH = 16;
|
|
1453
|
-
function createDocxThemeResolver(themeDocument, settingsDocument) {
|
|
1454
|
-
const colorMapping = docxColorSchemeMapping(settingsDocument);
|
|
1455
|
-
if (!themeDocument) return {
|
|
1456
|
-
colors: new Map(),
|
|
1457
|
-
colorMapping,
|
|
1458
|
-
fonts: new Map()
|
|
1459
|
-
};
|
|
1460
|
-
const fonts = new Map();
|
|
1461
|
-
const fontScheme = firstDescendant(themeDocument, 'fontScheme');
|
|
1462
|
-
addThemeFontFamily(fonts, 'major', fontScheme ? directChild(fontScheme, 'majorFont') : void 0);
|
|
1463
|
-
addThemeFontFamily(fonts, 'minor', fontScheme ? directChild(fontScheme, 'minorFont') : void 0);
|
|
1464
|
-
const colors = new Map();
|
|
1465
|
-
const colorScheme = firstDescendant(themeDocument, 'clrScheme');
|
|
1466
|
-
if (colorScheme) for (const entry of directChildren(colorScheme)){
|
|
1467
|
-
const color = themeColorValue(directChildren(entry)[0]);
|
|
1468
|
-
if (color) colors.set(entry.localName.toLowerCase(), color);
|
|
1469
|
-
}
|
|
1470
|
-
return {
|
|
1471
|
-
colors,
|
|
1472
|
-
colorMapping,
|
|
1473
|
-
fonts
|
|
1474
|
-
};
|
|
1475
|
-
}
|
|
1476
|
-
function resolveDocxThemeResolver(source) {
|
|
1477
|
-
return isDocxThemeResolver(source) ? source : createDocxThemeResolver(source);
|
|
1478
|
-
}
|
|
1479
|
-
function docxThemeFont(resolver, key) {
|
|
1480
|
-
return key ? resolver.fonts.get(key.trim().toLowerCase()) : void 0;
|
|
1481
|
-
}
|
|
1482
|
-
function docxThemeColor(resolver, key, tint, shade) {
|
|
1483
|
-
const sourceKey = key?.trim().toLowerCase();
|
|
1484
|
-
const mappedKey = sourceKey ? mappedWordThemeColorKey(sourceKey, resolver.colorMapping) : void 0;
|
|
1485
|
-
const colorKey = mappedKey ? WORD_THEME_COLOR_KEYS.get(mappedKey) ?? mappedKey : void 0;
|
|
1486
|
-
const color = colorKey ? resolver.colors.get(colorKey) : void 0;
|
|
1487
|
-
if (!color) return;
|
|
1488
|
-
const channels = [
|
|
1489
|
-
Number.parseInt(color.slice(0, 2), 16),
|
|
1490
|
-
Number.parseInt(color.slice(2, 4), 16),
|
|
1491
|
-
Number.parseInt(color.slice(4, 6), 16)
|
|
1492
|
-
];
|
|
1493
|
-
const shadeFactor = hexFactor(shade);
|
|
1494
|
-
const tintFactor = hexFactor(tint);
|
|
1495
|
-
const transformed = channels.map((channel)=>{
|
|
1496
|
-
const shaded = void 0 === shadeFactor ? channel : channel * shadeFactor;
|
|
1497
|
-
const tinted = void 0 === tintFactor ? shaded : shaded + (255 - shaded) * tintFactor;
|
|
1498
|
-
return Math.max(0, Math.min(255, Math.round(tinted)));
|
|
1499
|
-
});
|
|
1500
|
-
return transformed.map((channel)=>channel.toString(16).padStart(2, '0')).join('');
|
|
1501
|
-
}
|
|
1502
|
-
function docxColorSchemeMapping(settingsDocument) {
|
|
1503
|
-
const root = settingsDocument?.documentElement;
|
|
1504
|
-
if (!root || 'settings' !== root.localName || !WORDPROCESSING_NAMESPACES.has(root.namespaceURI ?? '')) return new Map();
|
|
1505
|
-
const candidates = directChildren(root, 'clrSchemeMapping').filter((element)=>element.namespaceURI === root.namespaceURI);
|
|
1506
|
-
if (1 !== candidates.length) return new Map();
|
|
1507
|
-
return parseDocxColorSchemeMappingElement(candidates[0]) ?? new Map();
|
|
1508
|
-
}
|
|
1509
|
-
function parseDocxColorSchemeMappingElement(element) {
|
|
1510
|
-
const namespace = element?.namespaceURI ?? '';
|
|
1511
|
-
if (!element || 'clrSchemeMapping' !== element.localName || !WORDPROCESSING_NAMESPACES.has(namespace) || directChildren(element).length || Array.from(element.childNodes).some((node)=>node.nodeType === Node.TEXT_NODE && node.textContent?.trim())) return null;
|
|
1512
|
-
const semanticsByAttribute = new Map(Array.from(DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES).map(([semantic, attributeName])=>[
|
|
1513
|
-
attributeName,
|
|
1514
|
-
semantic
|
|
1515
|
-
]));
|
|
1516
|
-
const mapping = new Map();
|
|
1517
|
-
for (const item of Array.from(element.attributes)){
|
|
1518
|
-
if (item.namespaceURI === XMLNS_NAMESPACE || 'xmlns' === item.name || item.name.startsWith('xmlns:')) continue;
|
|
1519
|
-
const attributeName = xmlAttributeLocalName(item);
|
|
1520
|
-
const semantic = semanticsByAttribute.get(attributeName);
|
|
1521
|
-
const value = item.value.trim();
|
|
1522
|
-
if (xmlAttributeNamespace(element, item) !== namespace || !semantic || mapping.has(semantic) || !WORD_COLOR_SCHEME_INDEXES.has(value)) return null;
|
|
1523
|
-
mapping.set(semantic, value);
|
|
1524
|
-
}
|
|
1525
|
-
return mapping;
|
|
1526
|
-
}
|
|
1527
|
-
function mappedWordThemeColorKey(source, mapping) {
|
|
1528
|
-
let current = source;
|
|
1529
|
-
const visited = new Set();
|
|
1530
|
-
for(let depth = 0; depth < MAX_COLOR_MAPPING_DEPTH; depth += 1){
|
|
1531
|
-
if (visited.has(current)) break;
|
|
1532
|
-
visited.add(current);
|
|
1533
|
-
const next = mapping?.get(current)?.toLowerCase();
|
|
1534
|
-
if (!next || next === current) return current;
|
|
1535
|
-
current = next;
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
function addThemeFontFamily(fonts, prefix, family) {
|
|
1539
|
-
if (!family) return;
|
|
1540
|
-
const latin = typeface(directChild(family, 'latin'));
|
|
1541
|
-
const eastAsia = typeface(directChild(family, 'ea')) || scriptTypeface(family, [
|
|
1542
|
-
'Hans',
|
|
1543
|
-
'Hant',
|
|
1544
|
-
'Jpan',
|
|
1545
|
-
'Hang'
|
|
1546
|
-
]) || latin;
|
|
1547
|
-
const complex = typeface(directChild(family, 'cs')) || latin;
|
|
1548
|
-
if (latin) {
|
|
1549
|
-
fonts.set(`${prefix}ascii`, latin);
|
|
1550
|
-
fonts.set(`${prefix}hansi`, latin);
|
|
1551
|
-
}
|
|
1552
|
-
if (eastAsia) fonts.set(`${prefix}eastasia`, eastAsia);
|
|
1553
|
-
if (complex) fonts.set(`${prefix}bidi`, complex);
|
|
1554
|
-
}
|
|
1555
|
-
function scriptTypeface(family, scripts) {
|
|
1556
|
-
const fonts = directChildren(family, 'font');
|
|
1557
|
-
for (const script of scripts){
|
|
1558
|
-
const font = fonts.find((candidate)=>drawingAttribute(candidate, "script") === script);
|
|
1559
|
-
const value = font ? typeface(font) : void 0;
|
|
1560
|
-
if (value) return value;
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
function typeface(element) {
|
|
1564
|
-
const value = element ? drawingAttribute(element, 'typeface')?.trim() : void 0;
|
|
1565
|
-
return value || void 0;
|
|
1566
|
-
}
|
|
1567
|
-
function themeColorValue(element) {
|
|
1568
|
-
if (!element) return;
|
|
1569
|
-
const value = 'sysClr' === element.localName ? drawingAttribute(element, 'lastClr') : drawingAttribute(element, 'val');
|
|
1570
|
-
return value && /^[0-9a-f]{6}$/i.test(value) ? value.toLowerCase() : void 0;
|
|
1571
|
-
}
|
|
1572
|
-
function drawingAttribute(element, name) {
|
|
1573
|
-
return work_ooxml_package_attribute(element, name) ?? work_ooxml_package_attribute(element, `a:${name}`);
|
|
1574
|
-
}
|
|
1575
|
-
function hexFactor(value) {
|
|
1576
|
-
if (!value || !/^[0-9a-f]{2}$/i.test(value)) return;
|
|
1577
|
-
return Number.parseInt(value, 16) / 255;
|
|
1578
|
-
}
|
|
1579
|
-
function isDocxThemeResolver(source) {
|
|
1580
|
-
return Boolean(source && 'colors' in source && source.colors instanceof Map && 'fonts' in source && source.fonts instanceof Map);
|
|
1581
|
-
}
|
|
1582
1582
|
export { DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, DOCX_WORDPROCESSING_NAMESPACES, DocxParagraphDefaultCollapsedPatchCollector, STRICT_WORDPROCESSING_NAMESPACE, XMLNS_NAMESPACE, XML_NAMESPACE, assertXmlRoot, cloneXmlElement, createDocxThemeResolver, cssColorToHex, cssFontFamily, cssFontSize, dataBoolean, docxCharacterPositionHalfPointsFromProperties, docxCharacterPositionValue, docxCharacterScalePercentFromProperties, docxCharacterScaleValue, docxCharacterSpacingTwipsFromProperties, docxCharacterSpacingValue, docxEmphasisMarkRunOptions, docxKerningThresholdValue, docxThemeColor, docxThemeFont, domDirection, hasNonWhitespaceXmlText, inspectDocxEmphasisMark, inspectDocxKerningThresholdHalfPoints, mergeDocxIgnorableExtensions, mergeDocxIgnorableExtensionsAtPairs, paragraphAlignment, paragraphBidirectional, paragraphDirectionOptions, paragraphIndent, paragraphPaginationOptions, paragraphSpacingOptions, paragraphTabStops, parseBoundedDocxInteger, parseDocxColorSchemeMappingElement, parseDocxParagraphDefaultCollapsed, parseDocxTwipsMeasure, patchDocxBibliography, patchDocxExplicitZeroCharacterSpacing, patchDocxExplicitZeroKerningThresholds, patchDocxParagraphDefaultCollapsed, readDocxBibliography, resolveDocxEmphasisMark, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver, xmlAttributeLocalName, xmlAttributeNamespace, xmlDeclaredPrefix, xmlNamespaceUri };
|
package/dist/0~7048.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useId, useRef, useState } from "react";
|
|
|
3
3
|
import { Check, ChevronDown, ChevronUp, Minus } from "lucide-react";
|
|
4
4
|
import { Dialog } from "./0~4595.js";
|
|
5
5
|
import { button_Button, office_text_field_OfficeTextField, office_text_field_OfficeTextArea } from "./0~6090.js";
|
|
6
|
-
import { OFFICE_KERNEL_SPREADSHEET_MAX_ROWS as office_kernel_spreadsheet_protocol_OFFICE_KERNEL_SPREADSHEET_MAX_ROWS, isOfficeKernelSpreadsheetError } from "./
|
|
6
|
+
import { OFFICE_KERNEL_SPREADSHEET_MAX_ROWS as office_kernel_spreadsheet_protocol_OFFICE_KERNEL_SPREADSHEET_MAX_ROWS, isOfficeKernelSpreadsheetError } from "./4121.js";
|
|
7
7
|
function CollectionState({ children, icon, actions, tone = 'neutral', role, className = '' }) {
|
|
8
8
|
return /*#__PURE__*/ jsxs("div", {
|
|
9
9
|
className: `ds-collection-state ${tone}${className ? ` ${className}` : ''}`,
|
package/dist/0~7614.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
|
-
import { descendants, directChildren, directChild, xmlNamespacePrefix, attribute, firstDescendant, parseXml } from "./
|
|
2
|
+
import { descendants, directChildren, directChild, xmlNamespacePrefix, attribute, firstDescendant, parseXml } from "./4121.js";
|
|
3
3
|
import { normalizePresentationChartDataLabelPosition, normalizePresentationChartDataLabels, normalizePresentationChartSeriesStyle } from "./0~work-presentation-charts.js";
|
|
4
4
|
import { parseXlsxChartSeriesStyle, xlsxChartSeriesMarkerXml, parseXlsxTrendline, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, isSupportedXlsxChartSeriesFormatting, parseXlsxChartPlotLayout, parseXlsxChartLegend, xlsxChartSeriesShapePropertiesXml, parseXlsxErrorBars } from "./4104.js";
|
|
5
5
|
import { workSpreadsheetChartSupportsErrorBars, workSpreadsheetChartSupportsGrouping, normalizeWorkSpreadsheetChartSmoothLines, workSpreadsheetChartSupportsSeriesAnalysis, normalizeWorkSpreadsheetChartSeriesStyle, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetChartOverlap, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetChartSupportsBarSpacing, normalizeWorkSpreadsheetChartLegendOverlay, normalizeWorkSpreadsheetChartGapWidth, normalizeWorkSpreadsheetChartGrouping, workSpreadsheetChartSupportsTrendlines, workSpreadsheetChartSupportsSmoothLines, normalizeWorkSpreadsheetTrendline } from "./8715.js";
|