@a3s-lab/office 0.45.0 → 0.46.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 +12 -0
- package/dist/{0~2330.js → 0~2133.js} +324 -18
- package/dist/0~document-editor.js +414 -9
- package/dist/0~work-docx-export.js +197 -2
- package/dist/0~work-docx-import.js +12 -3
- package/dist/0~work-office-diagnostics.js +7 -2
- package/dist/4174.js +400 -3
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +15 -1
- package/dist/internal/features/work/editors/document-text-box-ribbon.d.ts +4 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +2 -1
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +1 -0
- package/dist/internal/features/work/work-document-text-box.d.ts +64 -0
- package/dist/internal/features/work/work-docx-import.d.ts +3 -1
- package/dist/internal/features/work/work-docx-text-box-export.d.ts +25 -0
- package/dist/internal/features/work/work-docx-text-box-import.d.ts +26 -0
- package/dist/styles.css +63 -0
- package/package.json +6 -3
package/dist/4174.js
CHANGED
|
@@ -14956,7 +14956,7 @@ function measuredDocumentBlock({ block, element, from, to }) {
|
|
|
14956
14956
|
};
|
|
14957
14957
|
}
|
|
14958
14958
|
function shouldKeepDocumentBlockTogether(node) {
|
|
14959
|
-
return 'table' === node.type.name || 'blockquote' === node.type.name || 'codeBlock' === node.type.name || 'image' === node.type.name || 'documentNote' === node.type.name;
|
|
14959
|
+
return 'table' === node.type.name || 'blockquote' === node.type.name || 'codeBlock' === node.type.name || 'image' === node.type.name || 'documentTextBox' === node.type.name || 'documentNote' === node.type.name;
|
|
14960
14960
|
}
|
|
14961
14961
|
function documentBlockId(sectionPosition, index, position) {
|
|
14962
14962
|
return `section-${sectionPosition}-block-${index}-${position}`;
|
|
@@ -18093,6 +18093,402 @@ function work_document_table_of_contents_node_hiddenAttribute(defaultValue) {
|
|
|
18093
18093
|
function work_document_table_of_contents_node_stringAttribute(value) {
|
|
18094
18094
|
return 'string' == typeof value ? value.trim() : '';
|
|
18095
18095
|
}
|
|
18096
|
+
const DOCUMENT_TEXT_BOX_DEFAULTS = {
|
|
18097
|
+
id: '',
|
|
18098
|
+
width: 120,
|
|
18099
|
+
height: 45,
|
|
18100
|
+
layout: 'inline',
|
|
18101
|
+
horizontalOffset: null,
|
|
18102
|
+
verticalOffset: null,
|
|
18103
|
+
horizontalReference: 'column',
|
|
18104
|
+
verticalReference: 'paragraph',
|
|
18105
|
+
fill: '#fff2cc',
|
|
18106
|
+
borderColor: '#4472c4',
|
|
18107
|
+
borderWidth: 0.35,
|
|
18108
|
+
padding: 3,
|
|
18109
|
+
verticalAlign: 'top',
|
|
18110
|
+
docPropertiesId: null
|
|
18111
|
+
};
|
|
18112
|
+
const DOCUMENT_TEXT_BOX_LIMITS = {
|
|
18113
|
+
width: {
|
|
18114
|
+
min: 20,
|
|
18115
|
+
max: 558.7
|
|
18116
|
+
},
|
|
18117
|
+
height: {
|
|
18118
|
+
min: 10,
|
|
18119
|
+
max: 558.7
|
|
18120
|
+
},
|
|
18121
|
+
offset: {
|
|
18122
|
+
min: -558.7,
|
|
18123
|
+
max: 558.7
|
|
18124
|
+
},
|
|
18125
|
+
borderWidth: {
|
|
18126
|
+
min: 0,
|
|
18127
|
+
max: 10
|
|
18128
|
+
},
|
|
18129
|
+
padding: {
|
|
18130
|
+
min: 0,
|
|
18131
|
+
max: 25
|
|
18132
|
+
}
|
|
18133
|
+
};
|
|
18134
|
+
const TEXT_BOX_ID_MAX_LENGTH = 160;
|
|
18135
|
+
const TEXT_BOX_COLOR_PATTERN = /^#[0-9a-f]{6}$/i;
|
|
18136
|
+
const TEXT_BOX_MARKER_ATTRIBUTES = [
|
|
18137
|
+
'id',
|
|
18138
|
+
'width',
|
|
18139
|
+
'height',
|
|
18140
|
+
'layout',
|
|
18141
|
+
'horizontalOffset',
|
|
18142
|
+
'verticalOffset',
|
|
18143
|
+
'horizontalReference',
|
|
18144
|
+
'verticalReference',
|
|
18145
|
+
'fill',
|
|
18146
|
+
'borderColor',
|
|
18147
|
+
'borderWidth',
|
|
18148
|
+
'padding',
|
|
18149
|
+
'verticalAlign',
|
|
18150
|
+
'docPropertiesId'
|
|
18151
|
+
];
|
|
18152
|
+
const DocumentTextBox = core_Node.create({
|
|
18153
|
+
name: 'documentTextBox',
|
|
18154
|
+
group: 'block',
|
|
18155
|
+
content: 'inline*',
|
|
18156
|
+
defining: true,
|
|
18157
|
+
isolating: true,
|
|
18158
|
+
selectable: true,
|
|
18159
|
+
addAttributes () {
|
|
18160
|
+
return {
|
|
18161
|
+
id: dataAttribute(''),
|
|
18162
|
+
width: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.width),
|
|
18163
|
+
height: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.height),
|
|
18164
|
+
layout: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.layout),
|
|
18165
|
+
horizontalOffset: nullableDataAttribute(),
|
|
18166
|
+
verticalOffset: nullableDataAttribute(),
|
|
18167
|
+
horizontalReference: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.horizontalReference),
|
|
18168
|
+
verticalReference: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.verticalReference),
|
|
18169
|
+
fill: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.fill),
|
|
18170
|
+
borderColor: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.borderColor),
|
|
18171
|
+
borderWidth: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.borderWidth),
|
|
18172
|
+
padding: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.padding),
|
|
18173
|
+
verticalAlign: dataAttribute(DOCUMENT_TEXT_BOX_DEFAULTS.verticalAlign),
|
|
18174
|
+
docPropertiesId: nullableDataAttribute()
|
|
18175
|
+
};
|
|
18176
|
+
},
|
|
18177
|
+
parseHTML () {
|
|
18178
|
+
return [
|
|
18179
|
+
{
|
|
18180
|
+
tag: 'div[data-document-text-box]',
|
|
18181
|
+
getAttrs: (element)=>{
|
|
18182
|
+
if (!(element instanceof HTMLElement)) return false;
|
|
18183
|
+
return textBoxAttributesFromElement(element);
|
|
18184
|
+
}
|
|
18185
|
+
}
|
|
18186
|
+
];
|
|
18187
|
+
},
|
|
18188
|
+
renderHTML ({ node, HTMLAttributes }) {
|
|
18189
|
+
const properties = normalizeDocumentTextBoxProperties(node.attrs);
|
|
18190
|
+
return [
|
|
18191
|
+
'div',
|
|
18192
|
+
mergeAttributes(HTMLAttributes, textBoxDomAttributes(properties), {
|
|
18193
|
+
class: 'work-document-text-box',
|
|
18194
|
+
contenteditable: void 0,
|
|
18195
|
+
style: textBoxCss(properties),
|
|
18196
|
+
role: 'textbox',
|
|
18197
|
+
'aria-label': '文本框'
|
|
18198
|
+
}),
|
|
18199
|
+
0
|
|
18200
|
+
];
|
|
18201
|
+
},
|
|
18202
|
+
renderText ({ node }) {
|
|
18203
|
+
return node.textContent;
|
|
18204
|
+
},
|
|
18205
|
+
addCommands () {
|
|
18206
|
+
return {
|
|
18207
|
+
insertDocumentTextBox: (text = '', options = {})=>({ dispatch, editor, state, tr })=>insertDocumentTextBoxCommand({
|
|
18208
|
+
dispatch,
|
|
18209
|
+
editor,
|
|
18210
|
+
state,
|
|
18211
|
+
tr
|
|
18212
|
+
}, text, options),
|
|
18213
|
+
setDocumentTextBoxProperties: (value, options = {})=>({ chain, state, tr })=>{
|
|
18214
|
+
if (!selectedDocumentTextBox(state)) return false;
|
|
18215
|
+
const attributes = textBoxAttributesForChanges(value);
|
|
18216
|
+
if (!Object.keys(attributes).length) return false;
|
|
18217
|
+
closeHistory(tr);
|
|
18218
|
+
let commandChain = chain();
|
|
18219
|
+
if (false !== options.restoreFocus) commandChain = commandChain.focus();
|
|
18220
|
+
return commandChain.updateAttributes(this.name, attributes).run();
|
|
18221
|
+
},
|
|
18222
|
+
deleteDocumentTextBox: (options = {})=>({ dispatch, editor, state, tr })=>{
|
|
18223
|
+
const selected = selectedDocumentTextBox(state);
|
|
18224
|
+
if (!selected) return false;
|
|
18225
|
+
if (!dispatch) return true;
|
|
18226
|
+
closeHistory(tr);
|
|
18227
|
+
tr.delete(selected.position, selected.position + selected.node.nodeSize);
|
|
18228
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(Math.min(selected.position, tr.doc.content.size)), -1));
|
|
18229
|
+
dispatch(tr.scrollIntoView());
|
|
18230
|
+
if (false !== options.restoreFocus) editor.view.focus();
|
|
18231
|
+
return true;
|
|
18232
|
+
}
|
|
18233
|
+
};
|
|
18234
|
+
},
|
|
18235
|
+
addKeyboardShortcuts () {
|
|
18236
|
+
return {
|
|
18237
|
+
Backspace: ()=>deleteEmptyDocumentTextBox(this.editor),
|
|
18238
|
+
Delete: ()=>deleteEmptyDocumentTextBox(this.editor)
|
|
18239
|
+
};
|
|
18240
|
+
},
|
|
18241
|
+
addProseMirrorPlugins () {
|
|
18242
|
+
return [
|
|
18243
|
+
new Plugin({
|
|
18244
|
+
appendTransaction: (transactions, _oldState, state)=>{
|
|
18245
|
+
if (!transactions.some((transaction)=>transaction.docChanged)) return null;
|
|
18246
|
+
const seen = new Set();
|
|
18247
|
+
const updates = [];
|
|
18248
|
+
state.doc.descendants((node, position)=>{
|
|
18249
|
+
if (node.type.name !== this.name) return;
|
|
18250
|
+
const current = normalizeDocumentTextBoxId(node.attrs.id);
|
|
18251
|
+
const id = current && !seen.has(current) ? current : createWorkId('text-box');
|
|
18252
|
+
seen.add(id);
|
|
18253
|
+
if (id !== node.attrs.id) updates.push({
|
|
18254
|
+
position,
|
|
18255
|
+
id
|
|
18256
|
+
});
|
|
18257
|
+
});
|
|
18258
|
+
if (!updates.length) return null;
|
|
18259
|
+
const transaction = state.tr;
|
|
18260
|
+
for (const update of updates){
|
|
18261
|
+
const node = state.doc.nodeAt(update.position);
|
|
18262
|
+
if (node) transaction.setNodeMarkup(update.position, void 0, {
|
|
18263
|
+
...node.attrs,
|
|
18264
|
+
id: update.id
|
|
18265
|
+
});
|
|
18266
|
+
}
|
|
18267
|
+
transaction.setMeta('addToHistory', false);
|
|
18268
|
+
return transaction;
|
|
18269
|
+
}
|
|
18270
|
+
})
|
|
18271
|
+
];
|
|
18272
|
+
}
|
|
18273
|
+
});
|
|
18274
|
+
function documentTextBoxProperties(editor) {
|
|
18275
|
+
return normalizeDocumentTextBoxProperties(editor.getAttributes('documentTextBox'));
|
|
18276
|
+
}
|
|
18277
|
+
function normalizeDocumentTextBoxProperties(value) {
|
|
18278
|
+
return {
|
|
18279
|
+
id: normalizeDocumentTextBoxId(value.id),
|
|
18280
|
+
width: boundedNumber(value.width, DOCUMENT_TEXT_BOX_DEFAULTS.width, DOCUMENT_TEXT_BOX_LIMITS.width.min, DOCUMENT_TEXT_BOX_LIMITS.width.max),
|
|
18281
|
+
height: boundedNumber(value.height, DOCUMENT_TEXT_BOX_DEFAULTS.height, DOCUMENT_TEXT_BOX_LIMITS.height.min, DOCUMENT_TEXT_BOX_LIMITS.height.max),
|
|
18282
|
+
layout: 'floating' === value.layout ? 'floating' : 'inline',
|
|
18283
|
+
horizontalOffset: nullableBoundedNumber(value.horizontalOffset, DOCUMENT_TEXT_BOX_LIMITS.offset.min, DOCUMENT_TEXT_BOX_LIMITS.offset.max),
|
|
18284
|
+
verticalOffset: nullableBoundedNumber(value.verticalOffset, DOCUMENT_TEXT_BOX_LIMITS.offset.min, DOCUMENT_TEXT_BOX_LIMITS.offset.max),
|
|
18285
|
+
horizontalReference: textBoxHorizontalReference(value.horizontalReference),
|
|
18286
|
+
verticalReference: textBoxVerticalReference(value.verticalReference),
|
|
18287
|
+
fill: normalizeTextBoxFill(value.fill),
|
|
18288
|
+
borderColor: normalizeTextBoxBorderColor(value.borderColor),
|
|
18289
|
+
borderWidth: boundedNumber(value.borderWidth, DOCUMENT_TEXT_BOX_DEFAULTS.borderWidth, DOCUMENT_TEXT_BOX_LIMITS.borderWidth.min, DOCUMENT_TEXT_BOX_LIMITS.borderWidth.max),
|
|
18290
|
+
padding: boundedNumber(value.padding, DOCUMENT_TEXT_BOX_DEFAULTS.padding, DOCUMENT_TEXT_BOX_LIMITS.padding.min, DOCUMENT_TEXT_BOX_LIMITS.padding.max),
|
|
18291
|
+
verticalAlign: textBoxVerticalAlign(value.verticalAlign),
|
|
18292
|
+
docPropertiesId: nullableInteger(value.docPropertiesId, 0, 0xffffffff)
|
|
18293
|
+
};
|
|
18294
|
+
}
|
|
18295
|
+
function textBoxCss(value) {
|
|
18296
|
+
const properties = normalizeDocumentTextBoxProperties(value);
|
|
18297
|
+
return [
|
|
18298
|
+
`--work-document-text-box-width:${work_document_text_box_formatNumber(properties.width)}mm`,
|
|
18299
|
+
`--work-document-text-box-height:${work_document_text_box_formatNumber(properties.height)}mm`,
|
|
18300
|
+
`--work-document-text-box-padding:${work_document_text_box_formatNumber(properties.padding)}mm`,
|
|
18301
|
+
`--work-document-text-box-fill:${properties.fill}`,
|
|
18302
|
+
`--work-document-text-box-border-color:${'none' === properties.borderColor ? 'transparent' : properties.borderColor}`,
|
|
18303
|
+
`--work-document-text-box-border-width:${work_document_text_box_formatNumber(properties.borderWidth)}mm`,
|
|
18304
|
+
`--work-document-text-box-vertical-align:${properties.verticalAlign}`,
|
|
18305
|
+
...'floating' === properties.layout ? [
|
|
18306
|
+
`--work-document-text-box-horizontal-offset:${formatNullableNumber(properties.horizontalOffset)}mm`,
|
|
18307
|
+
`--work-document-text-box-vertical-offset:${formatNullableNumber(properties.verticalOffset)}mm`
|
|
18308
|
+
] : []
|
|
18309
|
+
].join(';');
|
|
18310
|
+
}
|
|
18311
|
+
function textBoxDomAttributes(value) {
|
|
18312
|
+
const properties = normalizeDocumentTextBoxProperties(value);
|
|
18313
|
+
return {
|
|
18314
|
+
'data-document-text-box': 'true',
|
|
18315
|
+
'data-text-box-id': properties.id || void 0,
|
|
18316
|
+
'data-text-box-width': work_document_text_box_formatNumber(properties.width),
|
|
18317
|
+
'data-text-box-height': work_document_text_box_formatNumber(properties.height),
|
|
18318
|
+
'data-text-box-layout': properties.layout,
|
|
18319
|
+
'data-text-box-horizontal-offset': null === properties.horizontalOffset ? void 0 : work_document_text_box_formatNumber(properties.horizontalOffset),
|
|
18320
|
+
'data-text-box-vertical-offset': null === properties.verticalOffset ? void 0 : work_document_text_box_formatNumber(properties.verticalOffset),
|
|
18321
|
+
'data-text-box-horizontal-reference': properties.horizontalReference,
|
|
18322
|
+
'data-text-box-vertical-reference': properties.verticalReference,
|
|
18323
|
+
'data-text-box-fill': properties.fill,
|
|
18324
|
+
'data-text-box-border-color': properties.borderColor,
|
|
18325
|
+
'data-text-box-border-width': work_document_text_box_formatNumber(properties.borderWidth),
|
|
18326
|
+
'data-text-box-padding': work_document_text_box_formatNumber(properties.padding),
|
|
18327
|
+
'data-text-box-vertical-align': properties.verticalAlign,
|
|
18328
|
+
'data-text-box-doc-properties-id': null === properties.docPropertiesId ? void 0 : String(properties.docPropertiesId)
|
|
18329
|
+
};
|
|
18330
|
+
}
|
|
18331
|
+
function insertDocumentTextBoxCommand({ dispatch, editor, state, tr }, text, options) {
|
|
18332
|
+
const section = activeDocumentSectionFromState(state);
|
|
18333
|
+
const textBoxType = editor.schema.nodes.documentTextBox;
|
|
18334
|
+
const paragraphType = editor.schema.nodes.paragraph;
|
|
18335
|
+
if (!section || !textBoxType || !paragraphType) return false;
|
|
18336
|
+
const child = work_document_text_box_activeSectionChild(section, state.selection.from);
|
|
18337
|
+
if (!child) return false;
|
|
18338
|
+
if (!dispatch) return true;
|
|
18339
|
+
const properties = normalizeDocumentTextBoxProperties({
|
|
18340
|
+
...DOCUMENT_TEXT_BOX_DEFAULTS,
|
|
18341
|
+
...options,
|
|
18342
|
+
id: options.id || createWorkId('text-box')
|
|
18343
|
+
});
|
|
18344
|
+
const content = text ? editor.schema.text(text) : void 0;
|
|
18345
|
+
const textBox = textBoxType.create(properties, content);
|
|
18346
|
+
const insertPosition = section.position + 1 + child.offset + child.nodeSize;
|
|
18347
|
+
tr.insert(insertPosition, textBox);
|
|
18348
|
+
const selectionPosition = insertPosition + 1;
|
|
18349
|
+
if (child.index === section.node.childCount - 1) {
|
|
18350
|
+
const paragraphPosition = insertPosition + textBox.nodeSize;
|
|
18351
|
+
tr.insert(paragraphPosition, paragraphType.create());
|
|
18352
|
+
}
|
|
18353
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(selectionPosition)));
|
|
18354
|
+
tr.scrollIntoView();
|
|
18355
|
+
return true;
|
|
18356
|
+
}
|
|
18357
|
+
function selectedDocumentTextBox(state) {
|
|
18358
|
+
const { $from } = state.selection;
|
|
18359
|
+
for(let depth = $from.depth; depth > 0; depth -= 1){
|
|
18360
|
+
const node = $from.node(depth);
|
|
18361
|
+
if ('documentTextBox' === node.type.name) return {
|
|
18362
|
+
node,
|
|
18363
|
+
position: $from.before(depth)
|
|
18364
|
+
};
|
|
18365
|
+
}
|
|
18366
|
+
if (state.selection instanceof NodeSelection && 'documentTextBox' === state.selection.node.type.name) return {
|
|
18367
|
+
node: state.selection.node,
|
|
18368
|
+
position: state.selection.from
|
|
18369
|
+
};
|
|
18370
|
+
return null;
|
|
18371
|
+
}
|
|
18372
|
+
function deleteEmptyDocumentTextBox(editor) {
|
|
18373
|
+
const selected = selectedDocumentTextBox(editor.state);
|
|
18374
|
+
if (!selected || selected.node.content.size > 0) return false;
|
|
18375
|
+
return editor.commands.deleteDocumentTextBox();
|
|
18376
|
+
}
|
|
18377
|
+
function textBoxAttributesForChanges(value) {
|
|
18378
|
+
const attributes = {};
|
|
18379
|
+
for (const name of TEXT_BOX_MARKER_ATTRIBUTES)if (name in value) attributes[name] = normalizeDocumentTextBoxProperties({
|
|
18380
|
+
...DOCUMENT_TEXT_BOX_DEFAULTS,
|
|
18381
|
+
...value
|
|
18382
|
+
})[name];
|
|
18383
|
+
return attributes;
|
|
18384
|
+
}
|
|
18385
|
+
function textBoxAttributesFromElement(element) {
|
|
18386
|
+
return {
|
|
18387
|
+
id: element.dataset.textBoxId ?? '',
|
|
18388
|
+
width: element.dataset.textBoxWidth,
|
|
18389
|
+
height: element.dataset.textBoxHeight,
|
|
18390
|
+
layout: element.dataset.textBoxLayout,
|
|
18391
|
+
horizontalOffset: element.dataset.textBoxHorizontalOffset,
|
|
18392
|
+
verticalOffset: element.dataset.textBoxVerticalOffset,
|
|
18393
|
+
horizontalReference: element.dataset.textBoxHorizontalReference,
|
|
18394
|
+
verticalReference: element.dataset.textBoxVerticalReference,
|
|
18395
|
+
fill: element.dataset.textBoxFill,
|
|
18396
|
+
borderColor: element.dataset.textBoxBorderColor,
|
|
18397
|
+
borderWidth: element.dataset.textBoxBorderWidth,
|
|
18398
|
+
padding: element.dataset.textBoxPadding,
|
|
18399
|
+
verticalAlign: element.dataset.textBoxVerticalAlign,
|
|
18400
|
+
docPropertiesId: element.dataset.textBoxDocPropertiesId
|
|
18401
|
+
};
|
|
18402
|
+
}
|
|
18403
|
+
function documentTextBoxPropertiesFromElement(element) {
|
|
18404
|
+
return normalizeDocumentTextBoxProperties({
|
|
18405
|
+
id: element.getAttribute('data-text-box-id'),
|
|
18406
|
+
width: element.getAttribute('data-text-box-width'),
|
|
18407
|
+
height: element.getAttribute('data-text-box-height'),
|
|
18408
|
+
layout: element.getAttribute('data-text-box-layout'),
|
|
18409
|
+
horizontalOffset: element.getAttribute('data-text-box-horizontal-offset'),
|
|
18410
|
+
verticalOffset: element.getAttribute('data-text-box-vertical-offset'),
|
|
18411
|
+
horizontalReference: element.getAttribute('data-text-box-horizontal-reference'),
|
|
18412
|
+
verticalReference: element.getAttribute('data-text-box-vertical-reference'),
|
|
18413
|
+
fill: element.getAttribute('data-text-box-fill'),
|
|
18414
|
+
borderColor: element.getAttribute('data-text-box-border-color'),
|
|
18415
|
+
borderWidth: element.getAttribute('data-text-box-border-width'),
|
|
18416
|
+
padding: element.getAttribute('data-text-box-padding'),
|
|
18417
|
+
verticalAlign: element.getAttribute('data-text-box-vertical-align'),
|
|
18418
|
+
docPropertiesId: element.getAttribute('data-text-box-doc-properties-id')
|
|
18419
|
+
});
|
|
18420
|
+
}
|
|
18421
|
+
function dataAttribute(defaultValue) {
|
|
18422
|
+
return {
|
|
18423
|
+
default: defaultValue,
|
|
18424
|
+
parseHTML: ()=>defaultValue,
|
|
18425
|
+
rendered: false
|
|
18426
|
+
};
|
|
18427
|
+
}
|
|
18428
|
+
function nullableDataAttribute() {
|
|
18429
|
+
return {
|
|
18430
|
+
default: null,
|
|
18431
|
+
parseHTML: ()=>null,
|
|
18432
|
+
rendered: false
|
|
18433
|
+
};
|
|
18434
|
+
}
|
|
18435
|
+
function normalizeDocumentTextBoxId(value) {
|
|
18436
|
+
return 'string' == typeof value ? value.trim().slice(0, TEXT_BOX_ID_MAX_LENGTH) : '';
|
|
18437
|
+
}
|
|
18438
|
+
function normalizeTextBoxFill(value) {
|
|
18439
|
+
if ('transparent' === value) return 'transparent';
|
|
18440
|
+
return normalizeTextBoxColor(value, DOCUMENT_TEXT_BOX_DEFAULTS.fill);
|
|
18441
|
+
}
|
|
18442
|
+
function normalizeTextBoxBorderColor(value) {
|
|
18443
|
+
if ('none' === value) return 'none';
|
|
18444
|
+
return normalizeTextBoxColor(value, DOCUMENT_TEXT_BOX_DEFAULTS.borderColor);
|
|
18445
|
+
}
|
|
18446
|
+
function normalizeTextBoxColor(value, fallback) {
|
|
18447
|
+
if ('string' != typeof value) return fallback;
|
|
18448
|
+
const normalized = value.trim().toLowerCase();
|
|
18449
|
+
return TEXT_BOX_COLOR_PATTERN.test(normalized) ? normalized : fallback;
|
|
18450
|
+
}
|
|
18451
|
+
function textBoxHorizontalReference(value) {
|
|
18452
|
+
return 'margin' === value || 'page' === value ? value : 'column';
|
|
18453
|
+
}
|
|
18454
|
+
function textBoxVerticalReference(value) {
|
|
18455
|
+
return 'margin' === value || 'page' === value ? value : 'paragraph';
|
|
18456
|
+
}
|
|
18457
|
+
function textBoxVerticalAlign(value) {
|
|
18458
|
+
return 'center' === value || 'bottom' === value ? value : 'top';
|
|
18459
|
+
}
|
|
18460
|
+
function boundedNumber(value, fallback, min, max) {
|
|
18461
|
+
const number = 'number' == typeof value ? value : Number(value);
|
|
18462
|
+
if (!Number.isFinite(number)) return fallback;
|
|
18463
|
+
return Number(Math.min(max, Math.max(min, number)).toFixed(2));
|
|
18464
|
+
}
|
|
18465
|
+
function nullableBoundedNumber(value, min, max) {
|
|
18466
|
+
if (null == value || '' === value) return null;
|
|
18467
|
+
return boundedNumber(value, 0, min, max);
|
|
18468
|
+
}
|
|
18469
|
+
function nullableInteger(value, min, max) {
|
|
18470
|
+
if (null == value || '' === value) return null;
|
|
18471
|
+
const number = 'number' == typeof value ? value : Number(value);
|
|
18472
|
+
return Number.isSafeInteger(number) ? Math.min(max, Math.max(min, number)) : null;
|
|
18473
|
+
}
|
|
18474
|
+
function work_document_text_box_formatNumber(value) {
|
|
18475
|
+
return Number(value.toFixed(2)).toString();
|
|
18476
|
+
}
|
|
18477
|
+
function formatNullableNumber(value) {
|
|
18478
|
+
return null === value ? '0' : work_document_text_box_formatNumber(value);
|
|
18479
|
+
}
|
|
18480
|
+
function work_document_text_box_activeSectionChild(section, selectionPosition) {
|
|
18481
|
+
const relativePosition = Math.max(0, selectionPosition - section.position - 1);
|
|
18482
|
+
let active = null;
|
|
18483
|
+
section.node.forEach((node, offset, index)=>{
|
|
18484
|
+
if (relativePosition >= offset) active = {
|
|
18485
|
+
index,
|
|
18486
|
+
offset,
|
|
18487
|
+
nodeSize: node.nodeSize
|
|
18488
|
+
};
|
|
18489
|
+
});
|
|
18490
|
+
return active;
|
|
18491
|
+
}
|
|
18096
18492
|
const BORDER_EDGES = [
|
|
18097
18493
|
'top',
|
|
18098
18494
|
'right',
|
|
@@ -20021,6 +20417,7 @@ function createWorkDocumentExtensions(options = {}) {
|
|
|
20021
20417
|
minHeight: 40
|
|
20022
20418
|
}
|
|
20023
20419
|
}),
|
|
20420
|
+
DocumentTextBox,
|
|
20024
20421
|
TableKit.configure({
|
|
20025
20422
|
table: false,
|
|
20026
20423
|
tableCell: false,
|
|
@@ -21913,7 +22310,7 @@ async function importWorkDocumentFile(file, extension, context) {
|
|
|
21913
22310
|
recordDocumentImportMeasure('a3s-office.document.mammoth', mammothStartedAt, documentImportNow());
|
|
21914
22311
|
context?.controller.report('parsing', 0.8);
|
|
21915
22312
|
const markersStartedAt = documentImportNow();
|
|
21916
|
-
html = prepared ? applyDocxSectionsToHtml(result.value, prepared.sections, prepared.captionMarkers, prepared.bookmarkMarkers, prepared.changeMarkers, prepared.commentMarkers, prepared.fieldMarkers, prepared.tableOfContentsMarkers, prepared.indexMarkers, prepared.equationMarkers, prepared.citationMarkers, prepared.listMarkers, prepared.numberingChangeMarkers, prepared.imageLayoutMarkers, prepared.paragraphIdentityMarkers, prepared.paragraphFormattingChangeMarkers, prepared.paragraphAlignmentMarkers, prepared.runFormattingMarkers, prepared.paragraphDirectionMarkers, prepared.paragraphIndentMarkers, prepared.paragraphSpacingMarkers, prepared.paragraphBorderMarkers, prepared.paragraphShadingMarkers, prepared.paragraphPaginationMarkers, prepared.bibliography, prepared.tabStopMarkers, prepared.tableCellMarkers, prepared.tableRowMarkers, prepared.tableSizingMarkers) : result.value;
|
|
22313
|
+
html = prepared ? applyDocxSectionsToHtml(result.value, prepared.sections, prepared.captionMarkers, prepared.bookmarkMarkers, prepared.changeMarkers, prepared.commentMarkers, prepared.fieldMarkers, prepared.tableOfContentsMarkers, prepared.indexMarkers, prepared.equationMarkers, prepared.citationMarkers, prepared.listMarkers, prepared.numberingChangeMarkers, prepared.imageLayoutMarkers, prepared.paragraphIdentityMarkers, prepared.paragraphFormattingChangeMarkers, prepared.paragraphAlignmentMarkers, prepared.runFormattingMarkers, prepared.paragraphDirectionMarkers, prepared.paragraphIndentMarkers, prepared.paragraphSpacingMarkers, prepared.paragraphBorderMarkers, prepared.paragraphShadingMarkers, prepared.paragraphPaginationMarkers, prepared.bibliography, prepared.tabStopMarkers, prepared.tableCellMarkers, prepared.tableRowMarkers, prepared.tableSizingMarkers, prepared.textBoxMarkers) : result.value;
|
|
21917
22314
|
recordDocumentImportMeasure('a3s-office.document.markers', markersStartedAt, documentImportNow());
|
|
21918
22315
|
const layout = prepared ? {
|
|
21919
22316
|
...documentContentLayoutProperties(prepared.sections[0].layout),
|
|
@@ -22111,4 +22508,4 @@ function registerDocumentPageSurfaceGeometry(element, provider) {
|
|
|
22111
22508
|
function documentPageSurfaceGeometryForElement(element) {
|
|
22112
22509
|
return documentPageSurfaceProviders.get(element)?.() ?? null;
|
|
22113
22510
|
}
|
|
22114
|
-
export { DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, DOCUMENT_CHUNK_HYDRATION_META, DOCUMENT_CHUNK_PAGINATION_META, DOCUMENT_CHUNK_VISIBLE_IDS_META, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, DOCUMENT_OPEN_TYPE_ATTRIBUTE, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_PARAGRAPH_CHANGE_ATTRIBUTES, DOCUMENT_PARAGRAPH_FORMAT_ATTRIBUTES, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, DOCUMENT_TABLE_STYLE_OPTIONS, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, DocumentCharacterFormatting, DocumentEquation, DocumentFontFamily, DocumentHighlight, DocumentImage, DocumentParagraphFormatting, DocumentScriptFontFormatting, DocumentStrike, DocumentSubscript, DocumentSuperscript, DocumentTableRowIdentity, DocumentTextStyle, DocumentUnderline, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageTransformToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, applyDocumentTextCaseStyle, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createSchemaDerivedWorkDocumentModel, createWorkDocumentBlob, createWorkDocumentExtensions, createWorkDocumentModel, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, defaultDocumentImageTransform, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentCharacterPositionDomAttributes, documentCharacterPositionHalfPointsFromElement, documentCharacterPositionPoints, documentCharacterScaleDomAttributes, documentCharacterScalePercentFromElement, documentCharacterSpacingDomAttributes, documentCharacterSpacingPoints, documentCharacterSpacingTwipsFromElement, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEmphasisMarkDomAttributes, documentEmphasisMarkFromElement, documentEquationFromElement, documentEquationText, documentHasIndex, documentHasTableOfContents, documentHiddenTextDomAttributes, documentHiddenTextFromElement, documentHiddenTextKeyboardShortcut, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageTransformFromElement, documentImageWrapContourFromElement, documentInitialSectionLayout, documentKerningDomAttributes, documentKerningIsEffective, documentKerningThresholdHalfPointsFromElement, documentKerningThresholdPoints, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentLegacyTextEffectsConflict, documentLegacyTextEffectsCss, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsFromElement, documentLegacyTextEffectsFromTextStyleAttributes, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOpenTypeCssProperties, documentOpenTypeDomAttributes, documentOpenTypeFeaturesFromElement, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, documentParagraphDirection, documentParagraphIndent, documentParagraphPagination, documentParagraphSpacing, documentParagraphTabStops, documentSectionById, documentSectionDomAttributes, documentSections, documentStrikeDomAttributes, documentStrikeFormattingFromElement, documentStrikeStyle, documentTabLeaderLabel, documentTableBordersFromElement, documentTableCellFormat, documentTableCellMarginOverridesFromElement, documentTableColumnPercentagesFromElement, documentTableGeometryFromElement, documentTableHorizontalAlignment, documentTableRowIdentityFromElement, documentTableRowOptions, documentTableSizing, documentTextCaseFromWordFlags, documentTextCaseKeyboardShortcuts, documentTextLayoutBatches, documentTextStatistics, documentTransactionsOnlyHydrateChunks, documentUnderlineColor, documentUnderlineDomAttributes, documentUnderlineFormattingFromElement, documentUnderlineKeyboardShortcuts, documentUnderlineStyle, documentWordLineHeightFactor, docxBookmarkReferenceTarget, docxDocumentFieldKind, editorDocumentBookmarkReferenceTargets, editorDocumentCaptionTargets, fileNameWithoutExtension, forgetWorkSourceBlob as forgetSourceBlob, importWorkDocumentFile, importedDocumentCharacterFormatting, initializeWorkOfficeDocumentCollaboration as initializeOfficeDocumentCollaboration, invalidateDocumentLazyHtmlProjection, isContourImageLayout, isDocumentCharacterFormatMark, isDocumentOpenTypeFeaturePatch, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, moveWorkSourceBlob, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterScalePercent, normalizeDocumentCharacterSpacingTwips, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEmphasisMark, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentHiddenText, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageTransform, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentLegacyTextEffect, normalizeDocumentLegacyTextEffects, normalizeDocumentNotesHtml, normalizeDocumentOpenTypeFeatures, normalizeDocumentOpenTypeLigatures, normalizeDocumentOpenTypeNumberForm, normalizeDocumentOpenTypeNumberSpacing, normalizeDocumentOpenTypeStylisticSets, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphIndent, normalizeDocumentStrikeStyle, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, normalizeDocumentUnderlineColor, normalizeDocumentUnderlineStyle, normalizeTableColor, normalizedTabPosition, numberingTypeFromFormat, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentNumberingChange, parseDocumentOpenTypeFeatures, parseDocumentParagraphFormatting, patchDocumentLazyHtmlProjection, patchDocumentOpenTypeFeatures, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, readWorkSourceBlob as readSourceBlob, registerDocumentPageSurfaceGeometry, rememberWorkSourceBlob as registerSourceBlob, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveAllDocumentChanges, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, selectedDocumentIndexDraft, selectedDocumentIndexEntry, selectedDocumentIndexOptions, selectedDocumentTableOfContentsOptions, serializeDocumentCharacterFormatting, serializeDocumentNumberingChange, serializeDocumentOpenTypeFeatures, serializeDocumentParagraphFormatting, serializeDocumentTabStops, serializeWorkDocumentNode, setCustomDocumentColumns, supportedDocxBookmarkReferenceInstruction, syncDocumentContentFromHtml, transferChangedDocumentTextStatistics, uniqueDocumentImageIdentity, updateDocumentColumnWidth, updateDocumentCustomPageMillimeters, updateDocumentGutterPosition, updateDocumentMirrorMargins, updateDocumentPageChromeVariant, updateDocumentPageMarginMillimeters, updateDocumentPageMarginMode, updateDocumentPageOrientation, updateDocumentPaperSizePreset, validateDocumentBookmarkName, windowDocumentModel, workDocumentSchema, workOfficeDocumentCollaborationFragment as officeDocumentCollaborationFragment, work_document_model_codec_createWorkDocumentModelFromContent as createWorkDocumentModelFromContent, work_document_model_codec_materializeWorkDocumentContent as materializeWorkDocumentContent, work_document_model_createSchemaValidatedWorkDocumentModel as createSchemaValidatedWorkDocumentModel, work_document_page_margins_twipsToMillimeters, work_file_download_downloadBlob, work_file_download_safeFileName, wrapsBesideImage };
|
|
22511
|
+
export { DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, DOCUMENT_CHUNK_HYDRATION_META, DOCUMENT_CHUNK_PAGINATION_META, DOCUMENT_CHUNK_VISIBLE_IDS_META, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, DOCUMENT_OPEN_TYPE_ATTRIBUTE, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_PARAGRAPH_CHANGE_ATTRIBUTES, DOCUMENT_PARAGRAPH_FORMAT_ATTRIBUTES, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, DOCUMENT_TABLE_STYLE_OPTIONS, DOCUMENT_TEXT_BOX_DEFAULTS, DOCUMENT_TEXT_BOX_LIMITS, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, DocumentCharacterFormatting, DocumentEquation, DocumentFontFamily, DocumentHighlight, DocumentImage, DocumentParagraphFormatting, DocumentScriptFontFormatting, DocumentStrike, DocumentSubscript, DocumentSuperscript, DocumentTableRowIdentity, DocumentTextStyle, DocumentUnderline, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageTransformToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, applyDocumentTextCaseStyle, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createSchemaDerivedWorkDocumentModel, createWorkDocumentBlob, createWorkDocumentExtensions, createWorkDocumentModel, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, defaultDocumentImageTransform, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentCharacterPositionDomAttributes, documentCharacterPositionHalfPointsFromElement, documentCharacterPositionPoints, documentCharacterScaleDomAttributes, documentCharacterScalePercentFromElement, documentCharacterSpacingDomAttributes, documentCharacterSpacingPoints, documentCharacterSpacingTwipsFromElement, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEmphasisMarkDomAttributes, documentEmphasisMarkFromElement, documentEquationFromElement, documentEquationText, documentHasIndex, documentHasTableOfContents, documentHiddenTextDomAttributes, documentHiddenTextFromElement, documentHiddenTextKeyboardShortcut, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageTransformFromElement, documentImageWrapContourFromElement, documentInitialSectionLayout, documentKerningDomAttributes, documentKerningIsEffective, documentKerningThresholdHalfPointsFromElement, documentKerningThresholdPoints, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentLegacyTextEffectsConflict, documentLegacyTextEffectsCss, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsFromElement, documentLegacyTextEffectsFromTextStyleAttributes, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOpenTypeCssProperties, documentOpenTypeDomAttributes, documentOpenTypeFeaturesFromElement, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, documentParagraphDirection, documentParagraphIndent, documentParagraphPagination, documentParagraphSpacing, documentParagraphTabStops, documentSectionById, documentSectionDomAttributes, documentSections, documentStrikeDomAttributes, documentStrikeFormattingFromElement, documentStrikeStyle, documentTabLeaderLabel, documentTableBordersFromElement, documentTableCellFormat, documentTableCellMarginOverridesFromElement, documentTableColumnPercentagesFromElement, documentTableGeometryFromElement, documentTableHorizontalAlignment, documentTableRowIdentityFromElement, documentTableRowOptions, documentTableSizing, documentTextBoxProperties, documentTextBoxPropertiesFromElement, documentTextCaseFromWordFlags, documentTextCaseKeyboardShortcuts, documentTextLayoutBatches, documentTextStatistics, documentTransactionsOnlyHydrateChunks, documentUnderlineColor, documentUnderlineDomAttributes, documentUnderlineFormattingFromElement, documentUnderlineKeyboardShortcuts, documentUnderlineStyle, documentWordLineHeightFactor, docxBookmarkReferenceTarget, docxDocumentFieldKind, editorDocumentBookmarkReferenceTargets, editorDocumentCaptionTargets, fileNameWithoutExtension, forgetWorkSourceBlob as forgetSourceBlob, importWorkDocumentFile, importedDocumentCharacterFormatting, initializeWorkOfficeDocumentCollaboration as initializeOfficeDocumentCollaboration, invalidateDocumentLazyHtmlProjection, isContourImageLayout, isDocumentCharacterFormatMark, isDocumentOpenTypeFeaturePatch, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, moveWorkSourceBlob, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterScalePercent, normalizeDocumentCharacterSpacingTwips, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEmphasisMark, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentHiddenText, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageTransform, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentLegacyTextEffect, normalizeDocumentLegacyTextEffects, normalizeDocumentNotesHtml, normalizeDocumentOpenTypeFeatures, normalizeDocumentOpenTypeLigatures, normalizeDocumentOpenTypeNumberForm, normalizeDocumentOpenTypeNumberSpacing, normalizeDocumentOpenTypeStylisticSets, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphIndent, normalizeDocumentStrikeStyle, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeDocumentTextBoxProperties, normalizeDocumentTextCase, normalizeDocumentUnderlineColor, normalizeDocumentUnderlineStyle, normalizeTableColor, normalizedTabPosition, numberingTypeFromFormat, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentNumberingChange, parseDocumentOpenTypeFeatures, parseDocumentParagraphFormatting, patchDocumentLazyHtmlProjection, patchDocumentOpenTypeFeatures, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, readWorkSourceBlob as readSourceBlob, registerDocumentPageSurfaceGeometry, rememberWorkSourceBlob as registerSourceBlob, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveAllDocumentChanges, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, selectedDocumentIndexDraft, selectedDocumentIndexEntry, selectedDocumentIndexOptions, selectedDocumentTableOfContentsOptions, serializeDocumentCharacterFormatting, serializeDocumentNumberingChange, serializeDocumentOpenTypeFeatures, serializeDocumentParagraphFormatting, serializeDocumentTabStops, serializeWorkDocumentNode, setCustomDocumentColumns, supportedDocxBookmarkReferenceInstruction, syncDocumentContentFromHtml, textBoxCss, textBoxDomAttributes, transferChangedDocumentTextStatistics, uniqueDocumentImageIdentity, updateDocumentColumnWidth, updateDocumentCustomPageMillimeters, updateDocumentGutterPosition, updateDocumentMirrorMargins, updateDocumentPageChromeVariant, updateDocumentPageMarginMillimeters, updateDocumentPageMarginMode, updateDocumentPageOrientation, updateDocumentPaperSizePreset, validateDocumentBookmarkName, windowDocumentModel, workDocumentSchema, workOfficeDocumentCollaborationFragment as officeDocumentCollaborationFragment, work_document_model_codec_createWorkDocumentModelFromContent as createWorkDocumentModelFromContent, work_document_model_codec_materializeWorkDocumentContent as materializeWorkDocumentContent, work_document_model_createSchemaValidatedWorkDocumentModel as createSchemaValidatedWorkDocumentModel, work_document_page_margins_twipsToMillimeters, work_file_download_downloadBlob, work_file_download_safeFileName, wrapsBesideImage };
|
|
@@ -23,6 +23,11 @@ export declare const documentPictureRibbonTab: {
|
|
|
23
23
|
readonly label: "图片";
|
|
24
24
|
readonly contextual: true;
|
|
25
25
|
};
|
|
26
|
+
export declare const documentTextBoxRibbonTab: {
|
|
27
|
+
readonly id: "textBox";
|
|
28
|
+
readonly label: "文本框";
|
|
29
|
+
readonly contextual: true;
|
|
30
|
+
};
|
|
26
31
|
export declare const documentTableRibbonTabs: readonly [{
|
|
27
32
|
readonly id: "tableDesign";
|
|
28
33
|
readonly label: "表格设计";
|
|
@@ -41,7 +46,7 @@ export declare const documentPageChromeRibbonTab: {
|
|
|
41
46
|
readonly contextual: true;
|
|
42
47
|
};
|
|
43
48
|
export type DocumentStandardRibbonTabId = (typeof documentRibbonTabs)[number]['id'];
|
|
44
|
-
export type DocumentRibbonTabId = DocumentStandardRibbonTabId | typeof documentPictureRibbonTab.id | (typeof documentTableRibbonTabs)[number]['id'] | typeof documentPageChromeRibbonTab.id;
|
|
49
|
+
export type DocumentRibbonTabId = DocumentStandardRibbonTabId | typeof documentPictureRibbonTab.id | typeof documentTextBoxRibbonTab.id | (typeof documentTableRibbonTabs)[number]['id'] | typeof documentPageChromeRibbonTab.id;
|
|
45
50
|
export interface DocumentCommandShortcut {
|
|
46
51
|
label: string;
|
|
47
52
|
aria: string;
|
|
@@ -533,6 +538,15 @@ export declare const documentCommandCatalog: {
|
|
|
533
538
|
readonly editor: readonly ["Mod-Enter"];
|
|
534
539
|
};
|
|
535
540
|
};
|
|
541
|
+
readonly insertTextBox: {
|
|
542
|
+
readonly id: "insert.textBox";
|
|
543
|
+
readonly label: "插入文本框";
|
|
544
|
+
readonly location: {
|
|
545
|
+
readonly area: "ribbon";
|
|
546
|
+
readonly tab: "insert";
|
|
547
|
+
readonly group: "text";
|
|
548
|
+
};
|
|
549
|
+
};
|
|
536
550
|
readonly hyperlink: {
|
|
537
551
|
readonly id: "insert.hyperlink";
|
|
538
552
|
readonly label: "添加链接";
|
|
@@ -39,6 +39,7 @@ interface DocumentToolbarProps {
|
|
|
39
39
|
pageChromeEditingPart: DocumentPageChromeEditingPart | null;
|
|
40
40
|
pageChromeShowPageNumber: boolean;
|
|
41
41
|
onRequestImage: () => void;
|
|
42
|
+
onInsertTextBox?: () => void;
|
|
42
43
|
onPageChromeEditingPartChange: (part: DocumentPageChromeEditingPart) => void;
|
|
43
44
|
onClosePageChrome: () => void;
|
|
44
45
|
onTogglePageChromePageNumber: () => void;
|
|
@@ -86,5 +87,5 @@ interface DocumentToolbarProps {
|
|
|
86
87
|
onOpenWordCount: () => void;
|
|
87
88
|
onOpenFindReplace: (mode: DocumentFindReplaceMode) => void;
|
|
88
89
|
}
|
|
89
|
-
export declare function DocumentToolbar({ editor, defaultRibbonCollapsed, reviewOnly, suggestionOnly, history, layoutOpen, layout, layoutFonts, navigationOpen, pageColor, showPageNumbers, showHiddenText, showRulers, spellcheckEnabled, viewMode, zoom, pageChromeEditor, pageChromeEditingPart, pageChromeShowPageNumber, onRequestImage, onPageChromeEditingPartChange, onClosePageChrome, onTogglePageChromePageNumber, onToggleLayout, onLayoutChange, onOpenLayout, onToggleNavigation, onTogglePageNumbers, onToggleHiddenText, onToggleRulers, onPageColorChange, onToggleSpellcheck, onViewModeChange, onZoomChange, onZoomFit, onInsertSection, onInsertNote, onInsertCaption, onInsertCrossReference, onOpenTableOfContents, onOpenIndexEntry, onOpenIndex, citationsOpen, citationSourceCount, onToggleCitations, onInsertField, onRefreshFields, onRefreshIndex, onRefreshTableOfContents, canInsertComment, onInsertComment, commentsOpen, commentCount, onToggleComments, trackChanges, changesOpen, changeCount, findReplaceMode, fileActions, onRibbonTabChange, onToggleTrackChanges, onToggleChanges, onOpenComparison, onDecideChange, onOpenWordCount, onOpenFindReplace, }: DocumentToolbarProps): import("react").JSX.Element;
|
|
90
|
+
export declare function DocumentToolbar({ editor, defaultRibbonCollapsed, reviewOnly, suggestionOnly, history, layoutOpen, layout, layoutFonts, navigationOpen, pageColor, showPageNumbers, showHiddenText, showRulers, spellcheckEnabled, viewMode, zoom, pageChromeEditor, pageChromeEditingPart, pageChromeShowPageNumber, onRequestImage, onInsertTextBox, onPageChromeEditingPartChange, onClosePageChrome, onTogglePageChromePageNumber, onToggleLayout, onLayoutChange, onOpenLayout, onToggleNavigation, onTogglePageNumbers, onToggleHiddenText, onToggleRulers, onPageColorChange, onToggleSpellcheck, onViewModeChange, onZoomChange, onZoomFit, onInsertSection, onInsertNote, onInsertCaption, onInsertCrossReference, onOpenTableOfContents, onOpenIndexEntry, onOpenIndex, citationsOpen, citationSourceCount, onToggleCitations, onInsertField, onRefreshFields, onRefreshIndex, onRefreshTableOfContents, canInsertComment, onInsertComment, commentsOpen, commentCount, onToggleComments, trackChanges, changesOpen, changeCount, findReplaceMode, fileActions, onRibbonTabChange, onToggleTrackChanges, onToggleChanges, onOpenComparison, onDecideChange, onOpenWordCount, onOpenFindReplace, }: DocumentToolbarProps): import("react").JSX.Element;
|
|
90
91
|
export {};
|
|
@@ -11,6 +11,7 @@ export interface DocumentInsertCommands {
|
|
|
11
11
|
insertField: (kind: WorkDocumentFieldKind) => void;
|
|
12
12
|
insertImage: (file: File) => Promise<void>;
|
|
13
13
|
insertNote: (kind: WorkDocumentNoteKind) => boolean;
|
|
14
|
+
insertTextBox: () => boolean;
|
|
14
15
|
openIndexEntry: () => void;
|
|
15
16
|
openIndex: () => void;
|
|
16
17
|
openTableOfContents: () => void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type Editor, Node } from '@tiptap/core';
|
|
2
|
+
/** The intentionally small text-box surface supported by Writer. */
|
|
3
|
+
export type WorkDocumentTextBoxLayout = 'inline' | 'floating';
|
|
4
|
+
export type WorkDocumentTextBoxHorizontalReference = 'column' | 'margin' | 'page';
|
|
5
|
+
export type WorkDocumentTextBoxVerticalReference = 'paragraph' | 'margin' | 'page';
|
|
6
|
+
export type WorkDocumentTextBoxVerticalAlign = 'top' | 'center' | 'bottom';
|
|
7
|
+
export interface WorkDocumentTextBoxProperties {
|
|
8
|
+
id: string;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
layout: WorkDocumentTextBoxLayout;
|
|
12
|
+
horizontalOffset: number | null;
|
|
13
|
+
verticalOffset: number | null;
|
|
14
|
+
horizontalReference: WorkDocumentTextBoxHorizontalReference;
|
|
15
|
+
verticalReference: WorkDocumentTextBoxVerticalReference;
|
|
16
|
+
fill: string;
|
|
17
|
+
borderColor: string;
|
|
18
|
+
borderWidth: number;
|
|
19
|
+
padding: number;
|
|
20
|
+
verticalAlign: WorkDocumentTextBoxVerticalAlign;
|
|
21
|
+
docPropertiesId: number | null;
|
|
22
|
+
}
|
|
23
|
+
export interface DocumentTextBoxCommandOptions {
|
|
24
|
+
restoreFocus?: boolean;
|
|
25
|
+
}
|
|
26
|
+
declare module '@tiptap/core' {
|
|
27
|
+
interface Commands<ReturnType> {
|
|
28
|
+
documentTextBox: {
|
|
29
|
+
insertDocumentTextBox: (text?: string, options?: Partial<WorkDocumentTextBoxProperties>) => ReturnType;
|
|
30
|
+
setDocumentTextBoxProperties: (value: Partial<WorkDocumentTextBoxProperties>, options?: DocumentTextBoxCommandOptions) => ReturnType;
|
|
31
|
+
deleteDocumentTextBox: (options?: DocumentTextBoxCommandOptions) => ReturnType;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export declare const DOCUMENT_TEXT_BOX_DEFAULTS: WorkDocumentTextBoxProperties;
|
|
36
|
+
export declare const DOCUMENT_TEXT_BOX_LIMITS: {
|
|
37
|
+
readonly width: {
|
|
38
|
+
readonly min: 20;
|
|
39
|
+
readonly max: 558.7;
|
|
40
|
+
};
|
|
41
|
+
readonly height: {
|
|
42
|
+
readonly min: 10;
|
|
43
|
+
readonly max: 558.7;
|
|
44
|
+
};
|
|
45
|
+
readonly offset: {
|
|
46
|
+
readonly min: -558.7;
|
|
47
|
+
readonly max: 558.7;
|
|
48
|
+
};
|
|
49
|
+
readonly borderWidth: {
|
|
50
|
+
readonly min: 0;
|
|
51
|
+
readonly max: 10;
|
|
52
|
+
};
|
|
53
|
+
readonly padding: {
|
|
54
|
+
readonly min: 0;
|
|
55
|
+
readonly max: 25;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export declare const DocumentTextBox: Node<any, any>;
|
|
59
|
+
export declare function documentTextBoxProperties(editor: Editor): WorkDocumentTextBoxProperties;
|
|
60
|
+
export declare function setDocumentTextBoxProperties(editor: Editor, value: Partial<WorkDocumentTextBoxProperties>, options?: DocumentTextBoxCommandOptions): boolean;
|
|
61
|
+
export declare function normalizeDocumentTextBoxProperties(value: Partial<Record<keyof WorkDocumentTextBoxProperties, unknown>>): WorkDocumentTextBoxProperties;
|
|
62
|
+
export declare function textBoxCss(value: Partial<Record<keyof WorkDocumentTextBoxProperties, unknown>>): string;
|
|
63
|
+
export declare function textBoxDomAttributes(value: Partial<Record<keyof WorkDocumentTextBoxProperties, unknown>>): Record<string, string | undefined>;
|
|
64
|
+
export declare function documentTextBoxPropertiesFromElement(element: Element): WorkDocumentTextBoxProperties;
|
|
@@ -6,6 +6,7 @@ import { type ImportedDocxCommentMarkers } from './work-docx-comment-import';
|
|
|
6
6
|
import { type ImportedDocxEquationMarkers } from './work-docx-equation-import';
|
|
7
7
|
import { type ImportedDocxFieldMarkers } from './work-docx-field-import';
|
|
8
8
|
import { type ImportedDocxImageLayoutMarkers } from './work-docx-image-layout-import';
|
|
9
|
+
import { type ImportedDocxTextBoxMarkers } from './work-docx-text-box-import';
|
|
9
10
|
import { type ImportedDocxIndexMarkers } from './work-docx-index-import';
|
|
10
11
|
import { type ImportedDocxListMarkers } from './work-docx-list-import';
|
|
11
12
|
import { type ImportedDocxNumberingChangeMarkers } from './work-docx-numbering-change-import';
|
|
@@ -46,6 +47,7 @@ export interface PreparedDocxImport {
|
|
|
46
47
|
listMarkers: ImportedDocxListMarkers;
|
|
47
48
|
numberingChangeMarkers: ImportedDocxNumberingChangeMarkers;
|
|
48
49
|
imageLayoutMarkers: ImportedDocxImageLayoutMarkers;
|
|
50
|
+
textBoxMarkers: ImportedDocxTextBoxMarkers;
|
|
49
51
|
paragraphIdentityMarkers: ImportedDocxParagraphIdentityMarkers;
|
|
50
52
|
paragraphFormattingChangeMarkers: ImportedDocxParagraphFormattingChangeMarkers;
|
|
51
53
|
paragraphAlignmentMarkers: ImportedDocxParagraphAlignmentMarkers;
|
|
@@ -64,6 +66,6 @@ export interface PreparedDocxImport {
|
|
|
64
66
|
trackChanges: boolean;
|
|
65
67
|
}
|
|
66
68
|
export declare function prepareDocxImport(buffer: ArrayBuffer, sourcePackage?: OoxmlPackage): Promise<PreparedDocxImport>;
|
|
67
|
-
export declare function applyDocxSectionsToHtml(html: string, sections: PreparedDocxImport['sections'], captionMarkers?: ImportedDocxCaptionMarkers, bookmarkMarkers?: ImportedDocxBookmarkMarkers, changeMarkers?: ImportedDocxChangeMarkers, commentMarkers?: ImportedDocxCommentMarkers, fieldMarkers?: ImportedDocxFieldMarkers, tableOfContentsMarkers?: ImportedDocxTableOfContentsMarkers, indexMarkers?: ImportedDocxIndexMarkers, equationMarkers?: ImportedDocxEquationMarkers, citationMarkers?: ImportedDocxCitationMarkers, listMarkers?: ImportedDocxListMarkers, numberingChangeMarkers?: ImportedDocxNumberingChangeMarkers, imageLayoutMarkers?: ImportedDocxImageLayoutMarkers, paragraphIdentityMarkers?: ImportedDocxParagraphIdentityMarkers, paragraphFormattingChangeMarkers?: ImportedDocxParagraphFormattingChangeMarkers, paragraphAlignmentMarkers?: ImportedDocxParagraphAlignmentMarkers, runFormattingMarkers?: ImportedDocxRunFormattingMarkers, paragraphDirectionMarkers?: ImportedDocxParagraphDirectionMarkers, paragraphIndentMarkers?: ImportedDocxParagraphIndentMarkers, paragraphSpacingMarkers?: ImportedDocxParagraphSpacingMarkers, paragraphBorderMarkers?: ImportedDocxParagraphBorderMarkers, paragraphShadingMarkers?: ImportedDocxParagraphShadingMarkers, paragraphPaginationMarkers?: ImportedDocxParagraphPaginationMarkers, bibliography?: WorkDocumentContent['bibliography'], tabStopMarkers?: ImportedDocxParagraphTabStopMarkers, tableCellMarkers?: ImportedDocxTableCellMarkers, tableRowMarkers?: ImportedDocxTableRowMarkers, tableSizingMarkers?: ImportedDocxTableSizingMarkers): string;
|
|
69
|
+
export declare function applyDocxSectionsToHtml(html: string, sections: PreparedDocxImport['sections'], captionMarkers?: ImportedDocxCaptionMarkers, bookmarkMarkers?: ImportedDocxBookmarkMarkers, changeMarkers?: ImportedDocxChangeMarkers, commentMarkers?: ImportedDocxCommentMarkers, fieldMarkers?: ImportedDocxFieldMarkers, tableOfContentsMarkers?: ImportedDocxTableOfContentsMarkers, indexMarkers?: ImportedDocxIndexMarkers, equationMarkers?: ImportedDocxEquationMarkers, citationMarkers?: ImportedDocxCitationMarkers, listMarkers?: ImportedDocxListMarkers, numberingChangeMarkers?: ImportedDocxNumberingChangeMarkers, imageLayoutMarkers?: ImportedDocxImageLayoutMarkers, paragraphIdentityMarkers?: ImportedDocxParagraphIdentityMarkers, paragraphFormattingChangeMarkers?: ImportedDocxParagraphFormattingChangeMarkers, paragraphAlignmentMarkers?: ImportedDocxParagraphAlignmentMarkers, runFormattingMarkers?: ImportedDocxRunFormattingMarkers, paragraphDirectionMarkers?: ImportedDocxParagraphDirectionMarkers, paragraphIndentMarkers?: ImportedDocxParagraphIndentMarkers, paragraphSpacingMarkers?: ImportedDocxParagraphSpacingMarkers, paragraphBorderMarkers?: ImportedDocxParagraphBorderMarkers, paragraphShadingMarkers?: ImportedDocxParagraphShadingMarkers, paragraphPaginationMarkers?: ImportedDocxParagraphPaginationMarkers, bibliography?: WorkDocumentContent['bibliography'], tabStopMarkers?: ImportedDocxParagraphTabStopMarkers, tableCellMarkers?: ImportedDocxTableCellMarkers, tableRowMarkers?: ImportedDocxTableRowMarkers, tableSizingMarkers?: ImportedDocxTableSizingMarkers, textBoxMarkers?: ImportedDocxTextBoxMarkers): string;
|
|
68
70
|
export declare function readDocxLayout(buffer: ArrayBuffer): Promise<ImportedDocumentLayout>;
|
|
69
71
|
export {};
|