@univerjs/docs-ui 1.0.0-alpha.1 → 1.0.0-insiders.20260701-0ef51b0
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/lib/cjs/index.js +1876 -284
- package/lib/es/index.js +1864 -288
- package/lib/index.css +20 -0
- package/lib/index.js +1864 -288
- package/lib/types/EmbedDocsCustomBlockRenderer.d.ts +54 -0
- package/lib/types/EmbedFloatingMenu.d.ts +25 -0
- package/lib/types/controllers/render-controllers/doc-input.controller.d.ts +4 -1
- package/lib/types/controllers/render-controllers/doc-selection-render.controller.d.ts +5 -1
- package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +4 -1
- package/lib/types/controllers/render-controllers/embed-docs-custom-block-bleed.render-controller.d.ts +31 -0
- package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +3 -1
- package/lib/types/controllers/ui.controller.d.ts +4 -1
- package/lib/types/embed-block.d.ts +18 -0
- package/lib/types/embed-docs-custom-block-bleed.d.ts +30 -0
- package/lib/types/embed-docs-custom-block-refresh.d.ts +30 -0
- package/lib/types/embed-docs-custom-block-scroll.d.ts +19 -0
- package/lib/types/embed-host-adapter.d.ts +20 -0
- package/lib/types/embed-host-anchor.d.ts +89 -0
- package/lib/types/embed-passive-viewport.d.ts +18 -0
- package/lib/types/embed-product-menu.d.ts +17 -0
- package/lib/types/embed-register.d.ts +17 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/plugin.d.ts +1 -0
- package/lib/types/services/doc-popup-manager.service.d.ts +1 -0
- package/lib/types/services/float-menu.service.d.ts +1 -0
- package/lib/types/services/selection/convert-text-range.d.ts +3 -0
- package/lib/types/services/selection/doc-selection-render.service.d.ts +13 -1
- package/lib/umd/index.js +85 -10
- package/package.json +10 -9
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -4,6 +4,7 @@ let _univerjs_docs = require("@univerjs/docs");
|
|
|
4
4
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
5
5
|
let _univerjs_ui = require("@univerjs/ui");
|
|
6
6
|
let _univerjs_drawing = require("@univerjs/drawing");
|
|
7
|
+
let _univerjs_embed_ui = require("@univerjs/embed-ui");
|
|
7
8
|
let rxjs = require("rxjs");
|
|
8
9
|
let rxjs_operators = require("rxjs/operators");
|
|
9
10
|
let _univerjs_design = require("@univerjs/design");
|
|
@@ -5929,6 +5930,224 @@ const SubtitleHeadingCommand = {
|
|
|
5929
5930
|
}
|
|
5930
5931
|
};
|
|
5931
5932
|
|
|
5933
|
+
//#endregion
|
|
5934
|
+
//#region src/embed-host-anchor.ts
|
|
5935
|
+
const EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY = "UniverEmbedDocsCustomBlock";
|
|
5936
|
+
const DEFAULT_CUSTOM_BLOCK_SIZE = {
|
|
5937
|
+
width: 720,
|
|
5938
|
+
height: 360
|
|
5939
|
+
};
|
|
5940
|
+
const SHEET_LIKE_CUSTOM_BLOCK_SIZE = {
|
|
5941
|
+
width: 960,
|
|
5942
|
+
height: 480
|
|
5943
|
+
};
|
|
5944
|
+
const SLIDE_CUSTOM_BLOCK_SIZE = {
|
|
5945
|
+
width: 720,
|
|
5946
|
+
height: 405
|
|
5947
|
+
};
|
|
5948
|
+
const MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET = 10;
|
|
5949
|
+
function createDocsCustomBlockInsertMutation(params) {
|
|
5950
|
+
return createRichTextMutation(params.unitId, params.segmentId, createInsertCustomBlockActions(params));
|
|
5951
|
+
}
|
|
5952
|
+
function createDocsCustomBlockRemoveMutation(params) {
|
|
5953
|
+
return createRichTextMutation(params.unitId, params.segmentId, createRemoveCustomBlockActions(params));
|
|
5954
|
+
}
|
|
5955
|
+
function createInsertCustomBlockActions(params) {
|
|
5956
|
+
const textX = new _univerjs_core.TextX();
|
|
5957
|
+
if (params.startIndex > 0) textX.push({
|
|
5958
|
+
t: _univerjs_core.TextXActionType.RETAIN,
|
|
5959
|
+
len: params.startIndex
|
|
5960
|
+
});
|
|
5961
|
+
textX.push({
|
|
5962
|
+
t: _univerjs_core.TextXActionType.INSERT,
|
|
5963
|
+
body: {
|
|
5964
|
+
dataStream: "\b",
|
|
5965
|
+
customBlocks: [{
|
|
5966
|
+
startIndex: 0,
|
|
5967
|
+
blockId: params.blockId
|
|
5968
|
+
}]
|
|
5969
|
+
},
|
|
5970
|
+
len: 1
|
|
5971
|
+
});
|
|
5972
|
+
return composeActions([toBodyEditActions(textX, params.segmentId), createDrawingInsertActions(params)]);
|
|
5973
|
+
}
|
|
5974
|
+
function createRemoveCustomBlockActions(params) {
|
|
5975
|
+
const textX = new _univerjs_core.TextX();
|
|
5976
|
+
if (params.startIndex > 0) textX.push({
|
|
5977
|
+
t: _univerjs_core.TextXActionType.RETAIN,
|
|
5978
|
+
len: params.startIndex
|
|
5979
|
+
});
|
|
5980
|
+
textX.push({
|
|
5981
|
+
t: _univerjs_core.TextXActionType.DELETE,
|
|
5982
|
+
len: 1
|
|
5983
|
+
});
|
|
5984
|
+
return composeActions([toBodyEditActions(textX, params.segmentId), createDrawingRemoveActions(params)]);
|
|
5985
|
+
}
|
|
5986
|
+
function createDocsCustomBlockDrawing(params) {
|
|
5987
|
+
var _params$componentKey;
|
|
5988
|
+
const size = resolveDocsCustomBlockSize(params.childType);
|
|
5989
|
+
const isInline = params.interactionMode === "inline";
|
|
5990
|
+
return {
|
|
5991
|
+
unitId: params.unitId,
|
|
5992
|
+
subUnitId: params.unitId,
|
|
5993
|
+
drawingId: params.blockId,
|
|
5994
|
+
drawingType: _univerjs_core.DrawingTypeEnum.DRAWING_DOM,
|
|
5995
|
+
componentKey: (_params$componentKey = params.componentKey) !== null && _params$componentKey !== void 0 ? _params$componentKey : EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY,
|
|
5996
|
+
data: createEmbedDocsCustomBlockData(params),
|
|
5997
|
+
title: params.blockId,
|
|
5998
|
+
description: "Univer embedded unit custom block",
|
|
5999
|
+
layoutType: isInline ? _univerjs_core.PositionedObjectLayoutType.INLINE : _univerjs_core.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM,
|
|
6000
|
+
allowTransform: false,
|
|
6001
|
+
docTransform: {
|
|
6002
|
+
size: {
|
|
6003
|
+
width: size.width,
|
|
6004
|
+
height: size.height
|
|
6005
|
+
},
|
|
6006
|
+
positionH: {
|
|
6007
|
+
relativeFrom: isInline ? _univerjs_core.ObjectRelativeFromH.PAGE : _univerjs_core.ObjectRelativeFromH.COLUMN,
|
|
6008
|
+
...isInline ? { posOffset: 0 } : { align: _univerjs_core.AlignTypeH.LEFT }
|
|
6009
|
+
},
|
|
6010
|
+
positionV: {
|
|
6011
|
+
relativeFrom: isInline ? _univerjs_core.ObjectRelativeFromV.PAGE : _univerjs_core.ObjectRelativeFromV.PARAGRAPH,
|
|
6012
|
+
posOffset: 0
|
|
6013
|
+
},
|
|
6014
|
+
angle: 0
|
|
6015
|
+
},
|
|
6016
|
+
transform: {
|
|
6017
|
+
left: 0,
|
|
6018
|
+
top: 0,
|
|
6019
|
+
width: size.width,
|
|
6020
|
+
height: size.height
|
|
6021
|
+
}
|
|
6022
|
+
};
|
|
6023
|
+
}
|
|
6024
|
+
function resolveDocsCustomBlockSize(childType) {
|
|
6025
|
+
if (childType === _univerjs_core.UniverInstanceType.UNIVER_SHEET || childType === _univerjs_core.UniverInstanceType.UNIVER_BASE) return SHEET_LIKE_CUSTOM_BLOCK_SIZE;
|
|
6026
|
+
if (childType === _univerjs_core.UniverInstanceType.UNIVER_SLIDE) return SLIDE_CUSTOM_BLOCK_SIZE;
|
|
6027
|
+
return DEFAULT_CUSTOM_BLOCK_SIZE;
|
|
6028
|
+
}
|
|
6029
|
+
function isSheetLikeDocsCustomBlockChildType(childType) {
|
|
6030
|
+
return childType === _univerjs_core.UniverInstanceType.UNIVER_SHEET || childType === _univerjs_core.UniverInstanceType.UNIVER_BASE;
|
|
6031
|
+
}
|
|
6032
|
+
function resolveDocsCustomBlockRenderViewport(params) {
|
|
6033
|
+
var _params$fallbackWidth, _params$fallbackHeigh, _params$contentHeight, _params$visibleCanvas, _params$pageMarginLef, _params$pageMarginRig, _params$contentWidth, _params$docsLeft, _params$visibleCanvas2;
|
|
6034
|
+
const defaultSize = resolveDocsCustomBlockSize(params.childType);
|
|
6035
|
+
const fallbackWidth = (_params$fallbackWidth = params.fallbackWidth) !== null && _params$fallbackWidth !== void 0 ? _params$fallbackWidth : defaultSize.width;
|
|
6036
|
+
const fallbackHeight = (_params$fallbackHeigh = params.fallbackHeight) !== null && _params$fallbackHeigh !== void 0 ? _params$fallbackHeigh : defaultSize.height;
|
|
6037
|
+
const sheetLike = isSheetLikeDocsCustomBlockChildType(params.childType);
|
|
6038
|
+
const contentHeight = Number.isFinite(params.contentHeight) && ((_params$contentHeight = params.contentHeight) !== null && _params$contentHeight !== void 0 ? _params$contentHeight : 0) > 0 ? params.contentHeight : fallbackHeight;
|
|
6039
|
+
const visibleCanvasHeight = Number.isFinite(params.visibleCanvasHeight) && ((_params$visibleCanvas = params.visibleCanvasHeight) !== null && _params$visibleCanvas !== void 0 ? _params$visibleCanvas : 0) > 0 ? params.visibleCanvasHeight : void 0;
|
|
6040
|
+
const height = sheetLike ? contentHeight : fallbackHeight;
|
|
6041
|
+
const viewportHeight = sheetLike && visibleCanvasHeight != null ? Math.min(contentHeight, visibleCanvasHeight) : height;
|
|
6042
|
+
if (!sheetLike) return {
|
|
6043
|
+
height,
|
|
6044
|
+
width: fallbackWidth
|
|
6045
|
+
};
|
|
6046
|
+
const pageWidth = params.pageWidth;
|
|
6047
|
+
const pageMarginLeft = (_params$pageMarginLef = params.pageMarginLeft) !== null && _params$pageMarginLef !== void 0 ? _params$pageMarginLef : 0;
|
|
6048
|
+
const pageMarginRight = (_params$pageMarginRig = params.pageMarginRight) !== null && _params$pageMarginRig !== void 0 ? _params$pageMarginRig : 0;
|
|
6049
|
+
const pageContentWidth = Number.isFinite(pageWidth) ? Math.max(0, pageWidth - pageMarginLeft - pageMarginRight) : fallbackWidth;
|
|
6050
|
+
const contentWidth = Number.isFinite(params.contentWidth) && ((_params$contentWidth = params.contentWidth) !== null && _params$contentWidth !== void 0 ? _params$contentWidth : 0) > 0 ? params.contentWidth : fallbackWidth;
|
|
6051
|
+
if (params.documentFlavor !== _univerjs_core.DocumentFlavor.MODERN || !Number.isFinite(pageWidth)) {
|
|
6052
|
+
const layoutWidth = Math.min(contentWidth, pageContentWidth || contentWidth);
|
|
6053
|
+
return {
|
|
6054
|
+
contentHeight,
|
|
6055
|
+
contentWidth,
|
|
6056
|
+
height,
|
|
6057
|
+
layoutWidth,
|
|
6058
|
+
offsetLeft: 0,
|
|
6059
|
+
viewportHeight,
|
|
6060
|
+
width: layoutWidth
|
|
6061
|
+
};
|
|
6062
|
+
}
|
|
6063
|
+
const inset = MODERN_DOCS_CUSTOM_BLOCK_VIEWPORT_INSET / (params.scale && params.scale > 0 ? params.scale : 1);
|
|
6064
|
+
const docsLeft = (_params$docsLeft = params.docsLeft) !== null && _params$docsLeft !== void 0 ? _params$docsLeft : 0;
|
|
6065
|
+
const fallbackViewportLeft = docsLeft + inset;
|
|
6066
|
+
const fallbackViewportWidth = Math.max(0, pageWidth - inset * 2);
|
|
6067
|
+
const hasVisibleCanvas = Number.isFinite(params.visibleCanvasLeft) && Number.isFinite(params.visibleCanvasWidth) && ((_params$visibleCanvas2 = params.visibleCanvasWidth) !== null && _params$visibleCanvas2 !== void 0 ? _params$visibleCanvas2 : 0) > 0;
|
|
6068
|
+
const viewportLeft = hasVisibleCanvas ? params.visibleCanvasLeft + inset : fallbackViewportLeft;
|
|
6069
|
+
const viewportWidth = hasVisibleCanvas ? Math.max(0, params.visibleCanvasWidth - inset * 2) : fallbackViewportWidth;
|
|
6070
|
+
const paragraphTextStart = docsLeft + pageMarginLeft;
|
|
6071
|
+
const leadingInsetLeft = Math.max(0, paragraphTextStart - viewportLeft);
|
|
6072
|
+
const layoutWidth = Math.min(contentWidth, pageContentWidth || contentWidth);
|
|
6073
|
+
return {
|
|
6074
|
+
bleedLeft: leadingInsetLeft,
|
|
6075
|
+
bleedWidth: viewportWidth,
|
|
6076
|
+
contentHeight,
|
|
6077
|
+
contentWidth,
|
|
6078
|
+
height,
|
|
6079
|
+
layoutWidth,
|
|
6080
|
+
offsetLeft: 0,
|
|
6081
|
+
viewportHeight,
|
|
6082
|
+
width: layoutWidth
|
|
6083
|
+
};
|
|
6084
|
+
}
|
|
6085
|
+
function createEmbedDocsCustomBlockData(params) {
|
|
6086
|
+
var _params$embedId, _params$interactionMo;
|
|
6087
|
+
return {
|
|
6088
|
+
version: 1,
|
|
6089
|
+
embedId: (_params$embedId = params.embedId) !== null && _params$embedId !== void 0 ? _params$embedId : params.blockId,
|
|
6090
|
+
hostUnitId: params.unitId,
|
|
6091
|
+
hostAnchorId: params.blockId,
|
|
6092
|
+
childUnitId: params.childUnitId,
|
|
6093
|
+
childType: params.childType,
|
|
6094
|
+
interactionMode: (_params$interactionMo = params.interactionMode) !== null && _params$interactionMo !== void 0 ? _params$interactionMo : "block"
|
|
6095
|
+
};
|
|
6096
|
+
}
|
|
6097
|
+
function isEmbedDocsCustomBlockData(data) {
|
|
6098
|
+
if (!data || typeof data !== "object") return false;
|
|
6099
|
+
const candidate = data;
|
|
6100
|
+
return candidate.version === 1 && typeof candidate.embedId === "string" && typeof candidate.hostAnchorId === "string";
|
|
6101
|
+
}
|
|
6102
|
+
function shouldUseInlineTextSelectionForDocsCustomBlockDrawing(drawing) {
|
|
6103
|
+
const data = drawing && typeof drawing === "object" ? drawing.data : void 0;
|
|
6104
|
+
if (!isEmbedDocsCustomBlockData(data)) return true;
|
|
6105
|
+
return data.interactionMode === "inline";
|
|
6106
|
+
}
|
|
6107
|
+
function createRichTextMutation(unitId, segmentId, actions) {
|
|
6108
|
+
return {
|
|
6109
|
+
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
6110
|
+
params: {
|
|
6111
|
+
unitId,
|
|
6112
|
+
segmentId,
|
|
6113
|
+
actions,
|
|
6114
|
+
textRanges: [],
|
|
6115
|
+
isEditing: false,
|
|
6116
|
+
noNeedSetTextRange: true
|
|
6117
|
+
}
|
|
6118
|
+
};
|
|
6119
|
+
}
|
|
6120
|
+
function toBodyEditActions(textX, segmentId) {
|
|
6121
|
+
const action = _univerjs_core.JSONX.getInstance().editOp(textX.serialize(), segmentId ? [
|
|
6122
|
+
"headers",
|
|
6123
|
+
segmentId,
|
|
6124
|
+
"body"
|
|
6125
|
+
] : ["body"]);
|
|
6126
|
+
return action !== null && action !== void 0 ? action : [];
|
|
6127
|
+
}
|
|
6128
|
+
function createDrawingInsertActions(params) {
|
|
6129
|
+
var _jsonX$insertOp, _jsonX$insertOp2, _params$drawingOrderI;
|
|
6130
|
+
if (params.segmentId) return [];
|
|
6131
|
+
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
6132
|
+
const drawing = createDocsCustomBlockDrawing(params);
|
|
6133
|
+
return composeActions([(_jsonX$insertOp = jsonX.insertOp(["drawings", params.blockId], drawing)) !== null && _jsonX$insertOp !== void 0 ? _jsonX$insertOp : [], (_jsonX$insertOp2 = jsonX.insertOp(["drawingsOrder", (_params$drawingOrderI = params.drawingOrderIndex) !== null && _params$drawingOrderI !== void 0 ? _params$drawingOrderI : 0], params.blockId)) !== null && _jsonX$insertOp2 !== void 0 ? _jsonX$insertOp2 : []]);
|
|
6134
|
+
}
|
|
6135
|
+
function createDrawingRemoveActions(params) {
|
|
6136
|
+
var _jsonX$removeOp, _jsonX$removeOp2, _params$drawingOrderI2;
|
|
6137
|
+
if (params.segmentId) return [];
|
|
6138
|
+
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
6139
|
+
const drawing = createDocsCustomBlockDrawing(params);
|
|
6140
|
+
return composeActions([(_jsonX$removeOp = jsonX.removeOp(["drawings", params.blockId], drawing)) !== null && _jsonX$removeOp !== void 0 ? _jsonX$removeOp : [], (_jsonX$removeOp2 = jsonX.removeOp(["drawingsOrder", (_params$drawingOrderI2 = params.drawingOrderIndex) !== null && _params$drawingOrderI2 !== void 0 ? _params$drawingOrderI2 : 0], params.blockId)) !== null && _jsonX$removeOp2 !== void 0 ? _jsonX$removeOp2 : []]);
|
|
6141
|
+
}
|
|
6142
|
+
function composeActions(actions) {
|
|
6143
|
+
return actions.reduce((composed, action) => {
|
|
6144
|
+
var _JSONX$compose;
|
|
6145
|
+
if (!action || _univerjs_core.JSONX.isNoop(action) || action.length === 0) return composed;
|
|
6146
|
+
if (!composed || _univerjs_core.JSONX.isNoop(composed) || composed.length === 0) return action;
|
|
6147
|
+
return (_JSONX$compose = _univerjs_core.JSONX.compose(composed, action)) !== null && _JSONX$compose !== void 0 ? _JSONX$compose : [];
|
|
6148
|
+
}, []);
|
|
6149
|
+
}
|
|
6150
|
+
|
|
5932
6151
|
//#endregion
|
|
5933
6152
|
//#region src/services/selection/convert-text-range.ts
|
|
5934
6153
|
let NodePositionType = /* @__PURE__ */ function(NodePositionType) {
|
|
@@ -6080,7 +6299,10 @@ var NodePositionConvertToCursor = class {
|
|
|
6080
6299
|
const isStartBack = start.glyph === start_sp && isFirst ? start.isBack : true;
|
|
6081
6300
|
const isEndBack = end.glyph === end_sp && isLast ? end.isBack : false;
|
|
6082
6301
|
const collapsed = start === end;
|
|
6083
|
-
const
|
|
6302
|
+
const rawAnchorGlyph = isStartBack ? preGlyph !== null && preGlyph !== void 0 ? preGlyph : firstGlyph : firstGlyph;
|
|
6303
|
+
const anchorGlyph = this._getCaretGlyph(rawAnchorGlyph, glyphGroup, start_sp);
|
|
6304
|
+
const selectedGlyphs = glyphGroup.slice(start_sp, end_sp + 1);
|
|
6305
|
+
const isSelectionOnlyNonInlineEmbedBlock = !collapsed && selectedGlyphs.length > 0 && selectedGlyphs.every((glyph) => this._isNonInlineEmbedCustomBlockGlyph(glyph));
|
|
6084
6306
|
const borderBoxStartY = startY;
|
|
6085
6307
|
const borderBoxEndY = contentHeight == null ? startY + lineHeight - marginTop - marginBottom : startY + paddingTop + contentHeight + paddingBottom;
|
|
6086
6308
|
if (start_sp === 0 && end_sp === glyphGroup.length - 1) {
|
|
@@ -6113,8 +6335,8 @@ var NodePositionConvertToCursor = class {
|
|
|
6113
6335
|
}
|
|
6114
6336
|
const clippedBorderBoxPosition = clipPositionToHorizontalRange(borderBoxPosition, this._horizontalClip);
|
|
6115
6337
|
const clippedContentBoxPosition = clipPositionToHorizontalRange(contentBoxPosition, this._horizontalClip);
|
|
6116
|
-
if (clippedBorderBoxPosition) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
|
|
6117
|
-
if (clippedContentBoxPosition) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
|
|
6338
|
+
if (clippedBorderBoxPosition && !isSelectionOnlyNonInlineEmbedBlock) borderBoxPointGroup.push(pushToPoints(clippedBorderBoxPosition));
|
|
6339
|
+
if (clippedContentBoxPosition && !isSelectionOnlyNonInlineEmbedBlock) contentBoxPointGroup.push(pushToPoints(clippedContentBoxPosition));
|
|
6118
6340
|
cursorList.push({
|
|
6119
6341
|
startOffset: isStartBack ? startOffset : startOffset + firstGlyph.count,
|
|
6120
6342
|
endOffset: isEndBack ? endOffset : endOffset + lastGlyph.count,
|
|
@@ -6127,6 +6349,26 @@ var NodePositionConvertToCursor = class {
|
|
|
6127
6349
|
cursorList
|
|
6128
6350
|
};
|
|
6129
6351
|
}
|
|
6352
|
+
_getCaretGlyph(glyph, glyphGroup, glyphIndex) {
|
|
6353
|
+
var _this$_findTextLikeGl;
|
|
6354
|
+
if (!glyph || !this._isNonInlineEmbedCustomBlockGlyph(glyph)) return glyph;
|
|
6355
|
+
const neighbor = (_this$_findTextLikeGl = this._findTextLikeGlyph(glyphGroup, glyphIndex - 1, -1)) !== null && _this$_findTextLikeGl !== void 0 ? _this$_findTextLikeGl : this._findTextLikeGlyph(glyphGroup, glyphIndex + 1, 1);
|
|
6356
|
+
return neighbor !== null && neighbor !== void 0 ? neighbor : {
|
|
6357
|
+
...glyph,
|
|
6358
|
+
bBox: getDefaultCaretBoundingBox(glyph)
|
|
6359
|
+
};
|
|
6360
|
+
}
|
|
6361
|
+
_findTextLikeGlyph(glyphGroup, startIndex, step) {
|
|
6362
|
+
for (let index = startIndex; index >= 0 && index < glyphGroup.length; index += step) {
|
|
6363
|
+
const glyph = glyphGroup[index];
|
|
6364
|
+
if (!this._isNonInlineEmbedCustomBlockGlyph(glyph)) return glyph;
|
|
6365
|
+
}
|
|
6366
|
+
}
|
|
6367
|
+
_isNonInlineEmbedCustomBlockGlyph(glyph) {
|
|
6368
|
+
var _this$_docSkeleton$ge, _this$_docSkeleton, _this$_docSkeleton$ge2, _this$_docSkeleton$ge3, _this$_docSkeleton$ge4, _this$_docSkeleton$ge5;
|
|
6369
|
+
if (!(glyph === null || glyph === void 0 ? void 0 : glyph.drawingId) || glyph.streamType !== _univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK) return false;
|
|
6370
|
+
return !shouldUseInlineTextSelectionForDocsCustomBlockDrawing((_this$_docSkeleton$ge = (_this$_docSkeleton = this._docSkeleton).getViewModel) === null || _this$_docSkeleton$ge === void 0 || (_this$_docSkeleton$ge3 = (_this$_docSkeleton$ge2 = _this$_docSkeleton$ge.call(_this$_docSkeleton)).getDataModel) === null || _this$_docSkeleton$ge3 === void 0 || (_this$_docSkeleton$ge5 = (_this$_docSkeleton$ge4 = _this$_docSkeleton$ge3.call(_this$_docSkeleton$ge2)).getSnapshot) === null || _this$_docSkeleton$ge5 === void 0 || (_this$_docSkeleton$ge5 = _this$_docSkeleton$ge5.call(_this$_docSkeleton$ge4).drawings) === null || _this$_docSkeleton$ge5 === void 0 ? void 0 : _this$_docSkeleton$ge5[glyph.drawingId]);
|
|
6371
|
+
}
|
|
6130
6372
|
_isValidPosition(startOrigin, endOrigin) {
|
|
6131
6373
|
const { segmentPage: startPage, pageType: startPageType } = startOrigin;
|
|
6132
6374
|
const { segmentPage: endPage, pageType: endPageType } = endOrigin;
|
|
@@ -6340,6 +6582,19 @@ function clipPositionToHorizontalRange(position, clip) {
|
|
|
6340
6582
|
endX
|
|
6341
6583
|
};
|
|
6342
6584
|
}
|
|
6585
|
+
function getDefaultCaretBoundingBox(glyph) {
|
|
6586
|
+
const fontSize = getGlyphFontSize(glyph);
|
|
6587
|
+
return {
|
|
6588
|
+
...glyph.bBox,
|
|
6589
|
+
ba: fontSize,
|
|
6590
|
+
bd: Math.max(2, Math.ceil(fontSize * .25))
|
|
6591
|
+
};
|
|
6592
|
+
}
|
|
6593
|
+
function getGlyphFontSize(glyph) {
|
|
6594
|
+
var _ref, _glyph$fontStyle$orig, _glyph$fontStyle, _glyph$fontStyle2, _glyph$ts;
|
|
6595
|
+
const fontSize = (_ref = (_glyph$fontStyle$orig = (_glyph$fontStyle = glyph.fontStyle) === null || _glyph$fontStyle === void 0 ? void 0 : _glyph$fontStyle.originFontSize) !== null && _glyph$fontStyle$orig !== void 0 ? _glyph$fontStyle$orig : (_glyph$fontStyle2 = glyph.fontStyle) === null || _glyph$fontStyle2 === void 0 ? void 0 : _glyph$fontStyle2.fontSize) !== null && _ref !== void 0 ? _ref : (_glyph$ts = glyph.ts) === null || _glyph$ts === void 0 ? void 0 : _glyph$ts.fs;
|
|
6596
|
+
return typeof fontSize === "number" && Number.isFinite(fontSize) && fontSize > 0 ? fontSize : 14;
|
|
6597
|
+
}
|
|
6343
6598
|
function getDocumentUnitId$1(docSkeleton) {
|
|
6344
6599
|
var _viewModel$getDataMod, _viewModel$getDataMod2, _viewModel$getDataMod3, _viewModel$getDataMod4;
|
|
6345
6600
|
const viewModel = docSkeleton.getViewModel();
|
|
@@ -7464,18 +7719,22 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7464
7719
|
return this._onPointerEvent;
|
|
7465
7720
|
}
|
|
7466
7721
|
get isFocusing() {
|
|
7467
|
-
return this._input ===
|
|
7722
|
+
return this._input === this._getOwnerDocument().activeElement;
|
|
7468
7723
|
}
|
|
7469
7724
|
get canFocusing() {
|
|
7470
|
-
|
|
7725
|
+
const ownerDocument = this._getOwnerDocument();
|
|
7726
|
+
const activeElement = ownerDocument.activeElement;
|
|
7727
|
+
return !this._shouldPreserveExternalFocus() && (this.isFocusing || activeElement === ownerDocument.body || activeElement === null || activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement));
|
|
7471
7728
|
}
|
|
7472
|
-
constructor(_context, _layoutService, _logService, _univerInstanceService, _docSkeletonManagerService) {
|
|
7729
|
+
constructor(_context, _layoutService, _logService, _univerInstanceService, _docSkeletonManagerService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
7473
7730
|
super();
|
|
7474
7731
|
this._context = _context;
|
|
7475
7732
|
this._layoutService = _layoutService;
|
|
7476
7733
|
this._logService = _logService;
|
|
7477
7734
|
this._univerInstanceService = _univerInstanceService;
|
|
7478
7735
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
7736
|
+
this._embedInteractionBoundaryService = _embedInteractionBoundaryService;
|
|
7737
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
7479
7738
|
_defineProperty(this, "_onInputBefore$", new rxjs.Subject());
|
|
7480
7739
|
_defineProperty(this, "onInputBefore$", this._onInputBefore$.asObservable());
|
|
7481
7740
|
_defineProperty(this, "_onKeydown$", new rxjs.Subject());
|
|
@@ -7632,12 +7891,13 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7632
7891
|
this._container.style.left = `${left}px`;
|
|
7633
7892
|
this._container.style.top = `${top}px`;
|
|
7634
7893
|
this._container.style.zIndex = "1000";
|
|
7635
|
-
if (this.
|
|
7894
|
+
if (force && !this._shouldPreserveExternalFocus() || !force && this.canFocusing) this.focus();
|
|
7636
7895
|
}
|
|
7637
7896
|
hasFocus() {
|
|
7638
|
-
return
|
|
7897
|
+
return this._getOwnerDocument().activeElement === this._input;
|
|
7639
7898
|
}
|
|
7640
7899
|
focus() {
|
|
7900
|
+
if (!this._input.hasAttribute("tabindex")) this._input.tabIndex = -1;
|
|
7641
7901
|
this._input.focus();
|
|
7642
7902
|
}
|
|
7643
7903
|
blur() {
|
|
@@ -7879,6 +8139,10 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
7879
8139
|
}
|
|
7880
8140
|
if (this._container.parentElement !== document.body) document.body.appendChild(this._container);
|
|
7881
8141
|
}
|
|
8142
|
+
_getOwnerDocument() {
|
|
8143
|
+
var _this$_container$owne, _this$_container;
|
|
8144
|
+
return (_this$_container$owne = (_this$_container = this._container) === null || _this$_container === void 0 ? void 0 : _this$_container.ownerDocument) !== null && _this$_container$owne !== void 0 ? _this$_container$owne : document;
|
|
8145
|
+
}
|
|
7882
8146
|
_getNodePosition(node) {
|
|
7883
8147
|
if (node == null) return;
|
|
7884
8148
|
const { node: glyph, ratioX, segmentPage } = node;
|
|
@@ -8014,6 +8278,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8014
8278
|
const activeRangeInstance = this._getActiveRangeInstance();
|
|
8015
8279
|
const anchor = activeRangeInstance === null || activeRangeInstance === void 0 ? void 0 : activeRangeInstance.getAnchor();
|
|
8016
8280
|
if (!anchor || anchor && !anchor.visible || this.activeViewPort == null) {
|
|
8281
|
+
if (this._shouldPreserveExternalFocus()) return;
|
|
8017
8282
|
this.focus();
|
|
8018
8283
|
return;
|
|
8019
8284
|
}
|
|
@@ -8110,12 +8375,15 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8110
8375
|
}
|
|
8111
8376
|
_initInputEvents() {
|
|
8112
8377
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "keydown").subscribe((e) => {
|
|
8378
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8113
8379
|
if (this._isIMEInputApply) return;
|
|
8380
|
+
this._stopEmbedOwnedEditorShortcutPropagation(e);
|
|
8114
8381
|
this._eventHandle(e, (config) => {
|
|
8115
8382
|
this._onKeydown$.next(config);
|
|
8116
8383
|
});
|
|
8117
8384
|
}));
|
|
8118
8385
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "input").subscribe((e) => {
|
|
8386
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8119
8387
|
if (e.inputType === "historyUndo" || e.inputType === "historyRedo") return;
|
|
8120
8388
|
if (this._rectRangeList.length > 0) {
|
|
8121
8389
|
e.stopPropagation();
|
|
@@ -8128,6 +8396,7 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8128
8396
|
});
|
|
8129
8397
|
}));
|
|
8130
8398
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "compositionstart").subscribe((e) => {
|
|
8399
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8131
8400
|
if (this._rectRangeList.length > 0) {
|
|
8132
8401
|
e.stopPropagation();
|
|
8133
8402
|
return e.preventDefault();
|
|
@@ -8138,28 +8407,33 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8138
8407
|
});
|
|
8139
8408
|
}));
|
|
8140
8409
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "compositionend").subscribe((e) => {
|
|
8410
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8141
8411
|
this._isIMEInputApply = false;
|
|
8142
8412
|
this._eventHandle(e, (config) => {
|
|
8143
8413
|
this._onCompositionend$.next(config);
|
|
8144
8414
|
});
|
|
8145
8415
|
}));
|
|
8146
8416
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "compositionupdate").subscribe((e) => {
|
|
8417
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8147
8418
|
this._eventHandle(e, (config) => {
|
|
8148
8419
|
this._onInputBefore$.next(config);
|
|
8149
8420
|
this._onCompositionupdate$.next(config);
|
|
8150
8421
|
});
|
|
8151
8422
|
}));
|
|
8152
8423
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "paste").subscribe((e) => {
|
|
8424
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8153
8425
|
this._eventHandle(e, (config) => {
|
|
8154
8426
|
this._onPaste$.next(config);
|
|
8155
8427
|
});
|
|
8156
8428
|
}));
|
|
8157
8429
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "focus").subscribe((e) => {
|
|
8430
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8158
8431
|
this._eventHandle(e, (config) => {
|
|
8159
8432
|
this._onFocus$.next(config);
|
|
8160
8433
|
});
|
|
8161
8434
|
}));
|
|
8162
8435
|
this.disposeWithMe((0, rxjs.fromEvent)(this._input, "blur").subscribe((e) => {
|
|
8436
|
+
if (this._shouldSuppressHostHiddenEditorEvent(e)) return;
|
|
8163
8437
|
this._eventHandle(e, (config) => {
|
|
8164
8438
|
this._onBlur$.next(config);
|
|
8165
8439
|
});
|
|
@@ -8175,6 +8449,26 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8175
8449
|
rangeList: this._getAllTextRanges()
|
|
8176
8450
|
});
|
|
8177
8451
|
}
|
|
8452
|
+
_shouldSuppressHostHiddenEditorEvent(event) {
|
|
8453
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
8454
|
+
const unitId = this._context.unitId;
|
|
8455
|
+
if ((0, _univerjs_core.isInternalEditorID)(unitId)) return false;
|
|
8456
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, event.target, event)) return false;
|
|
8457
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
8458
|
+
if (event.target instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(event.target)) return false;
|
|
8459
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, event.target, event)) {
|
|
8460
|
+
event.stopPropagation();
|
|
8461
|
+
if (event.cancelable) event.preventDefault();
|
|
8462
|
+
if (event.type === "focus" && event.target instanceof HTMLElement) event.target.blur();
|
|
8463
|
+
return true;
|
|
8464
|
+
}
|
|
8465
|
+
return false;
|
|
8466
|
+
}
|
|
8467
|
+
_stopEmbedOwnedEditorShortcutPropagation(event) {
|
|
8468
|
+
if (!(event instanceof KeyboardEvent) || !this._getCurrentEmbedOwner()) return;
|
|
8469
|
+
if (!(event.key.toLowerCase() === "a" && (event.metaKey || event.ctrlKey))) return;
|
|
8470
|
+
event.stopPropagation();
|
|
8471
|
+
}
|
|
8178
8472
|
_getTransformCoordForDocumentOffset(evtOffsetX, evtOffsetY) {
|
|
8179
8473
|
const { documentTransform } = this._context.mainComponent.getOffsetConfig();
|
|
8180
8474
|
if (this.activeViewPort == null || documentTransform == null) return;
|
|
@@ -8190,6 +8484,50 @@ let DocSelectionRenderService = class DocSelectionRenderService extends _univerj
|
|
|
8190
8484
|
const { pageLayoutType = _univerjs_engine_render.PageLayoutType.VERTICAL, pageMarginLeft, pageMarginTop } = document.getOffsetConfig();
|
|
8191
8485
|
return skeleton.findNodeByCoord(coord, pageLayoutType, pageMarginLeft, pageMarginTop, restrictions);
|
|
8192
8486
|
}
|
|
8487
|
+
_shouldPreserveExternalFocus() {
|
|
8488
|
+
var _this$_embedRuntimeFo4, _this$_embedRuntimeFo5, _this$_embedRuntimeFo6, _this$_embedInteracti, _this$_embedInteracti2, _this$_embedInteracti3;
|
|
8489
|
+
const ownerDocument = this._getOwnerDocument();
|
|
8490
|
+
const activeElement = ownerDocument.activeElement;
|
|
8491
|
+
const currentEmbedOwner = this._getCurrentEmbedOwner();
|
|
8492
|
+
if ((_this$_embedRuntimeFo4 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo4 === void 0 ? void 0 : _this$_embedRuntimeFo4.isChildUnitInActiveSession(this._context.unitId)) return false;
|
|
8493
|
+
if ((_this$_embedRuntimeFo5 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo5 === void 0 ? void 0 : _this$_embedRuntimeFo5.isChildUnitRuntimeEvent(this._context.unitId, activeElement)) return false;
|
|
8494
|
+
if (activeElement instanceof HTMLElement && this._containsOwnEditorElement(activeElement)) return false;
|
|
8495
|
+
if (activeElement instanceof HTMLElement && this._containsCurrentEmbedRuntimeElement(activeElement)) return false;
|
|
8496
|
+
if ((_this$_embedRuntimeFo6 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo6 === void 0 ? void 0 : _this$_embedRuntimeFo6.shouldSuppressHostInteraction(this._context.unitId, activeElement)) return true;
|
|
8497
|
+
if (currentEmbedOwner && ((_this$_embedInteracti = this._embedInteractionBoundaryService) === null || _this$_embedInteracti === void 0 ? void 0 : _this$_embedInteracti.contains(currentEmbedOwner, activeElement))) return true;
|
|
8498
|
+
if (activeElement instanceof HTMLElement && this._containsCurrentLayoutElement(activeElement)) return false;
|
|
8499
|
+
return ((_this$_embedInteracti2 = this._embedInteractionBoundaryService) === null || _this$_embedInteracti2 === void 0 || (_this$_embedInteracti3 = _this$_embedInteracti2.hasRecentInteractionFor) === null || _this$_embedInteracti3 === void 0 ? void 0 : _this$_embedInteracti3.call(_this$_embedInteracti2, currentEmbedOwner, ownerDocument)) === true;
|
|
8500
|
+
}
|
|
8501
|
+
_containsCurrentEmbedRuntimeElement(element) {
|
|
8502
|
+
const currentEmbedOwner = this._getCurrentEmbedOwner();
|
|
8503
|
+
if (!currentEmbedOwner) return false;
|
|
8504
|
+
return this._getElementEmbedOwner(element) === currentEmbedOwner && this._containsCurrentLayoutElement(element);
|
|
8505
|
+
}
|
|
8506
|
+
_getCurrentEmbedOwner() {
|
|
8507
|
+
var _this$_layoutService, _ref, _this$_getElementEmbe;
|
|
8508
|
+
const rootContainerElement = (_this$_layoutService = this._layoutService) === null || _this$_layoutService === void 0 ? void 0 : _this$_layoutService.rootContainerElement;
|
|
8509
|
+
return (_ref = (_this$_getElementEmbe = this._getElementEmbedOwner(this._input)) !== null && _this$_getElementEmbe !== void 0 ? _this$_getElementEmbe : this._getElementEmbedOwner(this._container)) !== null && _ref !== void 0 ? _ref : this._getElementEmbedOwner(rootContainerElement instanceof HTMLElement ? rootContainerElement : void 0);
|
|
8510
|
+
}
|
|
8511
|
+
_getElementEmbedOwner(element) {
|
|
8512
|
+
var _element$closest$getA, _element$closest;
|
|
8513
|
+
if (!element || typeof element.closest !== "function") return;
|
|
8514
|
+
return (_element$closest$getA = (_element$closest = element.closest(`[${_univerjs_embed_ui.EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`)) === null || _element$closest === void 0 ? void 0 : _element$closest.getAttribute(_univerjs_embed_ui.EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE)) !== null && _element$closest$getA !== void 0 ? _element$closest$getA : void 0;
|
|
8515
|
+
}
|
|
8516
|
+
_containsOwnEditorElement(element) {
|
|
8517
|
+
var _this$_container2, _this$_inputParent;
|
|
8518
|
+
return this._container === element || this._input === element || typeof ((_this$_container2 = this._container) === null || _this$_container2 === void 0 ? void 0 : _this$_container2.contains) === "function" && this._container.contains(element) || typeof ((_this$_inputParent = this._inputParent) === null || _this$_inputParent === void 0 ? void 0 : _this$_inputParent.contains) === "function" && this._inputParent.contains(element);
|
|
8519
|
+
}
|
|
8520
|
+
_containsCurrentLayoutElement(element) {
|
|
8521
|
+
var _layoutService$checkE, _this$_container4;
|
|
8522
|
+
const layoutService = this._layoutService;
|
|
8523
|
+
if (!layoutService) {
|
|
8524
|
+
var _this$_container3;
|
|
8525
|
+
return this._container === element || typeof ((_this$_container3 = this._container) === null || _this$_container3 === void 0 ? void 0 : _this$_container3.contains) === "function" && this._container.contains(element);
|
|
8526
|
+
}
|
|
8527
|
+
if ((_layoutService$checkE = layoutService.checkElementInCurrentContainers) === null || _layoutService$checkE === void 0 ? void 0 : _layoutService$checkE.call(layoutService, element)) return true;
|
|
8528
|
+
const root = layoutService.rootContainerElement;
|
|
8529
|
+
return root === element || (root === null || root === void 0 ? void 0 : root.contains(element)) === true || this._container === element || typeof ((_this$_container4 = this._container) === null || _this$_container4 === void 0 ? void 0 : _this$_container4.contains) === "function" && this._container.contains(element);
|
|
8530
|
+
}
|
|
8193
8531
|
_detachEvent() {
|
|
8194
8532
|
this._onInputBefore$.complete();
|
|
8195
8533
|
this._onKeydown$.complete();
|
|
@@ -8209,7 +8547,9 @@ DocSelectionRenderService = __decorate([
|
|
|
8209
8547
|
__decorateParam(1, _univerjs_ui.ILayoutService),
|
|
8210
8548
|
__decorateParam(2, _univerjs_core.ILogService),
|
|
8211
8549
|
__decorateParam(3, _univerjs_core.IUniverInstanceService),
|
|
8212
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService))
|
|
8550
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
8551
|
+
__decorateParam(5, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedInteractionBoundaryService)),
|
|
8552
|
+
__decorateParam(6, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedRuntimeFocusCoordinator))
|
|
8213
8553
|
], DocSelectionRenderService);
|
|
8214
8554
|
|
|
8215
8555
|
//#endregion
|
|
@@ -9716,11 +10056,11 @@ let DocViewScaleService = class DocViewScaleService extends _univerjs_core.Dispo
|
|
|
9716
10056
|
return (_this$getPluginConfig = this.getPluginConfig().fitToWidth) !== null && _this$getPluginConfig !== void 0 ? _this$getPluginConfig : DEFAULT_DOC_FIT_TO_WIDTH_OPTIONS;
|
|
9717
10057
|
}
|
|
9718
10058
|
getBaseWidth() {
|
|
9719
|
-
var _documentStyle$pageSi;
|
|
9720
|
-
const documentStyle = this._context.unit.getSnapshot().documentStyle;
|
|
10059
|
+
var _this$_context$unit, _this$_context$unit$g, _documentStyle$pageSi;
|
|
10060
|
+
const documentStyle = (_this$_context$unit = this._context.unit) === null || _this$_context$unit === void 0 || (_this$_context$unit$g = _this$_context$unit.getSnapshot) === null || _this$_context$unit$g === void 0 || (_this$_context$unit$g = _this$_context$unit$g.call(_this$_context$unit)) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.documentStyle;
|
|
9721
10061
|
return resolveDocFitBaseWidth({
|
|
9722
|
-
documentFlavor: documentStyle.documentFlavor,
|
|
9723
|
-
documentStylePageWidth: (_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width
|
|
10062
|
+
documentFlavor: documentStyle === null || documentStyle === void 0 ? void 0 : documentStyle.documentFlavor,
|
|
10063
|
+
documentStylePageWidth: documentStyle === null || documentStyle === void 0 || (_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width
|
|
9724
10064
|
});
|
|
9725
10065
|
}
|
|
9726
10066
|
getAvailableWidth() {
|
|
@@ -9733,6 +10073,7 @@ let DocViewScaleService = class DocViewScaleService extends _univerjs_core.Dispo
|
|
|
9733
10073
|
return this._context.engine.width;
|
|
9734
10074
|
}
|
|
9735
10075
|
getUserZoomRatio() {
|
|
10076
|
+
if (this._context.unit == null) return 1;
|
|
9736
10077
|
return getDocEffectiveZoomRatio(this._context.unit);
|
|
9737
10078
|
}
|
|
9738
10079
|
getFitToWidthScale() {
|
|
@@ -9810,7 +10151,7 @@ DocPageLayoutService = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)
|
|
|
9810
10151
|
//#endregion
|
|
9811
10152
|
//#region src/controllers/render-controllers/doc.render-controller.ts
|
|
9812
10153
|
let DocRenderController = class DocRenderController extends _univerjs_core.RxDisposable {
|
|
9813
|
-
constructor(_context, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _editorService, _renderManagerService, _univerInstanceService, _docPageLayoutService, _textSelectionManagerService, _themeService) {
|
|
10154
|
+
constructor(_context, _commandService, _docSelectionRenderService, _docSkeletonManagerService, _editorService, _renderManagerService, _univerInstanceService, _docPageLayoutService, _textSelectionManagerService, _docViewScaleService, _themeService) {
|
|
9814
10155
|
super();
|
|
9815
10156
|
this._context = _context;
|
|
9816
10157
|
this._commandService = _commandService;
|
|
@@ -9821,6 +10162,7 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
9821
10162
|
this._univerInstanceService = _univerInstanceService;
|
|
9822
10163
|
this._docPageLayoutService = _docPageLayoutService;
|
|
9823
10164
|
this._textSelectionManagerService = _textSelectionManagerService;
|
|
10165
|
+
this._docViewScaleService = _docViewScaleService;
|
|
9824
10166
|
this._themeService = _themeService;
|
|
9825
10167
|
this._addNewRender();
|
|
9826
10168
|
this._initRenderRefresh();
|
|
@@ -9867,7 +10209,7 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
9867
10209
|
else e.preventDefault();
|
|
9868
10210
|
} else viewMain.onMouseWheel(e, state);
|
|
9869
10211
|
});
|
|
9870
|
-
new _univerjs_engine_render.ScrollBar(viewMain);
|
|
10212
|
+
new _univerjs_engine_render.ScrollBar(viewMain, { enableHorizontal: this._shouldEnableHorizontalScrollBar() });
|
|
9871
10213
|
scene.addLayer(new _univerjs_engine_render.Layer(scene, [], 2), new _univerjs_engine_render.Layer(scene, [], 4));
|
|
9872
10214
|
this._addComponent();
|
|
9873
10215
|
const frameFn = () => scene.render();
|
|
@@ -9877,6 +10219,10 @@ let DocRenderController = class DocRenderController extends _univerjs_core.RxDis
|
|
|
9877
10219
|
}));
|
|
9878
10220
|
this._docSelectionRenderService.__attachScrollEvent();
|
|
9879
10221
|
}
|
|
10222
|
+
_shouldEnableHorizontalScrollBar() {
|
|
10223
|
+
const options = this._docViewScaleService.getOptions();
|
|
10224
|
+
return !(options.mode === "fit-width" && options.target === "container" && options.align === "start");
|
|
10225
|
+
}
|
|
9880
10226
|
_addComponent() {
|
|
9881
10227
|
const { scene, unit: documentModel, components } = this._context;
|
|
9882
10228
|
const config = {
|
|
@@ -10012,7 +10358,8 @@ DocRenderController = __decorate([
|
|
|
10012
10358
|
__decorateParam(6, _univerjs_core.IUniverInstanceService),
|
|
10013
10359
|
__decorateParam(7, (0, _univerjs_core.Inject)(DocPageLayoutService)),
|
|
10014
10360
|
__decorateParam(8, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
10015
|
-
__decorateParam(9, (0, _univerjs_core.Inject)(
|
|
10361
|
+
__decorateParam(9, (0, _univerjs_core.Inject)(DocViewScaleService)),
|
|
10362
|
+
__decorateParam(10, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
|
|
10016
10363
|
], DocRenderController);
|
|
10017
10364
|
function getPageSizeInModernMode(page) {
|
|
10018
10365
|
let { pageWidth, pageHeight } = page;
|
|
@@ -12319,9 +12666,17 @@ function BackgroundColorSelectorMenuItemFactory(accessor) {
|
|
|
12319
12666
|
}
|
|
12320
12667
|
function getFontStyleAtCursor(accessor) {
|
|
12321
12668
|
var _docRanges$find2, _docMenuStyleService$, _paragraph$paragraphS11, _paragraph$paragraphS12;
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12669
|
+
let univerInstanceService;
|
|
12670
|
+
let textSelectionService;
|
|
12671
|
+
let docMenuStyleService;
|
|
12672
|
+
try {
|
|
12673
|
+
univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
12674
|
+
textSelectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
12675
|
+
docMenuStyleService = accessor.get(DocMenuStyleService);
|
|
12676
|
+
} catch (error) {
|
|
12677
|
+
if (isInjectorDisposedError(error)) return;
|
|
12678
|
+
throw error;
|
|
12679
|
+
}
|
|
12325
12680
|
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
12326
12681
|
const docRanges = textSelectionService.getDocRanges();
|
|
12327
12682
|
const activeRange = (_docRanges$find2 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find2 !== void 0 ? _docRanges$find2 : docRanges[0];
|
|
@@ -12352,8 +12707,15 @@ function getFontStyleAtCursor(accessor) {
|
|
|
12352
12707
|
}
|
|
12353
12708
|
function getParagraphStyleAtCursor(accessor) {
|
|
12354
12709
|
var _docRanges$find3, _docDataModel$getSelf;
|
|
12355
|
-
|
|
12356
|
-
|
|
12710
|
+
let univerInstanceService;
|
|
12711
|
+
let textSelectionService;
|
|
12712
|
+
try {
|
|
12713
|
+
univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
12714
|
+
textSelectionService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
12715
|
+
} catch (error) {
|
|
12716
|
+
if (isInjectorDisposedError(error)) return;
|
|
12717
|
+
throw error;
|
|
12718
|
+
}
|
|
12357
12719
|
const docDataModel = univerInstanceService.getCurrentUniverDocInstance();
|
|
12358
12720
|
const docRanges = textSelectionService.getDocRanges();
|
|
12359
12721
|
const activeRange = (_docRanges$find3 = docRanges.find((r) => r.isActive)) !== null && _docRanges$find3 !== void 0 ? _docRanges$find3 : docRanges[0];
|
|
@@ -12369,6 +12731,10 @@ function getParagraphStyleAtCursor(accessor) {
|
|
|
12369
12731
|
}
|
|
12370
12732
|
return null;
|
|
12371
12733
|
}
|
|
12734
|
+
function isInjectorDisposedError(error) {
|
|
12735
|
+
if (!(error instanceof Error)) return false;
|
|
12736
|
+
return error.name === "InjectorAlreadyDisposedError" || error.message.includes("Injector cannot be accessed after it was disposed");
|
|
12737
|
+
}
|
|
12372
12738
|
function PageSettingMenuItemFactory(accessor) {
|
|
12373
12739
|
return {
|
|
12374
12740
|
id: DocOpenPageSettingCommand.id,
|
|
@@ -14007,11 +14373,13 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
14007
14373
|
attachPopupToRect(rect, popup, unitId) {
|
|
14008
14374
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
14009
14375
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14376
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
14010
14377
|
const { position, position$, disposable } = this._createRectPositionObserver(rect, currentRender);
|
|
14011
14378
|
const id = this._globalPopupManagerService.addPopup({
|
|
14012
14379
|
...popup,
|
|
14013
14380
|
unitId,
|
|
14014
14381
|
subUnitId: "default",
|
|
14382
|
+
injector: popupInjector,
|
|
14015
14383
|
anchorRect: position,
|
|
14016
14384
|
anchorRect$: position$,
|
|
14017
14385
|
canvasElement: currentRender.engine.getCanvasElement()
|
|
@@ -14034,11 +14402,13 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
14034
14402
|
attachPopupToObject(targetObject, popup, unitId) {
|
|
14035
14403
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
14036
14404
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14405
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
14037
14406
|
const { position, position$, disposable } = this._createObjectPositionObserver(targetObject, currentRender);
|
|
14038
14407
|
const id = this._globalPopupManagerService.addPopup({
|
|
14039
14408
|
...popup,
|
|
14040
14409
|
unitId,
|
|
14041
14410
|
subUnitId: "default",
|
|
14411
|
+
injector: popupInjector,
|
|
14042
14412
|
anchorRect: position,
|
|
14043
14413
|
anchorRect$: position$,
|
|
14044
14414
|
canvasElement: currentRender.engine.getCanvasElement()
|
|
@@ -14064,12 +14434,14 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
14064
14434
|
const { direction = "top", multipleDirection } = popup;
|
|
14065
14435
|
const currentRender = this._renderManagerService.getRenderById(unitId);
|
|
14066
14436
|
if (!currentRender) throw new Error(`Current render not found, unitId: ${unitId}`);
|
|
14437
|
+
const popupInjector = this._resolveEmbeddedPopupInjector(unitId, currentRender);
|
|
14067
14438
|
const { positions: bounds, positions$: bounds$, disposable } = this._createRangePositionObserver(range, currentRender);
|
|
14068
14439
|
const position$ = bounds$.pipe((0, rxjs.map)((bounds) => direction.includes("top") ? bounds[0] : bounds[bounds.length - 1]));
|
|
14069
14440
|
const id = this._globalPopupManagerService.addPopup({
|
|
14070
14441
|
...popup,
|
|
14071
14442
|
unitId,
|
|
14072
14443
|
subUnitId: "default",
|
|
14444
|
+
injector: popupInjector,
|
|
14073
14445
|
anchorRect: direction.includes("top") ? bounds[0] : bounds[bounds.length - 1],
|
|
14074
14446
|
anchorRect$: position$,
|
|
14075
14447
|
excludeRects: bounds,
|
|
@@ -14090,6 +14462,10 @@ let DocCanvasPopManagerService = class DocCanvasPopManagerService extends _unive
|
|
|
14090
14462
|
canDispose: () => this._globalPopupManagerService.activePopupId !== id
|
|
14091
14463
|
};
|
|
14092
14464
|
}
|
|
14465
|
+
_resolveEmbeddedPopupInjector(unitId, currentRender) {
|
|
14466
|
+
var _this$_univerInstance, _currentRender$getInj;
|
|
14467
|
+
return ((_this$_univerInstance = this._univerInstanceService.getUnitCreateOptions(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.embeddedRender) === true ? (_currentRender$getInj = currentRender.getInjector) === null || _currentRender$getInj === void 0 ? void 0 : _currentRender$getInj.call(currentRender) : void 0;
|
|
14468
|
+
}
|
|
14093
14469
|
};
|
|
14094
14470
|
DocCanvasPopManagerService = __decorate([
|
|
14095
14471
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ICanvasPopupService)),
|
|
@@ -15048,7 +15424,7 @@ function DocSideMenuContent() {
|
|
|
15048
15424
|
* limitations under the License.
|
|
15049
15425
|
*/
|
|
15050
15426
|
let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
15051
|
-
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService) {
|
|
15427
|
+
constructor(_injector, _commandService, _layoutService, _menuManagerService, _uiPartsService, _univerInstanceService, _shortcutService, _configService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
15052
15428
|
super();
|
|
15053
15429
|
this._injector = _injector;
|
|
15054
15430
|
this._commandService = _commandService;
|
|
@@ -15058,6 +15434,7 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
15058
15434
|
this._univerInstanceService = _univerInstanceService;
|
|
15059
15435
|
this._shortcutService = _shortcutService;
|
|
15060
15436
|
this._configService = _configService;
|
|
15437
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
15061
15438
|
this._init();
|
|
15062
15439
|
}
|
|
15063
15440
|
_initUiParts() {
|
|
@@ -15103,9 +15480,15 @@ let DocUIController = class DocUIController extends _univerjs_core.Disposable {
|
|
|
15103
15480
|
}
|
|
15104
15481
|
_initFocusHandler() {
|
|
15105
15482
|
this.disposeWithMe(this._layoutService.registerFocusHandler(_univerjs_core.UniverInstanceType.UNIVER_DOC, (unitId) => {
|
|
15483
|
+
if (this._shouldPreserveEmbedFocus(unitId)) return;
|
|
15106
15484
|
this._injector.get(_univerjs_engine_render.IRenderManagerService).getRenderById(unitId).with(DocSelectionRenderService).focus();
|
|
15107
15485
|
}));
|
|
15108
15486
|
}
|
|
15487
|
+
_shouldPreserveEmbedFocus(unitId) {
|
|
15488
|
+
var _this$_embedRuntimeFo;
|
|
15489
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.shouldSuppressHostInteraction(unitId)) return true;
|
|
15490
|
+
return false;
|
|
15491
|
+
}
|
|
15109
15492
|
};
|
|
15110
15493
|
DocUIController = __decorate([
|
|
15111
15494
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
@@ -15115,112 +15498,1192 @@ DocUIController = __decorate([
|
|
|
15115
15498
|
__decorateParam(4, _univerjs_ui.IUIPartsService),
|
|
15116
15499
|
__decorateParam(5, _univerjs_core.IUniverInstanceService),
|
|
15117
15500
|
__decorateParam(6, _univerjs_ui.IShortcutService),
|
|
15118
|
-
__decorateParam(7, _univerjs_core.IConfigService)
|
|
15501
|
+
__decorateParam(7, _univerjs_core.IConfigService),
|
|
15502
|
+
__decorateParam(8, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedInteractionBoundaryService)),
|
|
15503
|
+
__decorateParam(9, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedRuntimeFocusCoordinator))
|
|
15119
15504
|
], DocUIController);
|
|
15120
15505
|
|
|
15121
15506
|
//#endregion
|
|
15122
|
-
//#region
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
15129
|
-
id
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
const
|
|
15141
|
-
|
|
15142
|
-
const allParagraphs = (_segment$getBody$para = (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
15143
|
-
const dataStream = (_segment$getBody$data = (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
15144
|
-
const paragraphs = (_BuildTextUtils$range = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(docRanges, allParagraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
|
|
15145
|
-
const doMutation = {
|
|
15146
|
-
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
15147
|
-
params: {
|
|
15148
|
-
unitId,
|
|
15149
|
-
actions: [],
|
|
15150
|
-
textRanges: docRanges
|
|
15151
|
-
}
|
|
15152
|
-
};
|
|
15153
|
-
const memoryCursor = new _univerjs_core.MemoryCursor();
|
|
15154
|
-
memoryCursor.reset();
|
|
15155
|
-
const textX = new _univerjs_core.TextX();
|
|
15156
|
-
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
15157
|
-
for (const paragraph of paragraphs) {
|
|
15158
|
-
const { startIndex } = paragraph;
|
|
15159
|
-
textX.push({
|
|
15160
|
-
t: _univerjs_core.TextXActionType.RETAIN,
|
|
15161
|
-
len: startIndex - memoryCursor.cursor
|
|
15162
|
-
});
|
|
15163
|
-
const paragraphStyle = {
|
|
15164
|
-
...paragraph.paragraphStyle,
|
|
15165
|
-
...config.paragraph
|
|
15166
|
-
};
|
|
15167
|
-
textX.push({
|
|
15168
|
-
t: _univerjs_core.TextXActionType.RETAIN,
|
|
15169
|
-
len: 1,
|
|
15170
|
-
body: {
|
|
15171
|
-
dataStream: "",
|
|
15172
|
-
paragraphs: [{
|
|
15173
|
-
...paragraph,
|
|
15174
|
-
paragraphStyle,
|
|
15175
|
-
startIndex: 0
|
|
15176
|
-
}]
|
|
15177
|
-
},
|
|
15178
|
-
coverType: _univerjs_core.UpdateDocsAttributeType.REPLACE
|
|
15179
|
-
});
|
|
15180
|
-
memoryCursor.moveCursorTo(startIndex + 1);
|
|
15181
|
-
}
|
|
15182
|
-
const path = (0, _univerjs_core.getRichTextEditPath)(docDataModel, segmentId);
|
|
15183
|
-
doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
|
|
15184
|
-
return !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
15507
|
+
//#region src/views/float-toolbar/FloatToolbar.tsx
|
|
15508
|
+
const DEFAULT_AVALIABLE_MENUS = [
|
|
15509
|
+
FLOAT_TEXT_STYLE_MENU_ID,
|
|
15510
|
+
SetInlineFormatFontSizeCommand.id,
|
|
15511
|
+
SetInlineFormatBoldCommand.id,
|
|
15512
|
+
SetInlineFormatItalicCommand.id,
|
|
15513
|
+
SetInlineFormatUnderlineCommand.id,
|
|
15514
|
+
SetInlineFormatStrikethroughCommand.id,
|
|
15515
|
+
SetInlineFormatSubscriptCommand.id,
|
|
15516
|
+
SetInlineFormatSuperscriptCommand.id,
|
|
15517
|
+
SetInlineFormatTextColorCommand.id,
|
|
15518
|
+
SetInlineFormatTextBackgroundColorCommand.id
|
|
15519
|
+
];
|
|
15520
|
+
function resolveFloatToolbarMenus(menuManagerService, avaliableMenus) {
|
|
15521
|
+
const floatToolbarMenus = menuManagerService.getMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION);
|
|
15522
|
+
const flatMenus = [...menuManagerService.getFlatMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION), ...menuManagerService.getFlatMenuByPositionKey(_univerjs_ui.MenuManagerPosition.RIBBON)];
|
|
15523
|
+
const menus = [];
|
|
15524
|
+
for (const key of avaliableMenus) {
|
|
15525
|
+
const item = flatMenus.find((item) => item.key === key);
|
|
15526
|
+
if (item) menus.push(item);
|
|
15185
15527
|
}
|
|
15186
|
-
|
|
15528
|
+
return {
|
|
15529
|
+
menus,
|
|
15530
|
+
extraMenus: floatToolbarMenus.filter((item) => item.item && !avaliableMenus.includes(item.key))
|
|
15531
|
+
};
|
|
15532
|
+
}
|
|
15533
|
+
function FloatToolbar(props) {
|
|
15534
|
+
const { avaliableMenus = DEFAULT_AVALIABLE_MENUS } = props;
|
|
15535
|
+
const menuManagerService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMenuManagerService);
|
|
15536
|
+
const [menus, setMenus] = (0, react.useState)([]);
|
|
15537
|
+
const [extraMenus, setExtraMenus] = (0, react.useState)([]);
|
|
15538
|
+
(0, react.useEffect)(() => {
|
|
15539
|
+
function getRibbon() {
|
|
15540
|
+
const { menus, extraMenus } = resolveFloatToolbarMenus(menuManagerService, avaliableMenus);
|
|
15541
|
+
setMenus(menus);
|
|
15542
|
+
setExtraMenus(extraMenus);
|
|
15543
|
+
}
|
|
15544
|
+
getRibbon();
|
|
15545
|
+
const subscription = menuManagerService.menuChanged$.subscribe(getRibbon);
|
|
15546
|
+
return () => {
|
|
15547
|
+
subscription.unsubscribe();
|
|
15548
|
+
};
|
|
15549
|
+
}, [avaliableMenus, menuManagerService]);
|
|
15550
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15551
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-rounded univer-bg-white univer-py-1.5 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
|
|
15552
|
+
children: [
|
|
15553
|
+
menus.map((groupItem) => groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15554
|
+
className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
|
|
15555
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ToolbarItem, { ...groupItem.item }, groupItem.key)
|
|
15556
|
+
}, groupItem.key)),
|
|
15557
|
+
extraMenus.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-my-1 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700" }),
|
|
15558
|
+
extraMenus.map((groupItem) => groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15559
|
+
className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
|
|
15560
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ToolbarItem, { ...groupItem.item }, groupItem.key)
|
|
15561
|
+
}, groupItem.key))
|
|
15562
|
+
]
|
|
15563
|
+
});
|
|
15564
|
+
}
|
|
15187
15565
|
|
|
15188
15566
|
//#endregion
|
|
15189
|
-
//#region src/
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
if (
|
|
15193
|
-
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && pageIndex % 2 === 1 ? evenPageFooterId : defaultFooterId;
|
|
15197
|
-
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && pageIndex % 2 === 1 ? evenPageFooterId : defaultFooterId;
|
|
15567
|
+
//#region src/services/float-menu.service.ts
|
|
15568
|
+
const FLOAT_MENU_COMPONENT_KEY = "univer.doc.float-menu";
|
|
15569
|
+
function isInSameLine(startNodePosition, endNodePosition) {
|
|
15570
|
+
if (startNodePosition == null || endNodePosition == null) return false;
|
|
15571
|
+
const { glyph: _startGlyph, ...startRest } = startNodePosition;
|
|
15572
|
+
const { glyph: _endGlyph, ...endRest } = endNodePosition;
|
|
15573
|
+
return (0, _univerjs_core.deepCompare)(startRest, endRest);
|
|
15198
15574
|
}
|
|
15199
|
-
const
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15575
|
+
const SKIP_SYMBOLS = [_univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK, _univerjs_core.DataStreamTreeTokenType.PARAGRAPH];
|
|
15576
|
+
let DocFloatMenuService = class DocFloatMenuService extends _univerjs_core.Disposable {
|
|
15577
|
+
constructor(_context, _docSelectionManagerService, _docCanvasPopManagerService, _componentManager, _univerInstanceService, _docSelectionRenderService) {
|
|
15578
|
+
super();
|
|
15579
|
+
this._context = _context;
|
|
15580
|
+
this._docSelectionManagerService = _docSelectionManagerService;
|
|
15581
|
+
this._docCanvasPopManagerService = _docCanvasPopManagerService;
|
|
15582
|
+
this._componentManager = _componentManager;
|
|
15583
|
+
this._univerInstanceService = _univerInstanceService;
|
|
15584
|
+
this._docSelectionRenderService = _docSelectionRenderService;
|
|
15585
|
+
_defineProperty(this, "_floatMenu", null);
|
|
15586
|
+
if ((0, _univerjs_core.isInternalEditorID)(this._context.unitId)) return;
|
|
15587
|
+
this._registerFloatMenu();
|
|
15588
|
+
this._initSelectionChange();
|
|
15589
|
+
this.disposeWithMe(() => {
|
|
15590
|
+
this._hideFloatMenu();
|
|
15591
|
+
});
|
|
15592
|
+
}
|
|
15593
|
+
get floatMenu() {
|
|
15594
|
+
return this._floatMenu;
|
|
15595
|
+
}
|
|
15596
|
+
hideFloatMenu() {
|
|
15597
|
+
this._hideFloatMenu();
|
|
15598
|
+
}
|
|
15599
|
+
_registerFloatMenu() {
|
|
15600
|
+
this.disposeWithMe(this._componentManager.register(FLOAT_MENU_COMPONENT_KEY, FloatToolbar));
|
|
15601
|
+
}
|
|
15602
|
+
_initSelectionChange() {
|
|
15603
|
+
this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
|
|
15604
|
+
this._hideFloatMenu();
|
|
15605
|
+
}));
|
|
15606
|
+
this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe((selection) => {
|
|
15607
|
+
const { unitId, textRanges } = selection;
|
|
15608
|
+
if (unitId !== this._context.unitId) return;
|
|
15609
|
+
const range = textRanges.length > 0 && textRanges.find((range) => !range.collapsed);
|
|
15610
|
+
if (range) {
|
|
15611
|
+
var _this$_floatMenu, _this$_floatMenu2;
|
|
15612
|
+
if (range.startOffset === ((_this$_floatMenu = this._floatMenu) === null || _this$_floatMenu === void 0 ? void 0 : _this$_floatMenu.start) && range.endOffset === ((_this$_floatMenu2 = this._floatMenu) === null || _this$_floatMenu2 === void 0 ? void 0 : _this$_floatMenu2.end)) return;
|
|
15613
|
+
this._hideFloatMenu();
|
|
15614
|
+
this._showFloatMenu(unitId, range);
|
|
15615
|
+
return;
|
|
15616
|
+
}
|
|
15617
|
+
this._hideFloatMenu();
|
|
15618
|
+
}));
|
|
15619
|
+
}
|
|
15620
|
+
_hideFloatMenu() {
|
|
15621
|
+
var _this$_floatMenu3;
|
|
15622
|
+
(_this$_floatMenu3 = this._floatMenu) === null || _this$_floatMenu3 === void 0 || _this$_floatMenu3.disposable.dispose();
|
|
15623
|
+
this._floatMenu = null;
|
|
15624
|
+
}
|
|
15625
|
+
_showFloatMenu(unitId, range) {
|
|
15626
|
+
var _documentDataModel$ge, _documentDataModel$ge2;
|
|
15627
|
+
const documentDataModel = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
15628
|
+
if (!documentDataModel || documentDataModel.getDisabled()) return;
|
|
15629
|
+
if (isRangeInCodeBlock(documentDataModel, range)) return;
|
|
15630
|
+
const token = (_documentDataModel$ge = documentDataModel.getBody()) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.dataStream[range.startOffset];
|
|
15631
|
+
if (range.endOffset - range.startOffset === 1 && token && SKIP_SYMBOLS.includes(token)) return;
|
|
15632
|
+
const wholeCustomRanges = (_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 || (_documentDataModel$ge2 = _documentDataModel$ge2.customRanges) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.filter((range) => range.wholeEntity);
|
|
15633
|
+
if (wholeCustomRanges === null || wholeCustomRanges === void 0 ? void 0 : wholeCustomRanges.some((customRange) => customRange.startIndex === range.startOffset && customRange.endIndex === range.endOffset - 1)) return;
|
|
15634
|
+
this._floatMenu = {
|
|
15635
|
+
disposable: this._docCanvasPopManagerService.attachPopupToRange(range, {
|
|
15636
|
+
componentKey: FLOAT_MENU_COMPONENT_KEY,
|
|
15637
|
+
direction: range.direction === "backward" || isInSameLine(range.startNodePosition, range.endNodePosition) ? "top-center" : "bottom-center",
|
|
15638
|
+
offset: [0, 4]
|
|
15639
|
+
}, unitId),
|
|
15640
|
+
start: range.startOffset,
|
|
15641
|
+
end: range.endOffset
|
|
15642
|
+
};
|
|
15643
|
+
return (0, _univerjs_core.toDisposable)(() => this._hideFloatMenu());
|
|
15644
|
+
}
|
|
15645
|
+
};
|
|
15646
|
+
DocFloatMenuService = __decorate([
|
|
15647
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
15648
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(DocCanvasPopManagerService)),
|
|
15649
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
|
|
15650
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
15651
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(DocSelectionRenderService))
|
|
15652
|
+
], DocFloatMenuService);
|
|
15653
|
+
function isRangeInCodeBlock(documentDataModel, range) {
|
|
15654
|
+
var _documentDataModel$ge3, _documentDataModel$ge4;
|
|
15655
|
+
return ((_documentDataModel$ge3 = (_documentDataModel$ge4 = documentDataModel.getBody()) === null || _documentDataModel$ge4 === void 0 ? void 0 : _documentDataModel$ge4.blockRanges) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : []).some((blockRange) => blockRange.blockType === _univerjs_core.DocumentBlockRangeType.CODE && Math.max(range.startOffset, blockRange.startIndex) <= Math.min(range.endOffset, blockRange.endIndex));
|
|
15656
|
+
}
|
|
15657
|
+
|
|
15658
|
+
//#endregion
|
|
15659
|
+
//#region src/embed-block.ts
|
|
15660
|
+
const EMBED_DOC_FIT_TO_WIDTH_OPTIONS = {
|
|
15661
|
+
mode: "fit-width",
|
|
15662
|
+
target: "container",
|
|
15663
|
+
paddingX: 0,
|
|
15664
|
+
minScale: 0,
|
|
15665
|
+
align: "start"
|
|
15666
|
+
};
|
|
15667
|
+
function createDocsEmbedBlockContribution() {
|
|
15668
|
+
return (0, _univerjs_embed_ui.createEmbedRibbonBlockContribution)({
|
|
15669
|
+
childType: _univerjs_core.UniverInstanceType.UNIVER_DOC,
|
|
15670
|
+
productName: "Docs"
|
|
15671
|
+
});
|
|
15672
|
+
}
|
|
15673
|
+
function createDocsEmbedChildViewContribution() {
|
|
15674
|
+
return {
|
|
15675
|
+
childType: _univerjs_core.UniverInstanceType.UNIVER_DOC,
|
|
15676
|
+
supportedLayouts: [
|
|
15677
|
+
"tab-peer",
|
|
15678
|
+
"doc-width-scale",
|
|
15679
|
+
"scroll-contained"
|
|
15680
|
+
],
|
|
15681
|
+
beforeDeactivate: deactivateEmbeddedDocSelection,
|
|
15682
|
+
mount: (context) => {
|
|
15683
|
+
if (context.renderScope.mode === "float") applyDocsEmbedFitToWidthConfig(context.runtimeScope.injector);
|
|
15684
|
+
return (0, _univerjs_embed_ui.mountEmbedRenderChildUnit)(context, _univerjs_engine_render.IRenderManagerService);
|
|
15685
|
+
}
|
|
15686
|
+
};
|
|
15687
|
+
}
|
|
15688
|
+
function deactivateEmbeddedDocSelection(context) {
|
|
15689
|
+
var _render$with;
|
|
15690
|
+
const render = context.injector.get(_univerjs_engine_render.IRenderManagerService).getRenderById(context.childUnitId);
|
|
15691
|
+
const docSelectionRenderService = render === null || render === void 0 ? void 0 : render.with(DocSelectionRenderService);
|
|
15692
|
+
render === null || render === void 0 || (_render$with = render.with(DocFloatMenuService)) === null || _render$with === void 0 || _render$with.hideFloatMenu();
|
|
15693
|
+
docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.removeAllRanges();
|
|
15694
|
+
docSelectionRenderService === null || docSelectionRenderService === void 0 || docSelectionRenderService.blur();
|
|
15695
|
+
}
|
|
15696
|
+
function applyDocsEmbedFitToWidthConfig(injector) {
|
|
15697
|
+
if (!injector.has(_univerjs_core.IConfigService)) return;
|
|
15698
|
+
const configService = injector.get(_univerjs_core.IConfigService);
|
|
15699
|
+
injector.add([_univerjs_core.IConfigService, { useValue: createDocsEmbedConfigService(configService) }]);
|
|
15700
|
+
}
|
|
15701
|
+
function createDocsEmbedConfigService(configService) {
|
|
15702
|
+
return new Proxy(configService, { get(target, property, receiver) {
|
|
15703
|
+
if (property === "getConfig") return (id) => {
|
|
15704
|
+
const config = target.getConfig(id);
|
|
15705
|
+
if (id !== "docs-ui.config") return config;
|
|
15706
|
+
return withDocsEmbedFitToWidthConfig(config);
|
|
15707
|
+
};
|
|
15708
|
+
return Reflect.get(target, property, receiver);
|
|
15709
|
+
} });
|
|
15710
|
+
}
|
|
15711
|
+
function withDocsEmbedFitToWidthConfig(config) {
|
|
15712
|
+
return {
|
|
15713
|
+
...config,
|
|
15714
|
+
fitToWidth: {
|
|
15715
|
+
...config === null || config === void 0 ? void 0 : config.fitToWidth,
|
|
15716
|
+
...EMBED_DOC_FIT_TO_WIDTH_OPTIONS
|
|
15717
|
+
}
|
|
15718
|
+
};
|
|
15719
|
+
}
|
|
15720
|
+
|
|
15721
|
+
//#endregion
|
|
15722
|
+
//#region src/embed-host-adapter.ts
|
|
15723
|
+
function createDocsCustomBlockHostAdapterContribution(anchorModelService, univerInstanceService, renderManagerService) {
|
|
15724
|
+
return {
|
|
15725
|
+
hostType: _univerjs_core.UniverInstanceType.UNIVER_DOC,
|
|
15726
|
+
entry: "docs-custom-block",
|
|
15727
|
+
createAnchorPlan: (context) => requireAnchorPlan(createDocsCustomBlockAnchorPlan(context, univerInstanceService), "EMBED_DOCS_CUSTOM_BLOCK_ANCHOR_UNAVAILABLE"),
|
|
15728
|
+
removeAnchorPlan: (context) => {
|
|
15729
|
+
const previous = anchorModelService === null || anchorModelService === void 0 ? void 0 : anchorModelService.getAnchor(context.hostUnitId, context.hostAnchorId);
|
|
15730
|
+
const record = previous !== null && previous !== void 0 ? previous : createDocsCustomBlockRecord(context);
|
|
15731
|
+
const plan = createDocsCustomBlockRemoveAnchorPlan(context, record, univerInstanceService);
|
|
15732
|
+
if (plan) return plan;
|
|
15733
|
+
return {
|
|
15734
|
+
redoMutations: [{
|
|
15735
|
+
id: _univerjs_embed_ui.REMOVE_EMBED_HOST_ANCHOR_RECORD_MUTATION_ID,
|
|
15736
|
+
params: {
|
|
15737
|
+
hostUnitId: context.hostUnitId,
|
|
15738
|
+
hostAnchorId: context.hostAnchorId
|
|
15739
|
+
}
|
|
15740
|
+
}],
|
|
15741
|
+
undoMutations: [{
|
|
15742
|
+
id: _univerjs_embed_ui.SET_EMBED_HOST_ANCHOR_RECORD_MUTATION_ID,
|
|
15743
|
+
params: { record: {
|
|
15744
|
+
...record,
|
|
15745
|
+
lifecycle: "active"
|
|
15746
|
+
} }
|
|
15747
|
+
}]
|
|
15748
|
+
};
|
|
15749
|
+
},
|
|
15750
|
+
afterCreateAnchor: (context) => refreshDocsCustomBlockLayout(renderManagerService, context.hostUnitId),
|
|
15751
|
+
afterRemoveAnchor: (context) => refreshDocsCustomBlockLayout(renderManagerService, context.hostUnitId)
|
|
15752
|
+
};
|
|
15753
|
+
}
|
|
15754
|
+
function createDocsCustomBlockHostContainerContribution() {
|
|
15755
|
+
return {
|
|
15756
|
+
hostType: _univerjs_core.UniverInstanceType.UNIVER_DOC,
|
|
15757
|
+
entry: "docs-custom-block",
|
|
15758
|
+
layout: "docs-sticky-sheet",
|
|
15759
|
+
supportedLayouts: [
|
|
15760
|
+
"docs-sticky-sheet",
|
|
15761
|
+
"docs-sticky-base",
|
|
15762
|
+
"aspect-fit",
|
|
15763
|
+
"scroll-contained"
|
|
15764
|
+
],
|
|
15765
|
+
menuBehavior: "floating"
|
|
15766
|
+
};
|
|
15767
|
+
}
|
|
15768
|
+
function createDocsCustomBlockAnchorPlan(context, univerInstanceService) {
|
|
15769
|
+
var _getDocDrawingsOrder$, _getDocDrawingsOrder, _context$descriptor, _context$descriptor2, _getString;
|
|
15770
|
+
if (!univerInstanceService) return;
|
|
15771
|
+
const record = createDocsCustomBlockRecord(context);
|
|
15772
|
+
const startIndex = getDocsCustomBlockInsertIndex(context, univerInstanceService);
|
|
15773
|
+
if (startIndex == null) return;
|
|
15774
|
+
const drawingOrderIndex = (_getDocDrawingsOrder$ = (_getDocDrawingsOrder = getDocDrawingsOrder(univerInstanceService, context.hostUnitId)) === null || _getDocDrawingsOrder === void 0 ? void 0 : _getDocDrawingsOrder.length) !== null && _getDocDrawingsOrder$ !== void 0 ? _getDocDrawingsOrder$ : 0;
|
|
15775
|
+
record.hostContext = {
|
|
15776
|
+
...record.hostContext,
|
|
15777
|
+
startIndex,
|
|
15778
|
+
drawingOrderIndex
|
|
15779
|
+
};
|
|
15780
|
+
return {
|
|
15781
|
+
hostAnchorId: record.hostAnchorId,
|
|
15782
|
+
redoMutations: [createDocsCustomBlockInsertMutation({
|
|
15783
|
+
unitId: record.hostUnitId,
|
|
15784
|
+
blockId: record.hostAnchorId,
|
|
15785
|
+
startIndex,
|
|
15786
|
+
drawingOrderIndex,
|
|
15787
|
+
embedId: record.embedId,
|
|
15788
|
+
childUnitId: (_context$descriptor = context.descriptor) === null || _context$descriptor === void 0 ? void 0 : _context$descriptor.childUnitId,
|
|
15789
|
+
childType: (_context$descriptor2 = context.descriptor) === null || _context$descriptor2 === void 0 ? void 0 : _context$descriptor2.childType,
|
|
15790
|
+
componentKey: (_getString = getString(record.hostContext, "componentKey")) !== null && _getString !== void 0 ? _getString : void 0,
|
|
15791
|
+
interactionMode: getInteractionMode(record.hostContext)
|
|
15792
|
+
}), {
|
|
15793
|
+
id: _univerjs_embed_ui.SET_EMBED_HOST_ANCHOR_RECORD_MUTATION_ID,
|
|
15794
|
+
params: { record }
|
|
15795
|
+
}],
|
|
15796
|
+
undoMutations: [{
|
|
15797
|
+
id: _univerjs_embed_ui.REMOVE_EMBED_HOST_ANCHOR_RECORD_MUTATION_ID,
|
|
15798
|
+
params: {
|
|
15799
|
+
hostUnitId: record.hostUnitId,
|
|
15800
|
+
hostAnchorId: record.hostAnchorId
|
|
15801
|
+
}
|
|
15802
|
+
}, createDocsCustomBlockRemoveMutation({
|
|
15803
|
+
unitId: record.hostUnitId,
|
|
15804
|
+
blockId: record.hostAnchorId,
|
|
15805
|
+
startIndex,
|
|
15806
|
+
drawingOrderIndex
|
|
15807
|
+
})]
|
|
15808
|
+
};
|
|
15809
|
+
}
|
|
15810
|
+
function createDocsCustomBlockRemoveAnchorPlan(context, record, univerInstanceService) {
|
|
15811
|
+
var _getDocsCustomBlockSt, _ref, _getDocDrawingOrderIn, _context$descriptor3, _context$descriptor4, _getString2;
|
|
15812
|
+
if (!univerInstanceService) return;
|
|
15813
|
+
const startIndex = (_getDocsCustomBlockSt = getDocsCustomBlockStartIndex(univerInstanceService, context.hostUnitId, context.hostAnchorId)) !== null && _getDocsCustomBlockSt !== void 0 ? _getDocsCustomBlockSt : getNumber(record.hostContext, "startIndex");
|
|
15814
|
+
const drawingOrderIndex = (_ref = (_getDocDrawingOrderIn = getDocDrawingOrderIndex(univerInstanceService, context.hostUnitId, context.hostAnchorId)) !== null && _getDocDrawingOrderIn !== void 0 ? _getDocDrawingOrderIn : getNumber(record.hostContext, "drawingOrderIndex")) !== null && _ref !== void 0 ? _ref : 0;
|
|
15815
|
+
if (startIndex == null) return;
|
|
15816
|
+
return {
|
|
15817
|
+
redoMutations: [{
|
|
15818
|
+
id: _univerjs_embed_ui.REMOVE_EMBED_HOST_ANCHOR_RECORD_MUTATION_ID,
|
|
15819
|
+
params: {
|
|
15820
|
+
hostUnitId: context.hostUnitId,
|
|
15821
|
+
hostAnchorId: context.hostAnchorId
|
|
15822
|
+
}
|
|
15823
|
+
}, createDocsCustomBlockRemoveMutation({
|
|
15824
|
+
unitId: context.hostUnitId,
|
|
15825
|
+
blockId: context.hostAnchorId,
|
|
15826
|
+
startIndex,
|
|
15827
|
+
drawingOrderIndex
|
|
15828
|
+
})],
|
|
15829
|
+
undoMutations: [createDocsCustomBlockInsertMutation({
|
|
15830
|
+
unitId: context.hostUnitId,
|
|
15831
|
+
blockId: context.hostAnchorId,
|
|
15832
|
+
startIndex,
|
|
15833
|
+
drawingOrderIndex,
|
|
15834
|
+
embedId: record.embedId,
|
|
15835
|
+
childUnitId: (_context$descriptor3 = context.descriptor) === null || _context$descriptor3 === void 0 ? void 0 : _context$descriptor3.childUnitId,
|
|
15836
|
+
childType: (_context$descriptor4 = context.descriptor) === null || _context$descriptor4 === void 0 ? void 0 : _context$descriptor4.childType,
|
|
15837
|
+
componentKey: (_getString2 = getString(record.hostContext, "componentKey")) !== null && _getString2 !== void 0 ? _getString2 : void 0,
|
|
15838
|
+
interactionMode: getInteractionMode(record.hostContext)
|
|
15839
|
+
}), {
|
|
15840
|
+
id: _univerjs_embed_ui.SET_EMBED_HOST_ANCHOR_RECORD_MUTATION_ID,
|
|
15841
|
+
params: { record: {
|
|
15842
|
+
...record,
|
|
15843
|
+
lifecycle: "active",
|
|
15844
|
+
hostContext: {
|
|
15845
|
+
...record.hostContext,
|
|
15846
|
+
startIndex,
|
|
15847
|
+
drawingOrderIndex
|
|
15848
|
+
}
|
|
15849
|
+
} }
|
|
15850
|
+
}]
|
|
15851
|
+
};
|
|
15852
|
+
}
|
|
15853
|
+
function createDocsCustomBlockRecord(context) {
|
|
15854
|
+
var _context$requestedAnc;
|
|
15855
|
+
return {
|
|
15856
|
+
hostAnchorId: (_context$requestedAnc = context.requestedAnchorId) !== null && _context$requestedAnc !== void 0 ? _context$requestedAnc : `docs-custom-block:${context.embedId}`,
|
|
15857
|
+
embedId: context.embedId,
|
|
15858
|
+
hostUnitId: context.hostUnitId,
|
|
15859
|
+
hostType: context.hostType,
|
|
15860
|
+
entry: context.entry,
|
|
15861
|
+
kind: "docs-custom-block",
|
|
15862
|
+
hostContext: context.hostContext,
|
|
15863
|
+
lifecycle: "active"
|
|
15864
|
+
};
|
|
15865
|
+
}
|
|
15866
|
+
function getDocsCustomBlockInsertIndex(context, univerInstanceService) {
|
|
15867
|
+
const explicit = getNumber(context.hostContext, "startIndex");
|
|
15868
|
+
if (explicit != null) return explicit;
|
|
15869
|
+
const body = getDocBody(univerInstanceService, context.hostUnitId);
|
|
15870
|
+
if (!(body === null || body === void 0 ? void 0 : body.dataStream)) return;
|
|
15871
|
+
return Math.max(0, body.dataStream.length - 2);
|
|
15872
|
+
}
|
|
15873
|
+
function getDocsCustomBlockStartIndex(univerInstanceService, unitId, blockId) {
|
|
15874
|
+
var _getDocBody;
|
|
15875
|
+
return (_getDocBody = getDocBody(univerInstanceService, unitId)) === null || _getDocBody === void 0 || (_getDocBody = _getDocBody.customBlocks) === null || _getDocBody === void 0 || (_getDocBody = _getDocBody.find((block) => block.blockId === blockId)) === null || _getDocBody === void 0 ? void 0 : _getDocBody.startIndex;
|
|
15876
|
+
}
|
|
15877
|
+
function getDocBody(univerInstanceService, unitId) {
|
|
15878
|
+
var _univerInstanceServic;
|
|
15879
|
+
return univerInstanceService === null || univerInstanceService === void 0 || (_univerInstanceServic = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getBody();
|
|
15880
|
+
}
|
|
15881
|
+
function getDocDrawingsOrder(univerInstanceService, unitId) {
|
|
15882
|
+
var _univerInstanceServic2, _univerInstanceServic3;
|
|
15883
|
+
return univerInstanceService === null || univerInstanceService === void 0 || (_univerInstanceServic2 = univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _univerInstanceServic2 === void 0 || (_univerInstanceServic3 = _univerInstanceServic2.getSnapshot) === null || _univerInstanceServic3 === void 0 ? void 0 : _univerInstanceServic3.call(_univerInstanceServic2).drawingsOrder;
|
|
15884
|
+
}
|
|
15885
|
+
function getDocDrawingOrderIndex(univerInstanceService, unitId, blockId) {
|
|
15886
|
+
var _getDocDrawingsOrder2;
|
|
15887
|
+
const index = (_getDocDrawingsOrder2 = getDocDrawingsOrder(univerInstanceService, unitId)) === null || _getDocDrawingsOrder2 === void 0 ? void 0 : _getDocDrawingsOrder2.indexOf(blockId);
|
|
15888
|
+
return index == null || index < 0 ? void 0 : index;
|
|
15889
|
+
}
|
|
15890
|
+
function getNumber(hostContext, key) {
|
|
15891
|
+
return typeof (hostContext === null || hostContext === void 0 ? void 0 : hostContext[key]) === "number" ? hostContext[key] : void 0;
|
|
15892
|
+
}
|
|
15893
|
+
function getString(hostContext, key) {
|
|
15894
|
+
return typeof (hostContext === null || hostContext === void 0 ? void 0 : hostContext[key]) === "string" ? hostContext[key] : void 0;
|
|
15895
|
+
}
|
|
15896
|
+
function getInteractionMode(hostContext) {
|
|
15897
|
+
const value = getString(hostContext, "interactionMode");
|
|
15898
|
+
return value === "inline" || value === "block" ? value : void 0;
|
|
15899
|
+
}
|
|
15900
|
+
function refreshDocsCustomBlockLayout(renderManagerService, unitId) {
|
|
15901
|
+
if (!renderManagerService) return;
|
|
15902
|
+
const refresh = () => {
|
|
15903
|
+
var _render$with;
|
|
15904
|
+
const render = renderManagerService.getRenderById(unitId);
|
|
15905
|
+
if (!render) return;
|
|
15906
|
+
render.engine.resize();
|
|
15907
|
+
(_render$with = render.with(DocPageLayoutService)) === null || _render$with === void 0 || _render$with.calculatePagePosition();
|
|
15908
|
+
render.components.forEach((component) => {
|
|
15909
|
+
component.makeDirty(true);
|
|
15910
|
+
});
|
|
15911
|
+
render.scene.makeDirty(true);
|
|
15912
|
+
};
|
|
15913
|
+
refresh();
|
|
15914
|
+
let remaining = 4;
|
|
15915
|
+
const schedule = typeof requestAnimationFrame === "function" ? requestAnimationFrame : (callback) => setTimeout(callback, 16);
|
|
15916
|
+
const run = () => {
|
|
15917
|
+
refresh();
|
|
15918
|
+
remaining -= 1;
|
|
15919
|
+
if (remaining > 0) schedule(run);
|
|
15920
|
+
};
|
|
15921
|
+
schedule(run);
|
|
15922
|
+
}
|
|
15923
|
+
function requireAnchorPlan(plan, errorCode) {
|
|
15924
|
+
if (!plan) throw new Error(errorCode);
|
|
15925
|
+
return plan;
|
|
15926
|
+
}
|
|
15927
|
+
|
|
15928
|
+
//#endregion
|
|
15929
|
+
//#region src/embed-product-menu.ts
|
|
15930
|
+
function registerDocsEmbedProductMenus(injector) {
|
|
15931
|
+
return (0, _univerjs_embed_ui.registerEmbedProductMenuContribution)(injector, {
|
|
15932
|
+
id: "docs-ui.ribbon",
|
|
15933
|
+
childType: _univerjs_core.UniverInstanceType.UNIVER_DOC,
|
|
15934
|
+
surface: "ribbon",
|
|
15935
|
+
menuSchema
|
|
15936
|
+
});
|
|
15937
|
+
}
|
|
15938
|
+
|
|
15939
|
+
//#endregion
|
|
15940
|
+
//#region src/embed-passive-viewport.ts
|
|
15941
|
+
function createDocsPassiveViewportProvider(injector) {
|
|
15942
|
+
return {
|
|
15943
|
+
childType: _univerjs_core.UniverInstanceType.UNIVER_DOC,
|
|
15944
|
+
handleWheel: (context) => {
|
|
15945
|
+
const passiveWheelHandlers = injector.has(_univerjs_embed_ui.EmbedPassiveWheelHandlerRegistryService) ? injector.get(_univerjs_embed_ui.EmbedPassiveWheelHandlerRegistryService) : void 0;
|
|
15946
|
+
if ((passiveWheelHandlers === null || passiveWheelHandlers === void 0 ? void 0 : passiveWheelHandlers.handleWheel(context)) === true) return true;
|
|
15947
|
+
if (!injector.has(_univerjs_engine_render.IRenderManagerService)) return false;
|
|
15948
|
+
const render = injector.get(_univerjs_engine_render.IRenderManagerService).getRenderById(context.childUnitId);
|
|
15949
|
+
const scene = render === null || render === void 0 ? void 0 : render.scene;
|
|
15950
|
+
return (0, _univerjs_embed_ui.scrollSceneViewportPassive)(context, scene === null || scene === void 0 ? void 0 : scene.getViewport("viewMain"), scene);
|
|
15951
|
+
}
|
|
15952
|
+
};
|
|
15953
|
+
}
|
|
15954
|
+
|
|
15955
|
+
//#endregion
|
|
15956
|
+
//#region src/embed-docs-custom-block-bleed.ts
|
|
15957
|
+
/**
|
|
15958
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
15959
|
+
*
|
|
15960
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15961
|
+
* you may not use this file except in compliance with the License.
|
|
15962
|
+
* You may obtain a copy of the License at
|
|
15963
|
+
*
|
|
15964
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15965
|
+
*
|
|
15966
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15967
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15968
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15969
|
+
* See the License for the specific language governing permissions and
|
|
15970
|
+
* limitations under the License.
|
|
15971
|
+
*/
|
|
15972
|
+
const DOCS_CUSTOM_BLOCK_VIEWPORT_INSET = 10;
|
|
15973
|
+
function createDefaultDocsTableLikeCustomBlockBleedViewport() {
|
|
15974
|
+
if (typeof window === "undefined") return {
|
|
15975
|
+
bleedLeft: 0,
|
|
15976
|
+
bleedRight: 0,
|
|
15977
|
+
bleedWidth: 1,
|
|
15978
|
+
contentWidth: 1,
|
|
15979
|
+
virtualWidth: 1
|
|
15980
|
+
};
|
|
15981
|
+
const bleedWidth = Math.max(1, window.innerWidth - DOCS_CUSTOM_BLOCK_VIEWPORT_INSET * 2);
|
|
15982
|
+
return {
|
|
15983
|
+
bleedLeft: 0,
|
|
15984
|
+
bleedRight: 0,
|
|
15985
|
+
bleedWidth,
|
|
15986
|
+
contentWidth: 1,
|
|
15987
|
+
virtualWidth: bleedWidth
|
|
15988
|
+
};
|
|
15989
|
+
}
|
|
15990
|
+
function resolveDocsTableLikeCustomBlockBleedViewport(root, contentWidth, hint) {
|
|
15991
|
+
const rootRect = root.getBoundingClientRect();
|
|
15992
|
+
const rootWidth = Math.max(1, rootRect.width);
|
|
15993
|
+
const normalizedContentWidth = Math.max(1, contentWidth);
|
|
15994
|
+
const hintedBleedLeft = hint === null || hint === void 0 ? void 0 : hint.bleedLeft;
|
|
15995
|
+
const hintedBleedWidth = hint === null || hint === void 0 ? void 0 : hint.bleedWidth;
|
|
15996
|
+
if (Number.isFinite(hintedBleedWidth) && (hintedBleedWidth !== null && hintedBleedWidth !== void 0 ? hintedBleedWidth : 0) > 0) {
|
|
15997
|
+
const bleedLeft = Math.max(0, hintedBleedLeft !== null && hintedBleedLeft !== void 0 ? hintedBleedLeft : 0);
|
|
15998
|
+
const bleedWidth = Math.max(1, hintedBleedWidth);
|
|
15999
|
+
return {
|
|
16000
|
+
bleedLeft,
|
|
16001
|
+
bleedRight: Math.max(0, bleedWidth - bleedLeft - rootWidth),
|
|
16002
|
+
bleedWidth,
|
|
16003
|
+
contentWidth: normalizedContentWidth,
|
|
16004
|
+
virtualWidth: Math.max(bleedWidth, bleedLeft + normalizedContentWidth)
|
|
16005
|
+
};
|
|
16006
|
+
}
|
|
16007
|
+
if (normalizedContentWidth <= rootWidth) return {
|
|
16008
|
+
bleedLeft: 0,
|
|
16009
|
+
bleedRight: 0,
|
|
16010
|
+
bleedWidth: rootWidth,
|
|
16011
|
+
contentWidth: normalizedContentWidth,
|
|
16012
|
+
virtualWidth: rootWidth
|
|
16013
|
+
};
|
|
16014
|
+
const bounds = resolveDocsTableLikeCustomBlockBleedBounds(root);
|
|
16015
|
+
const viewportLeft = bounds.left + DOCS_CUSTOM_BLOCK_VIEWPORT_INSET;
|
|
16016
|
+
const viewportWidth = Math.max(1, bounds.width - DOCS_CUSTOM_BLOCK_VIEWPORT_INSET * 2);
|
|
16017
|
+
const bleedLeft = Math.max(0, rootRect.left - viewportLeft);
|
|
16018
|
+
return {
|
|
16019
|
+
bleedLeft,
|
|
16020
|
+
bleedRight: Math.max(0, viewportLeft + viewportWidth - rootRect.right),
|
|
16021
|
+
bleedWidth: viewportWidth,
|
|
16022
|
+
contentWidth: normalizedContentWidth,
|
|
16023
|
+
virtualWidth: Math.max(viewportWidth, bleedLeft + normalizedContentWidth)
|
|
16024
|
+
};
|
|
16025
|
+
}
|
|
16026
|
+
function resolveDocsTableLikeCustomBlockContentWidth(authoritativeContentWidth, fallbackContentWidth) {
|
|
16027
|
+
return Number.isFinite(authoritativeContentWidth) && (authoritativeContentWidth !== null && authoritativeContentWidth !== void 0 ? authoritativeContentWidth : 0) > 0 ? authoritativeContentWidth : Math.max(1, fallbackContentWidth);
|
|
16028
|
+
}
|
|
16029
|
+
function resolveDocsTableLikeCustomBlockContentHeight(authoritativeContentHeight, fallbackContentHeight) {
|
|
16030
|
+
return Number.isFinite(authoritativeContentHeight) && (authoritativeContentHeight !== null && authoritativeContentHeight !== void 0 ? authoritativeContentHeight : 0) > 0 ? authoritativeContentHeight : Math.max(1, fallbackContentHeight);
|
|
16031
|
+
}
|
|
16032
|
+
function resolveDocsTableLikeCustomBlockBleedBounds(root) {
|
|
16033
|
+
const clippingAncestor = findClippingAncestor(root);
|
|
16034
|
+
if (clippingAncestor) {
|
|
16035
|
+
const rect = clippingAncestor.getBoundingClientRect();
|
|
16036
|
+
if (Number.isFinite(rect.width) && rect.width > 0) return {
|
|
16037
|
+
left: rect.left,
|
|
16038
|
+
width: rect.width
|
|
16039
|
+
};
|
|
16040
|
+
}
|
|
16041
|
+
return {
|
|
16042
|
+
left: 0,
|
|
16043
|
+
width: typeof window === "undefined" ? 1 : Math.max(1, window.innerWidth)
|
|
16044
|
+
};
|
|
16045
|
+
}
|
|
16046
|
+
function findClippingAncestor(root) {
|
|
16047
|
+
let current = root.parentElement;
|
|
16048
|
+
while (current && current !== document.body && current !== document.documentElement) {
|
|
16049
|
+
if (clipsOverflow(current)) return current;
|
|
16050
|
+
current = current.parentElement;
|
|
16051
|
+
}
|
|
16052
|
+
return null;
|
|
16053
|
+
}
|
|
16054
|
+
function clipsOverflow(element) {
|
|
16055
|
+
const style = window.getComputedStyle(element);
|
|
16056
|
+
return hasClippingOverflow(style.overflow) || hasClippingOverflow(style.overflowX) || hasClippingOverflow(style.overflowY);
|
|
16057
|
+
}
|
|
16058
|
+
function hasClippingOverflow(value) {
|
|
16059
|
+
return value === "hidden" || value === "auto" || value === "scroll" || value === "clip";
|
|
16060
|
+
}
|
|
16061
|
+
|
|
16062
|
+
//#endregion
|
|
16063
|
+
//#region src/embed-docs-custom-block-scroll.ts
|
|
16064
|
+
function scrollDocsTableLikeCustomBlockLive(event, live, options = {}) {
|
|
16065
|
+
if (event.defaultPrevented || event.ctrlKey || event.metaKey) return false;
|
|
16066
|
+
const deltaX = event.deltaX || (event.shiftKey ? event.deltaY : 0);
|
|
16067
|
+
const deltaY = event.shiftKey ? 0 : event.deltaY;
|
|
16068
|
+
const previousLeft = live.scrollLeft;
|
|
16069
|
+
const previousTop = live.scrollTop;
|
|
16070
|
+
const maxScrollLeft = resolveMaxScrollLeft(live, options.maxScrollLeft);
|
|
16071
|
+
if (deltaX && canScrollX(live, deltaX, maxScrollLeft)) live.scrollLeft = clampScroll(previousLeft + deltaX, 0, maxScrollLeft);
|
|
16072
|
+
if (deltaY && canScrollY(live, deltaY)) live.scrollTop = clampScroll(previousTop + deltaY, 0, live.scrollHeight - live.clientHeight);
|
|
16073
|
+
return live.scrollLeft !== previousLeft || live.scrollTop !== previousTop;
|
|
16074
|
+
}
|
|
16075
|
+
function canScrollX(element, deltaX, maxScrollLeft) {
|
|
16076
|
+
return element.scrollWidth > element.clientWidth && (deltaX < 0 ? element.scrollLeft > 0 : element.scrollLeft < maxScrollLeft);
|
|
16077
|
+
}
|
|
16078
|
+
function canScrollY(element, deltaY) {
|
|
16079
|
+
return element.scrollHeight > element.clientHeight && (deltaY < 0 ? element.scrollTop > 0 : element.scrollTop + element.clientHeight < element.scrollHeight);
|
|
16080
|
+
}
|
|
16081
|
+
function clampScroll(value, min, max) {
|
|
16082
|
+
return Math.max(min, Math.min(max, value));
|
|
16083
|
+
}
|
|
16084
|
+
function resolveMaxScrollLeft(element, requestedMaxScrollLeft) {
|
|
16085
|
+
const nativeMaxScrollLeft = Math.max(0, element.scrollWidth - element.clientWidth);
|
|
16086
|
+
if (!Number.isFinite(requestedMaxScrollLeft)) return nativeMaxScrollLeft;
|
|
16087
|
+
return clampScroll(requestedMaxScrollLeft !== null && requestedMaxScrollLeft !== void 0 ? requestedMaxScrollLeft : nativeMaxScrollLeft, 0, nativeMaxScrollLeft);
|
|
16088
|
+
}
|
|
16089
|
+
|
|
16090
|
+
//#endregion
|
|
16091
|
+
//#region src/EmbedDocsCustomBlockRenderer.tsx
|
|
16092
|
+
const SHEET_LIKE_CUSTOM_BLOCK_DEFAULT_CONTENT_HEIGHT = 480;
|
|
16093
|
+
const DOCS_CUSTOM_BLOCK_FLOATING_MENU_INSET_TOP = 52;
|
|
16094
|
+
const EMBED_DOCS_CUSTOM_BLOCK_STYLE_TEXT = `
|
|
16095
|
+
.univer-embed-docs-custom-block {
|
|
16096
|
+
position: relative;
|
|
16097
|
+
width: 100%;
|
|
16098
|
+
height: 100%;
|
|
16099
|
+
min-width: 0;
|
|
16100
|
+
min-height: 0;
|
|
16101
|
+
overflow: visible;
|
|
16102
|
+
}
|
|
16103
|
+
.univer-embed-docs-custom-block .univer-embed-float-dom__content {
|
|
16104
|
+
top: var(--univer-embed-docs-block-floating-menu-inset-top, 52px);
|
|
16105
|
+
height: calc(100% - var(--univer-embed-docs-block-floating-menu-inset-top, 52px));
|
|
16106
|
+
}
|
|
16107
|
+
.univer-embed-docs-custom-block .univer-docs-embed-floating-menu,
|
|
16108
|
+
.univer-embed-docs-custom-block .univer-sheet-embed-floating-menu,
|
|
16109
|
+
.univer-embed-docs-custom-block .univer-base-embed-floating-menu,
|
|
16110
|
+
.univer-embed-docs-custom-block .univer-slide-embed-floating-menu {
|
|
16111
|
+
top: calc(var(--univer-embed-docs-block-floating-menu-inset-top, 52px) * -1);
|
|
16112
|
+
left: 50%;
|
|
16113
|
+
transform: translateX(-50%);
|
|
16114
|
+
}
|
|
16115
|
+
.univer-embed-docs-custom-block[data-embed-docs-custom-block-sheet-like="true"] {
|
|
16116
|
+
contain: layout style;
|
|
16117
|
+
height: var(--univer-embed-docs-block-outer-height, 100%);
|
|
16118
|
+
min-height: var(--univer-embed-docs-block-outer-height, 100%);
|
|
16119
|
+
}
|
|
16120
|
+
.univer-embed-docs-custom-block[data-embed-docs-custom-block-sheet-like="true"] .univer-embed-float-dom__content {
|
|
16121
|
+
left: calc(var(--univer-embed-docs-block-bleed-left, 0px) * -1);
|
|
16122
|
+
width: var(--univer-embed-docs-block-bleed-width, 100%);
|
|
16123
|
+
height: var(--univer-embed-docs-block-viewport-height, 100%);
|
|
16124
|
+
overflow: hidden;
|
|
16125
|
+
transform: translateY(var(--univer-embed-docs-scroll-offset, 0px));
|
|
16126
|
+
}
|
|
16127
|
+
.univer-embed-docs-custom-block[data-embed-docs-custom-block-sheet-like="true"] .univer-embed-float-dom__content::after {
|
|
16128
|
+
border: 0;
|
|
16129
|
+
}
|
|
16130
|
+
.univer-embed-docs-custom-block[data-embed-docs-custom-block-sheet-like="true"] .univer-embed-float-dom__live {
|
|
16131
|
+
inset: 0;
|
|
16132
|
+
width: 100%;
|
|
16133
|
+
height: 100%;
|
|
16134
|
+
overflow: hidden;
|
|
16135
|
+
}
|
|
16136
|
+
.univer-embed-docs-custom-block[data-embed-docs-custom-block-sheet-like="true"] .univer-embed-float-dom__live::before {
|
|
16137
|
+
display: none;
|
|
16138
|
+
width: var(--univer-embed-docs-block-virtual-width, 100%);
|
|
16139
|
+
height: var(--univer-embed-docs-block-content-height, 1px);
|
|
16140
|
+
pointer-events: none;
|
|
16141
|
+
content: '';
|
|
16142
|
+
}
|
|
16143
|
+
.univer-embed-docs-custom-block[data-embed-docs-custom-block-sheet-like="true"] .univer-embed-float-dom__live-canvas,
|
|
16144
|
+
.univer-embed-docs-custom-block[data-embed-docs-custom-block-sheet-like="true"] .univer-embed-float-dom__live-content {
|
|
16145
|
+
left: var(--univer-embed-docs-block-bleed-left, 0px);
|
|
16146
|
+
width: var(--univer-embed-docs-block-bleed-width, 100%);
|
|
16147
|
+
height: var(--univer-embed-docs-block-viewport-height, 100%);
|
|
16148
|
+
min-height: var(--univer-embed-docs-block-viewport-height, 100%);
|
|
16149
|
+
}
|
|
16150
|
+
`;
|
|
16151
|
+
function EmbedDocsCustomBlockRenderer(props) {
|
|
16152
|
+
var _univerInstanceServic, _props$customBlockRen, _props$customBlockRen2, _props$customBlockRen3;
|
|
16153
|
+
ensureEmbedDocsCustomBlockStyles();
|
|
16154
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
16155
|
+
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
16156
|
+
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
16157
|
+
const data = normalizeFloatDomData(props.data);
|
|
16158
|
+
const hostUnitId = data === null || data === void 0 ? void 0 : data.hostUnitId;
|
|
16159
|
+
const resolvedHostUnitId = hostUnitId !== null && hostUnitId !== void 0 ? hostUnitId : (_univerInstanceServic = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) === null || _univerInstanceServic === void 0 ? void 0 : _univerInstanceServic.getUnitId();
|
|
16160
|
+
const rootRef = (0, react.useRef)(null);
|
|
16161
|
+
const liveRef = (0, react.useRef)(null);
|
|
16162
|
+
const [viewport, setViewport] = (0, react.useState)(() => createDefaultDocsTableLikeCustomBlockBleedViewport());
|
|
16163
|
+
const viewportRef = (0, react.useRef)(viewport);
|
|
16164
|
+
const sheetLike = isSheetLikeDocsCustomBlock(data);
|
|
16165
|
+
const customBlockRenderViewport = props.customBlockRenderViewport;
|
|
16166
|
+
const renderViewportBleedLeft = customBlockRenderViewport === null || customBlockRenderViewport === void 0 ? void 0 : customBlockRenderViewport.bleedLeft;
|
|
16167
|
+
const renderViewportBleedWidth = customBlockRenderViewport === null || customBlockRenderViewport === void 0 ? void 0 : customBlockRenderViewport.bleedWidth;
|
|
16168
|
+
const renderViewportContentWidth = customBlockRenderViewport === null || customBlockRenderViewport === void 0 ? void 0 : customBlockRenderViewport.contentWidth;
|
|
16169
|
+
viewportRef.current = viewport;
|
|
16170
|
+
(0, react.useEffect)(() => {
|
|
16171
|
+
if (!hostUnitId) return;
|
|
16172
|
+
const disposables = [];
|
|
16173
|
+
const refresh = () => {
|
|
16174
|
+
const documentModel = univerInstanceService.getUnit(hostUnitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16175
|
+
const zoomRatio = documentModel === null || documentModel === void 0 ? void 0 : documentModel.zoomRatio;
|
|
16176
|
+
if (typeof zoomRatio !== "number") return;
|
|
16177
|
+
commandService.syncExecuteCommand(SetDocZoomRatioOperation.id, {
|
|
16178
|
+
unitId: hostUnitId,
|
|
16179
|
+
zoomRatio
|
|
16180
|
+
});
|
|
16181
|
+
};
|
|
16182
|
+
const schedule = (callback) => {
|
|
16183
|
+
if (typeof requestAnimationFrame === "function") {
|
|
16184
|
+
const frame = requestAnimationFrame(callback);
|
|
16185
|
+
disposables.push(() => cancelAnimationFrame(frame));
|
|
16186
|
+
return;
|
|
16187
|
+
}
|
|
16188
|
+
const timer = setTimeout(callback, 16);
|
|
16189
|
+
disposables.push(() => clearTimeout(timer));
|
|
16190
|
+
};
|
|
16191
|
+
const scheduleDelay = (delay) => {
|
|
16192
|
+
const timer = setTimeout(refresh, delay);
|
|
16193
|
+
disposables.push(() => clearTimeout(timer));
|
|
16194
|
+
};
|
|
16195
|
+
refresh();
|
|
16196
|
+
schedule(refresh);
|
|
16197
|
+
schedule(() => schedule(refresh));
|
|
16198
|
+
scheduleDelay(120);
|
|
16199
|
+
scheduleDelay(500);
|
|
16200
|
+
return () => {
|
|
16201
|
+
disposables.forEach((dispose) => dispose());
|
|
16202
|
+
};
|
|
16203
|
+
}, [
|
|
16204
|
+
commandService,
|
|
16205
|
+
hostUnitId,
|
|
16206
|
+
univerInstanceService
|
|
16207
|
+
]);
|
|
16208
|
+
(0, react.useLayoutEffect)(() => {
|
|
16209
|
+
const root = rootRef.current;
|
|
16210
|
+
if (!root || !sheetLike || typeof window === "undefined") return;
|
|
16211
|
+
let frame;
|
|
16212
|
+
const sync = () => {
|
|
16213
|
+
frame = void 0;
|
|
16214
|
+
const rect = root.getBoundingClientRect();
|
|
16215
|
+
const next = resolveDocsTableLikeCustomBlockBleedViewport(root, resolveDocsTableLikeCustomBlockRuntimeContentWidth(renderViewportContentWidth, () => measureRuntimeContentWidth(root, rect.width)), {
|
|
16216
|
+
bleedLeft: renderViewportBleedLeft,
|
|
16217
|
+
bleedWidth: renderViewportBleedWidth
|
|
16218
|
+
});
|
|
16219
|
+
setViewport((previous) => Math.abs(previous.bleedLeft - next.bleedLeft) < .5 && Math.abs(previous.bleedRight - next.bleedRight) < .5 && Math.abs(previous.bleedWidth - next.bleedWidth) < .5 && Math.abs(previous.contentWidth - next.contentWidth) < .5 && Math.abs(previous.virtualWidth - next.virtualWidth) < .5 ? previous : next);
|
|
16220
|
+
};
|
|
16221
|
+
const schedule = () => {
|
|
16222
|
+
if (frame != null) return;
|
|
16223
|
+
frame = window.requestAnimationFrame(sync);
|
|
16224
|
+
};
|
|
16225
|
+
const scheduleFromScroll = (event) => {
|
|
16226
|
+
if (!shouldSyncDocsTableLikeCustomBlockBleedOnScroll(root, event.target)) return;
|
|
16227
|
+
schedule();
|
|
16228
|
+
};
|
|
16229
|
+
sync();
|
|
16230
|
+
const resizeObserver = new ResizeObserver(schedule);
|
|
16231
|
+
resizeObserver.observe(root);
|
|
16232
|
+
window.addEventListener("resize", schedule);
|
|
16233
|
+
window.addEventListener("scroll", scheduleFromScroll, true);
|
|
16234
|
+
return () => {
|
|
16235
|
+
if (frame != null) window.cancelAnimationFrame(frame);
|
|
16236
|
+
resizeObserver.disconnect();
|
|
16237
|
+
window.removeEventListener("resize", schedule);
|
|
16238
|
+
window.removeEventListener("scroll", scheduleFromScroll, true);
|
|
16239
|
+
};
|
|
16240
|
+
}, [
|
|
16241
|
+
renderViewportBleedLeft,
|
|
16242
|
+
renderViewportBleedWidth,
|
|
16243
|
+
renderViewportContentWidth,
|
|
16244
|
+
sheetLike
|
|
16245
|
+
]);
|
|
16246
|
+
(0, react.useLayoutEffect)(() => {
|
|
16247
|
+
const root = rootRef.current;
|
|
16248
|
+
if (!root || !sheetLike) {
|
|
16249
|
+
liveRef.current = null;
|
|
16250
|
+
return;
|
|
16251
|
+
}
|
|
16252
|
+
const findLiveRoot = () => {
|
|
16253
|
+
liveRef.current = root.querySelector(".univer-embed-float-dom__live");
|
|
16254
|
+
};
|
|
16255
|
+
findLiveRoot();
|
|
16256
|
+
const observer = new MutationObserver(findLiveRoot);
|
|
16257
|
+
observer.observe(root, {
|
|
16258
|
+
childList: true,
|
|
16259
|
+
subtree: true
|
|
16260
|
+
});
|
|
16261
|
+
return () => {
|
|
16262
|
+
liveRef.current = null;
|
|
16263
|
+
observer.disconnect();
|
|
16264
|
+
};
|
|
16265
|
+
}, [sheetLike]);
|
|
16266
|
+
const contentHeight = sheetLike ? resolveDocsTableLikeCustomBlockRuntimeContentHeight((_props$customBlockRen = props.customBlockRenderViewport) === null || _props$customBlockRen === void 0 ? void 0 : _props$customBlockRen.contentHeight) : resolveDocsTableLikeCustomBlockContentHeight((_props$customBlockRen2 = props.customBlockRenderViewport) === null || _props$customBlockRen2 === void 0 ? void 0 : _props$customBlockRen2.contentHeight, 1);
|
|
16267
|
+
const outerHeight = resolveDocsCustomBlockRuntimeOuterHeight({
|
|
16268
|
+
contentHeight,
|
|
16269
|
+
menuInsetTop: DOCS_CUSTOM_BLOCK_FLOATING_MENU_INSET_TOP,
|
|
16270
|
+
sheetLike
|
|
16271
|
+
});
|
|
16272
|
+
const viewportHeight = resolveDocsCustomBlockRuntimeViewportHeight({
|
|
16273
|
+
contentHeight,
|
|
16274
|
+
sheetLike,
|
|
16275
|
+
viewportHeight: (_props$customBlockRen3 = props.customBlockRenderViewport) === null || _props$customBlockRen3 === void 0 ? void 0 : _props$customBlockRen3.viewportHeight
|
|
16276
|
+
});
|
|
16277
|
+
const style = sheetLike ? {
|
|
16278
|
+
"--univer-embed-docs-block-bleed-left": `${viewport.bleedLeft}px`,
|
|
16279
|
+
"--univer-embed-docs-block-bleed-width": `${viewport.bleedWidth}px`,
|
|
16280
|
+
"--univer-embed-docs-block-content-height": `${contentHeight}px`,
|
|
16281
|
+
"--univer-embed-docs-block-content-width": `${viewport.contentWidth}px`,
|
|
16282
|
+
"--univer-embed-docs-block-floating-menu-inset-top": `${DOCS_CUSTOM_BLOCK_FLOATING_MENU_INSET_TOP}px`,
|
|
16283
|
+
"--univer-embed-docs-block-outer-height": `${outerHeight}px`,
|
|
16284
|
+
"--univer-embed-docs-block-viewport-height": `${viewportHeight}px`,
|
|
16285
|
+
"--univer-embed-docs-block-virtual-width": `${viewport.virtualWidth}px`
|
|
16286
|
+
} : { "--univer-embed-docs-block-floating-menu-inset-top": `${DOCS_CUSTOM_BLOCK_FLOATING_MENU_INSET_TOP}px` };
|
|
16287
|
+
const handleHostWheel = (0, react.useCallback)((event, context) => {
|
|
16288
|
+
var _renderManagerService;
|
|
16289
|
+
const scene = (_renderManagerService = renderManagerService.getRenderById(context.hostUnitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.scene;
|
|
16290
|
+
return (0, _univerjs_embed_ui.scrollSceneViewportPassive)({
|
|
16291
|
+
...context,
|
|
16292
|
+
event,
|
|
16293
|
+
source: "wheel",
|
|
16294
|
+
stage: "stage2"
|
|
16295
|
+
}, scene === null || scene === void 0 ? void 0 : scene.getViewport("viewMain"), scene);
|
|
16296
|
+
}, [renderManagerService]);
|
|
16297
|
+
const scrollHostViewportByWheel = (0, react.useCallback)((event) => {
|
|
16298
|
+
var _renderManagerService2;
|
|
16299
|
+
if (!resolvedHostUnitId) return false;
|
|
16300
|
+
const scene = (_renderManagerService2 = renderManagerService.getRenderById(resolvedHostUnitId)) === null || _renderManagerService2 === void 0 ? void 0 : _renderManagerService2.scene;
|
|
16301
|
+
return (0, _univerjs_embed_ui.scrollSceneViewportPassive)({
|
|
16302
|
+
event,
|
|
16303
|
+
source: "wheel",
|
|
16304
|
+
stage: "stage2"
|
|
16305
|
+
}, scene === null || scene === void 0 ? void 0 : scene.getViewport("viewMain"), scene);
|
|
16306
|
+
}, [renderManagerService, resolvedHostUnitId]);
|
|
16307
|
+
const handleRuntimeStageEnter = (0, react.useCallback)((stage) => {
|
|
16308
|
+
blurHostDocSelectionWhenEmbedRuntimeEntersStage(renderManagerService, resolvedHostUnitId, stage);
|
|
16309
|
+
}, [renderManagerService, resolvedHostUnitId]);
|
|
16310
|
+
(0, react.useEffect)(() => {
|
|
16311
|
+
const root = rootRef.current;
|
|
16312
|
+
if (!root || !sheetLike) return;
|
|
16313
|
+
const onWheel = (event) => {
|
|
16314
|
+
var _root$querySelector;
|
|
16315
|
+
if (!isDominantVerticalWheel(event)) return;
|
|
16316
|
+
if (((_root$querySelector = root.querySelector("[data-embed-float-dom]")) === null || _root$querySelector === void 0 ? void 0 : _root$querySelector.dataset.embedFloatStage) !== "stage2") return;
|
|
16317
|
+
if (!scrollHostViewportByWheel(event)) return;
|
|
16318
|
+
event.preventDefault();
|
|
16319
|
+
event.stopPropagation();
|
|
16320
|
+
event.stopImmediatePropagation();
|
|
16321
|
+
};
|
|
16322
|
+
root.addEventListener("wheel", onWheel, {
|
|
16323
|
+
capture: true,
|
|
16324
|
+
passive: false
|
|
16325
|
+
});
|
|
16326
|
+
return () => root.removeEventListener("wheel", onWheel, { capture: true });
|
|
16327
|
+
}, [scrollHostViewportByWheel, sheetLike]);
|
|
16328
|
+
(0, react.useEffect)(() => {
|
|
16329
|
+
const root = rootRef.current;
|
|
16330
|
+
if (!root || !sheetLike) return;
|
|
16331
|
+
const onWheel = createDocsTableLikeCustomBlockStage2WheelHandler({
|
|
16332
|
+
getLive: () => liveRef.current,
|
|
16333
|
+
getStage: () => {
|
|
16334
|
+
var _root$querySelector2;
|
|
16335
|
+
return (_root$querySelector2 = root.querySelector("[data-embed-float-dom]")) === null || _root$querySelector2 === void 0 ? void 0 : _root$querySelector2.dataset.embedFloatStage;
|
|
16336
|
+
},
|
|
16337
|
+
getMaxScrollLeft: () => {
|
|
16338
|
+
const maxScrollLeft = viewportRef.current.virtualWidth - viewportRef.current.bleedWidth;
|
|
16339
|
+
return maxScrollLeft > 0 ? maxScrollLeft : void 0;
|
|
16340
|
+
}
|
|
16341
|
+
});
|
|
16342
|
+
root.addEventListener("wheel", onWheel, {
|
|
16343
|
+
capture: true,
|
|
16344
|
+
passive: false
|
|
16345
|
+
});
|
|
16346
|
+
return () => root.removeEventListener("wheel", onWheel, { capture: true });
|
|
16347
|
+
}, [sheetLike]);
|
|
16348
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
16349
|
+
ref: rootRef,
|
|
16350
|
+
className: "univer-embed-docs-custom-block",
|
|
16351
|
+
"data-embed-docs-custom-block": "true",
|
|
16352
|
+
"data-embed-docs-custom-block-child-type": (data === null || data === void 0 ? void 0 : data.childType) == null ? void 0 : String(data.childType),
|
|
16353
|
+
"data-embed-docs-custom-block-sheet-like": sheetLike ? "true" : void 0,
|
|
16354
|
+
style,
|
|
16355
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_embed_ui.EmbedFloatDomRenderer, {
|
|
16356
|
+
...props,
|
|
16357
|
+
interactionFlow: "doc-block",
|
|
16358
|
+
onHostWheel: sheetLike ? handleHostWheel : void 0,
|
|
16359
|
+
onRuntimeStageEnter: handleRuntimeStageEnter,
|
|
16360
|
+
syncHostVerticalScroll: sheetLike
|
|
16361
|
+
})
|
|
16362
|
+
});
|
|
16363
|
+
}
|
|
16364
|
+
function blurHostDocSelectionWhenEmbedRuntimeEntersStage(renderManagerService, hostUnitId, stage) {
|
|
16365
|
+
var _renderManagerService3;
|
|
16366
|
+
if (stage !== "stage2" || !hostUnitId) return;
|
|
16367
|
+
(_renderManagerService3 = renderManagerService.getRenderById(hostUnitId)) === null || _renderManagerService3 === void 0 || (_renderManagerService3 = _renderManagerService3.with(DocSelectionRenderService)) === null || _renderManagerService3 === void 0 || _renderManagerService3.blur();
|
|
16368
|
+
}
|
|
16369
|
+
function createDocsTableLikeCustomBlockWheelHandler(options) {
|
|
16370
|
+
return (event) => {
|
|
16371
|
+
var _options$getMaxScroll;
|
|
16372
|
+
const live = options.getLive();
|
|
16373
|
+
if (!live || event.ctrlKey || event.metaKey) return;
|
|
16374
|
+
if (scrollDocsTableLikeCustomBlockLive(event, live, { maxScrollLeft: (_options$getMaxScroll = options.getMaxScrollLeft) === null || _options$getMaxScroll === void 0 ? void 0 : _options$getMaxScroll.call(options) })) {
|
|
16375
|
+
event.preventDefault();
|
|
16376
|
+
event.stopPropagation();
|
|
16377
|
+
}
|
|
16378
|
+
};
|
|
16379
|
+
}
|
|
16380
|
+
function createDocsTableLikeCustomBlockStage2WheelHandler(options) {
|
|
16381
|
+
const handleWheel = createDocsTableLikeCustomBlockWheelHandler(options);
|
|
16382
|
+
return (event) => {
|
|
16383
|
+
if (options.getStage() !== "stage2" || !isDominantHorizontalWheel(event)) return;
|
|
16384
|
+
handleWheel(event);
|
|
16385
|
+
};
|
|
16386
|
+
}
|
|
16387
|
+
function resolveDocsTableLikeCustomBlockRuntimeContentHeight(authoritativeContentHeight) {
|
|
16388
|
+
return resolveDocsTableLikeCustomBlockContentHeight(authoritativeContentHeight, SHEET_LIKE_CUSTOM_BLOCK_DEFAULT_CONTENT_HEIGHT);
|
|
16389
|
+
}
|
|
16390
|
+
function resolveDocsCustomBlockRuntimeViewportHeight(params) {
|
|
16391
|
+
return resolveDocsTableLikeCustomBlockContentHeight(params.viewportHeight, params.contentHeight);
|
|
16392
|
+
}
|
|
16393
|
+
function resolveDocsCustomBlockRuntimeOuterHeight(params) {
|
|
16394
|
+
return params.sheetLike ? params.contentHeight + params.menuInsetTop : params.contentHeight;
|
|
16395
|
+
}
|
|
16396
|
+
function resolveDocsTableLikeCustomBlockRuntimeContentWidth(authoritativeContentWidth, measureFallback) {
|
|
16397
|
+
if (Number.isFinite(authoritativeContentWidth) && (authoritativeContentWidth !== null && authoritativeContentWidth !== void 0 ? authoritativeContentWidth : 0) > 0) return authoritativeContentWidth;
|
|
16398
|
+
return resolveDocsTableLikeCustomBlockContentWidth(void 0, measureFallback());
|
|
16399
|
+
}
|
|
16400
|
+
function shouldSyncDocsTableLikeCustomBlockBleedOnScroll(root, target) {
|
|
16401
|
+
if (target instanceof Node && root.contains(target)) return false;
|
|
16402
|
+
return true;
|
|
16403
|
+
}
|
|
16404
|
+
function normalizeFloatDomData(data) {
|
|
16405
|
+
if (!data || typeof data !== "object") return;
|
|
16406
|
+
const candidate = data;
|
|
16407
|
+
if (candidate.version !== 1 || !candidate.embedId || !candidate.hostAnchorId) return;
|
|
16408
|
+
return candidate;
|
|
16409
|
+
}
|
|
16410
|
+
function isSheetLikeDocsCustomBlock(data) {
|
|
16411
|
+
return (data === null || data === void 0 ? void 0 : data.childType) === _univerjs_core.UniverInstanceType.UNIVER_SHEET || (data === null || data === void 0 ? void 0 : data.childType) === _univerjs_core.UniverInstanceType.UNIVER_BASE;
|
|
16412
|
+
}
|
|
16413
|
+
function isDominantVerticalWheel(event) {
|
|
16414
|
+
if (event.shiftKey || event.ctrlKey || event.metaKey) return false;
|
|
16415
|
+
return Math.abs(event.deltaY) > Math.abs(event.deltaX);
|
|
16416
|
+
}
|
|
16417
|
+
function isDominantHorizontalWheel(event) {
|
|
16418
|
+
if (event.ctrlKey || event.metaKey) return false;
|
|
16419
|
+
const deltaX = event.deltaX || (event.shiftKey ? event.deltaY : 0);
|
|
16420
|
+
const deltaY = event.shiftKey ? 0 : event.deltaY;
|
|
16421
|
+
return Math.abs(deltaX) > Math.abs(deltaY);
|
|
16422
|
+
}
|
|
16423
|
+
function measureRuntimeContentWidth(root, fallbackWidth) {
|
|
16424
|
+
const liveContent = root.querySelector(".univer-embed-float-dom__live-content");
|
|
16425
|
+
const liveCanvas = root.querySelector(".univer-embed-float-dom__live-canvas");
|
|
16426
|
+
const candidates = [Math.max(1, fallbackWidth)];
|
|
16427
|
+
collectElementContentWidth(liveContent, candidates);
|
|
16428
|
+
collectElementContentWidth(liveCanvas, candidates);
|
|
16429
|
+
return Math.max(...candidates.filter((value) => Number.isFinite(value) && value > 0));
|
|
16430
|
+
}
|
|
16431
|
+
function collectElementContentWidth(element, candidates) {
|
|
16432
|
+
if (!element) return;
|
|
16433
|
+
candidates.push(element.scrollWidth, element.offsetWidth, element.getBoundingClientRect().width);
|
|
16434
|
+
for (const child of Array.from(element.children)) {
|
|
16435
|
+
if (!(child instanceof HTMLElement)) continue;
|
|
16436
|
+
const childRect = child.getBoundingClientRect();
|
|
16437
|
+
const elementRect = element.getBoundingClientRect();
|
|
16438
|
+
candidates.push(child.scrollWidth, child.offsetWidth, childRect.right - elementRect.left);
|
|
16439
|
+
}
|
|
16440
|
+
}
|
|
16441
|
+
function ensureEmbedDocsCustomBlockStyles() {
|
|
16442
|
+
if (typeof document === "undefined" || document.getElementById("univer-embed-docs-custom-block-styles")) return;
|
|
16443
|
+
const style = document.createElement("style");
|
|
16444
|
+
style.id = "univer-embed-docs-custom-block-styles";
|
|
16445
|
+
style.textContent = EMBED_DOCS_CUSTOM_BLOCK_STYLE_TEXT;
|
|
16446
|
+
document.head.appendChild(style);
|
|
16447
|
+
}
|
|
16448
|
+
|
|
16449
|
+
//#endregion
|
|
16450
|
+
//#region src/EmbedFloatingMenu.tsx
|
|
16451
|
+
const DOCS_FLOATING_MENU_STYLE_ID = "univer-docs-embed-floating-menu-styles";
|
|
16452
|
+
const DOCS_FLOATING_MENU_STYLE_TEXT = `
|
|
16453
|
+
.univer-docs-embed-floating-menu {
|
|
16454
|
+
position: absolute;
|
|
16455
|
+
top: -36px;
|
|
16456
|
+
left: 50%;
|
|
16457
|
+
transform: translateX(-50%);
|
|
16458
|
+
z-index: 30;
|
|
16459
|
+
}
|
|
16460
|
+
[data-embed-floating-menu-entry="docs-custom-block"] .univer-docs-embed-floating-menu {
|
|
16461
|
+
top: calc(var(--univer-embed-docs-block-floating-menu-inset-top, 52px) * -1);
|
|
16462
|
+
}
|
|
16463
|
+
.univer-docs-embed-floating-menu:not([data-embed-float-stage="stage2"]) {
|
|
16464
|
+
display: none;
|
|
16465
|
+
}
|
|
16466
|
+
[data-embed-fullscreen-menu-slot="true"] .univer-docs-embed-floating-menu {
|
|
16467
|
+
position: static;
|
|
16468
|
+
margin: 6px auto;
|
|
16469
|
+
transform: none;
|
|
16470
|
+
}
|
|
16471
|
+
`;
|
|
16472
|
+
function createDocsFloatingMenuContributions() {
|
|
16473
|
+
return (0, _univerjs_embed_ui.createEmbedProductFloatingMenuContributions)({
|
|
16474
|
+
childType: _univerjs_core.UniverInstanceType.UNIVER_DOC,
|
|
16475
|
+
mount: mountDocsFloatingMenu
|
|
16476
|
+
});
|
|
16477
|
+
}
|
|
16478
|
+
function mountDocsFloatingMenu(context) {
|
|
16479
|
+
ensureDocsFloatingMenuStyles();
|
|
16480
|
+
const root = (0, _univerjs_embed_ui.resolveEmbedFloatingMenuRoot)(context);
|
|
16481
|
+
const menu = document.createElement("div");
|
|
16482
|
+
menu.setAttribute("data-embed-floating-menu-entry", context.descriptor.entry);
|
|
16483
|
+
root.appendChild(menu);
|
|
16484
|
+
const reactRoot = (0, _univerjs_embed_ui.createEmbedReactRoot)(menu);
|
|
16485
|
+
reactRoot.render((0, react.createElement)(_univerjs_embed_ui.EmbedRuntimeProviders, {
|
|
16486
|
+
injector: context.runtimeScope.injector,
|
|
16487
|
+
mountContainer: root,
|
|
16488
|
+
embedId: context.embedId
|
|
16489
|
+
}, (0, react.createElement)(DocsEmbedFloatingMenu, {
|
|
16490
|
+
hostUnitId: context.hostUnitId,
|
|
16491
|
+
embedId: context.embedId,
|
|
16492
|
+
fullscreen: Boolean(context.renderScope.fullscreen),
|
|
16493
|
+
usesDomFloatingStage: context.descriptor.entry !== "slides-floating-object",
|
|
16494
|
+
renderScopeActive$: context.renderScope.active$
|
|
16495
|
+
})));
|
|
16496
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
16497
|
+
(0, _univerjs_embed_ui.disposeEmbedReactRoot)(reactRoot);
|
|
16498
|
+
globalThis.setTimeout(() => menu.remove(), 0);
|
|
16499
|
+
});
|
|
16500
|
+
}
|
|
16501
|
+
function DocsEmbedFloatingMenu(props) {
|
|
16502
|
+
const { hostUnitId, embedId, fullscreen, usesDomFloatingStage, renderScopeActive$ } = props;
|
|
16503
|
+
const renderScopeActive = (0, _univerjs_ui.useObservable)(() => renderScopeActive$, false, false, [renderScopeActive$]);
|
|
16504
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
16505
|
+
const floatingActiveService = (0, _univerjs_ui.useDependency)(_univerjs_embed_ui.EmbedFloatingActiveService);
|
|
16506
|
+
const stage = resolveDocsFloatingMenuStage({
|
|
16507
|
+
embedId,
|
|
16508
|
+
active: (0, _univerjs_ui.useObservable)(() => floatingActiveService.active$, floatingActiveService.getActive(), false, [floatingActiveService]),
|
|
16509
|
+
fullscreen,
|
|
16510
|
+
usesDomFloatingStage,
|
|
16511
|
+
renderScopeActive
|
|
16512
|
+
});
|
|
16513
|
+
const removeEmbed = () => {
|
|
16514
|
+
commandService.executeCommand(_univerjs_embed_ui.RemoveHostEmbedCommand.id, {
|
|
16515
|
+
hostUnitId,
|
|
16516
|
+
embedId
|
|
16517
|
+
});
|
|
16518
|
+
};
|
|
16519
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
16520
|
+
className: "univer-docs-embed-floating-menu univer-box-border univer-inline-flex univer-h-8 univer-items-center univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-1 univer-text-gray-900 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:!univer-text-white",
|
|
16521
|
+
"data-embed-floating-menu": "true",
|
|
16522
|
+
"data-embed-id": embedId,
|
|
16523
|
+
"data-embed-float-stage": stage,
|
|
16524
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
16525
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
16526
|
+
type: "button",
|
|
16527
|
+
size: "small",
|
|
16528
|
+
variant: "ghost",
|
|
16529
|
+
className: "univer-size-6 univer-p-0 univer-text-red-500 hover:univer-text-red-600",
|
|
16530
|
+
title: "Delete embed block",
|
|
16531
|
+
"aria-label": "Delete embed block",
|
|
16532
|
+
onClick: removeEmbed,
|
|
16533
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, {})
|
|
16534
|
+
})
|
|
16535
|
+
});
|
|
16536
|
+
}
|
|
16537
|
+
function resolveDocsFloatingMenuStage(params) {
|
|
16538
|
+
return (0, _univerjs_embed_ui.resolveEmbedFloatingMenuStage)(params);
|
|
16539
|
+
}
|
|
16540
|
+
function ensureDocsFloatingMenuStyles() {
|
|
16541
|
+
if (typeof document === "undefined" || document.getElementById(DOCS_FLOATING_MENU_STYLE_ID)) return;
|
|
16542
|
+
const style = document.createElement("style");
|
|
16543
|
+
style.id = DOCS_FLOATING_MENU_STYLE_ID;
|
|
16544
|
+
style.textContent = DOCS_FLOATING_MENU_STYLE_TEXT;
|
|
16545
|
+
document.head.appendChild(style);
|
|
16546
|
+
}
|
|
16547
|
+
|
|
16548
|
+
//#endregion
|
|
16549
|
+
//#region src/embed-register.ts
|
|
16550
|
+
function registerDocsEmbedUIContributions(injector) {
|
|
16551
|
+
(0, _univerjs_embed_ui.registerEmbedUIContribution)(injector, "docs-ui.embed", registerDocsEmbedUIContributionsNow);
|
|
16552
|
+
}
|
|
16553
|
+
function registerDocsEmbedUIContributionsNow(injector) {
|
|
16554
|
+
const adapterRegistry = injector.get(_univerjs_embed_ui.EmbedHostAdapterRegistryService);
|
|
16555
|
+
const containerRegistry = injector.get(_univerjs_embed_ui.EmbedHostContainerRegistryService);
|
|
16556
|
+
const childViewRegistry = injector.get(_univerjs_embed_ui.EmbedChildViewRegistryService);
|
|
16557
|
+
const blockRegistry = injector.get(_univerjs_embed_ui.EmbedBlockRegistryService);
|
|
16558
|
+
const floatingMenuRegistry = injector.get(_univerjs_embed_ui.EmbedFloatingMenuRegistryService);
|
|
16559
|
+
const previewService = injector.get(_univerjs_embed_ui.EmbedFloatPreviewService);
|
|
16560
|
+
const passiveViewportRegistry = injector.get(_univerjs_embed_ui.EmbedPassiveViewportRegistryService);
|
|
16561
|
+
const anchorModelService = injector.has(_univerjs_embed_ui.EmbedHostAnchorModelService) ? injector.get(_univerjs_embed_ui.EmbedHostAnchorModelService) : void 0;
|
|
16562
|
+
const univerInstanceService = injector.has(_univerjs_core.IUniverInstanceService) ? injector.get(_univerjs_core.IUniverInstanceService) : void 0;
|
|
16563
|
+
const renderManagerService = injector.has(_univerjs_engine_render.IRenderManagerService) ? injector.get(_univerjs_engine_render.IRenderManagerService) : void 0;
|
|
16564
|
+
registerDocsEmbedProductMenus(injector);
|
|
16565
|
+
if (injector.has(_univerjs_ui.ComponentManager)) injector.get(_univerjs_ui.ComponentManager).register(EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY, EmbedDocsCustomBlockRenderer);
|
|
16566
|
+
const adapter = createDocsCustomBlockHostAdapterContribution(anchorModelService, univerInstanceService, renderManagerService);
|
|
16567
|
+
if (!adapterRegistry.get(adapter.hostType, adapter.entry)) adapterRegistry.register(adapter);
|
|
16568
|
+
const container = createDocsCustomBlockHostContainerContribution();
|
|
16569
|
+
if (!containerRegistry.get(container.hostType, container.entry)) containerRegistry.register(container);
|
|
16570
|
+
const childView = createDocsEmbedChildViewContribution();
|
|
16571
|
+
if (!childViewRegistry.get(childView.childType)) childViewRegistry.register(childView);
|
|
16572
|
+
const block = createDocsEmbedBlockContribution();
|
|
16573
|
+
if (!blockRegistry.get(block.childType)) blockRegistry.register(block);
|
|
16574
|
+
createDocsFloatingMenuContributions().forEach((floatingMenu) => {
|
|
16575
|
+
if (!floatingMenuRegistry.hasExact(floatingMenu.hostType, floatingMenu.entry, floatingMenu.childType)) floatingMenuRegistry.register(floatingMenu);
|
|
16576
|
+
});
|
|
16577
|
+
previewService.registerProvider((0, _univerjs_embed_ui.createEmbedRenderCanvasPreviewProvider)(injector, {
|
|
16578
|
+
childType: _univerjs_core.UniverInstanceType.UNIVER_DOC,
|
|
16579
|
+
renderManagerService: _univerjs_engine_render.IRenderManagerService
|
|
16580
|
+
}));
|
|
16581
|
+
if (!passiveViewportRegistry.get(_univerjs_core.UniverInstanceType.UNIVER_DOC)) passiveViewportRegistry.register(createDocsPassiveViewportProvider(injector));
|
|
16582
|
+
}
|
|
16583
|
+
|
|
16584
|
+
//#endregion
|
|
16585
|
+
//#region package.json
|
|
16586
|
+
var name = "@univerjs/docs-ui";
|
|
16587
|
+
var version = "1.0.0-insiders.20260701-0ef51b0";
|
|
16588
|
+
|
|
16589
|
+
//#endregion
|
|
16590
|
+
//#region src/commands/commands/doc-paragraph-setting.command.ts
|
|
16591
|
+
const DocParagraphSettingCommand = {
|
|
16592
|
+
id: "doc-paragraph-setting.command",
|
|
16593
|
+
type: _univerjs_core.CommandType.COMMAND,
|
|
16594
|
+
handler: async (accessor, config) => {
|
|
16595
|
+
var _segment$getBody$para, _segment$getBody, _segment$getBody$data, _segment$getBody2, _BuildTextUtils$range;
|
|
16596
|
+
const docSelectionManagerService = accessor.get(_univerjs_docs.DocSelectionManagerService);
|
|
16597
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
16598
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
16599
|
+
const docDataModel = univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16600
|
+
const docRanges = docSelectionManagerService.getDocRanges();
|
|
16601
|
+
if (!docDataModel || docRanges.length === 0 || !config) return false;
|
|
16602
|
+
const segmentId = docRanges[0].segmentId;
|
|
16603
|
+
const unitId = docDataModel.getUnitId();
|
|
16604
|
+
const segment = docDataModel.getSelfOrHeaderFooterModel(segmentId);
|
|
16605
|
+
const allParagraphs = (_segment$getBody$para = (_segment$getBody = segment.getBody()) === null || _segment$getBody === void 0 ? void 0 : _segment$getBody.paragraphs) !== null && _segment$getBody$para !== void 0 ? _segment$getBody$para : [];
|
|
16606
|
+
const dataStream = (_segment$getBody$data = (_segment$getBody2 = segment.getBody()) === null || _segment$getBody2 === void 0 ? void 0 : _segment$getBody2.dataStream) !== null && _segment$getBody$data !== void 0 ? _segment$getBody$data : "";
|
|
16607
|
+
const paragraphs = (_BuildTextUtils$range = _univerjs_core.BuildTextUtils.range.getParagraphsInRanges(docRanges, allParagraphs, dataStream)) !== null && _BuildTextUtils$range !== void 0 ? _BuildTextUtils$range : [];
|
|
16608
|
+
const doMutation = {
|
|
16609
|
+
id: _univerjs_docs.RichTextEditingMutation.id,
|
|
16610
|
+
params: {
|
|
16611
|
+
unitId,
|
|
16612
|
+
actions: [],
|
|
16613
|
+
textRanges: docRanges
|
|
16614
|
+
}
|
|
16615
|
+
};
|
|
16616
|
+
const memoryCursor = new _univerjs_core.MemoryCursor();
|
|
16617
|
+
memoryCursor.reset();
|
|
16618
|
+
const textX = new _univerjs_core.TextX();
|
|
16619
|
+
const jsonX = _univerjs_core.JSONX.getInstance();
|
|
16620
|
+
for (const paragraph of paragraphs) {
|
|
16621
|
+
const { startIndex } = paragraph;
|
|
16622
|
+
textX.push({
|
|
16623
|
+
t: _univerjs_core.TextXActionType.RETAIN,
|
|
16624
|
+
len: startIndex - memoryCursor.cursor
|
|
16625
|
+
});
|
|
16626
|
+
const paragraphStyle = {
|
|
16627
|
+
...paragraph.paragraphStyle,
|
|
16628
|
+
...config.paragraph
|
|
16629
|
+
};
|
|
16630
|
+
textX.push({
|
|
16631
|
+
t: _univerjs_core.TextXActionType.RETAIN,
|
|
16632
|
+
len: 1,
|
|
16633
|
+
body: {
|
|
16634
|
+
dataStream: "",
|
|
16635
|
+
paragraphs: [{
|
|
16636
|
+
...paragraph,
|
|
16637
|
+
paragraphStyle,
|
|
16638
|
+
startIndex: 0
|
|
16639
|
+
}]
|
|
16640
|
+
},
|
|
16641
|
+
coverType: _univerjs_core.UpdateDocsAttributeType.REPLACE
|
|
16642
|
+
});
|
|
16643
|
+
memoryCursor.moveCursorTo(startIndex + 1);
|
|
16644
|
+
}
|
|
16645
|
+
const path = (0, _univerjs_core.getRichTextEditPath)(docDataModel, segmentId);
|
|
16646
|
+
doMutation.params.actions = jsonX.editOp(textX.serialize(), path);
|
|
16647
|
+
return !!commandService.syncExecuteCommand(doMutation.id, doMutation.params);
|
|
16648
|
+
}
|
|
16649
|
+
};
|
|
16650
|
+
|
|
16651
|
+
//#endregion
|
|
16652
|
+
//#region src/views/header-footer/panel/DocHeaderFooterOptions.tsx
|
|
16653
|
+
function getSegmentId(documentStyle, editArea, pageIndex) {
|
|
16654
|
+
const { useFirstPageHeaderFooter, evenAndOddHeaders, defaultHeaderId, defaultFooterId, firstPageHeaderId, firstPageFooterId, evenPageHeaderId, evenPageFooterId } = documentStyle;
|
|
16655
|
+
if (editArea === _univerjs_engine_render.DocumentEditArea.HEADER) if (useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE) if (pageIndex === 0) return firstPageHeaderId;
|
|
16656
|
+
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && pageIndex % 2 === 1 ? evenPageHeaderId : defaultHeaderId;
|
|
16657
|
+
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && pageIndex % 2 === 1 ? evenPageHeaderId : defaultHeaderId;
|
|
16658
|
+
else if (useFirstPageHeaderFooter === _univerjs_core.BooleanNumber.TRUE) if (pageIndex === 0) return firstPageFooterId;
|
|
16659
|
+
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && pageIndex % 2 === 1 ? evenPageFooterId : defaultFooterId;
|
|
16660
|
+
else return evenAndOddHeaders === _univerjs_core.BooleanNumber.TRUE && pageIndex % 2 === 1 ? evenPageFooterId : defaultFooterId;
|
|
16661
|
+
}
|
|
16662
|
+
const DocHeaderFooterOptions = (props) => {
|
|
16663
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
16664
|
+
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
16665
|
+
const renderManagerService = (0, _univerjs_ui.useDependency)(_univerjs_engine_render.IRenderManagerService);
|
|
16666
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
16667
|
+
const layoutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
|
|
16668
|
+
const { unitId } = props;
|
|
16669
|
+
const docSelectionRenderService = renderManagerService.getRenderById(unitId).with(DocSelectionRenderService);
|
|
16670
|
+
const [options, setOptions] = (0, react.useState)({});
|
|
16671
|
+
const handleCheckboxChange = (val, type) => {
|
|
16672
|
+
var _renderManagerService;
|
|
16673
|
+
setOptions((prev) => ({
|
|
16674
|
+
...prev,
|
|
16675
|
+
[type]: val ? _univerjs_core.BooleanNumber.TRUE : _univerjs_core.BooleanNumber.FALSE
|
|
16676
|
+
}));
|
|
16677
|
+
const docDataModel = univerInstanceService.getUniverDocInstance(unitId);
|
|
16678
|
+
const documentStyle = docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getSnapshot().documentStyle;
|
|
16679
|
+
const docSkeletonManagerService = (_renderManagerService = renderManagerService.getRenderById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(_univerjs_docs.DocSkeletonManagerService);
|
|
16680
|
+
const viewModel = docSkeletonManagerService === null || docSkeletonManagerService === void 0 ? void 0 : docSkeletonManagerService.getViewModel();
|
|
16681
|
+
if (documentStyle == null || viewModel == null) return;
|
|
16682
|
+
const editArea = viewModel.getEditArea();
|
|
16683
|
+
let needCreateHeaderFooter = false;
|
|
16684
|
+
const segmentPage = docSelectionRenderService.getSegmentPage();
|
|
16685
|
+
let needChangeSegmentId = false;
|
|
16686
|
+
if (type === "useFirstPageHeaderFooter" && val === true) {
|
|
15224
16687
|
if (editArea === _univerjs_engine_render.DocumentEditArea.HEADER && !documentStyle.firstPageHeaderId) needCreateHeaderFooter = true;
|
|
15225
16688
|
else if (editArea === _univerjs_engine_render.DocumentEditArea.FOOTER && !documentStyle.firstPageFooterId) needCreateHeaderFooter = true;
|
|
15226
16689
|
if (needCreateHeaderFooter && segmentPage === 0) needChangeSegmentId = true;
|
|
@@ -16016,155 +17479,6 @@ function ParagraphSettingIndex() {
|
|
|
16016
17479
|
const DOC_PARAGRAPH_MENU_COMPONENT_KEY = "doc.paragraph.menu";
|
|
16017
17480
|
const DOC_TABLE_BLOCK_MENU_COMPONENT_KEY = "doc.table-block.menu";
|
|
16018
17481
|
|
|
16019
|
-
//#endregion
|
|
16020
|
-
//#region src/views/float-toolbar/FloatToolbar.tsx
|
|
16021
|
-
const DEFAULT_AVALIABLE_MENUS = [
|
|
16022
|
-
FLOAT_TEXT_STYLE_MENU_ID,
|
|
16023
|
-
SetInlineFormatFontSizeCommand.id,
|
|
16024
|
-
SetInlineFormatBoldCommand.id,
|
|
16025
|
-
SetInlineFormatItalicCommand.id,
|
|
16026
|
-
SetInlineFormatUnderlineCommand.id,
|
|
16027
|
-
SetInlineFormatStrikethroughCommand.id,
|
|
16028
|
-
SetInlineFormatSubscriptCommand.id,
|
|
16029
|
-
SetInlineFormatSuperscriptCommand.id,
|
|
16030
|
-
SetInlineFormatTextColorCommand.id,
|
|
16031
|
-
SetInlineFormatTextBackgroundColorCommand.id
|
|
16032
|
-
];
|
|
16033
|
-
function resolveFloatToolbarMenus(menuManagerService, avaliableMenus) {
|
|
16034
|
-
const floatToolbarMenus = menuManagerService.getMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION);
|
|
16035
|
-
const flatMenus = [...menuManagerService.getFlatMenuByPositionKey(FLOAT_TOOLBAR_MENU_POSITION), ...menuManagerService.getFlatMenuByPositionKey(_univerjs_ui.MenuManagerPosition.RIBBON)];
|
|
16036
|
-
const menus = [];
|
|
16037
|
-
for (const key of avaliableMenus) {
|
|
16038
|
-
const item = flatMenus.find((item) => item.key === key);
|
|
16039
|
-
if (item) menus.push(item);
|
|
16040
|
-
}
|
|
16041
|
-
return {
|
|
16042
|
-
menus,
|
|
16043
|
-
extraMenus: floatToolbarMenus.filter((item) => item.item && !avaliableMenus.includes(item.key))
|
|
16044
|
-
};
|
|
16045
|
-
}
|
|
16046
|
-
function FloatToolbar(props) {
|
|
16047
|
-
const { avaliableMenus = DEFAULT_AVALIABLE_MENUS } = props;
|
|
16048
|
-
const menuManagerService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMenuManagerService);
|
|
16049
|
-
const [menus, setMenus] = (0, react.useState)([]);
|
|
16050
|
-
const [extraMenus, setExtraMenus] = (0, react.useState)([]);
|
|
16051
|
-
(0, react.useEffect)(() => {
|
|
16052
|
-
function getRibbon() {
|
|
16053
|
-
const { menus, extraMenus } = resolveFloatToolbarMenus(menuManagerService, avaliableMenus);
|
|
16054
|
-
setMenus(menus);
|
|
16055
|
-
setExtraMenus(extraMenus);
|
|
16056
|
-
}
|
|
16057
|
-
getRibbon();
|
|
16058
|
-
const subscription = menuManagerService.menuChanged$.subscribe(getRibbon);
|
|
16059
|
-
return () => {
|
|
16060
|
-
subscription.unsubscribe();
|
|
16061
|
-
};
|
|
16062
|
-
}, [avaliableMenus, menuManagerService]);
|
|
16063
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
16064
|
-
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-rounded univer-bg-white univer-py-1.5 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900", _univerjs_design.borderClassName),
|
|
16065
|
-
children: [
|
|
16066
|
-
menus.map((groupItem) => groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
16067
|
-
className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
|
|
16068
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ToolbarItem, { ...groupItem.item }, groupItem.key)
|
|
16069
|
-
}, groupItem.key)),
|
|
16070
|
-
extraMenus.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-my-1 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700" }),
|
|
16071
|
-
extraMenus.map((groupItem) => groupItem.item && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
16072
|
-
className: "univer-flex univer-flex-nowrap univer-gap-2 univer-px-2",
|
|
16073
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ToolbarItem, { ...groupItem.item }, groupItem.key)
|
|
16074
|
-
}, groupItem.key))
|
|
16075
|
-
]
|
|
16076
|
-
});
|
|
16077
|
-
}
|
|
16078
|
-
|
|
16079
|
-
//#endregion
|
|
16080
|
-
//#region src/services/float-menu.service.ts
|
|
16081
|
-
const FLOAT_MENU_COMPONENT_KEY = "univer.doc.float-menu";
|
|
16082
|
-
function isInSameLine(startNodePosition, endNodePosition) {
|
|
16083
|
-
if (startNodePosition == null || endNodePosition == null) return false;
|
|
16084
|
-
const { glyph: _startGlyph, ...startRest } = startNodePosition;
|
|
16085
|
-
const { glyph: _endGlyph, ...endRest } = endNodePosition;
|
|
16086
|
-
return (0, _univerjs_core.deepCompare)(startRest, endRest);
|
|
16087
|
-
}
|
|
16088
|
-
const SKIP_SYMBOLS = [_univerjs_core.DataStreamTreeTokenType.CUSTOM_BLOCK, _univerjs_core.DataStreamTreeTokenType.PARAGRAPH];
|
|
16089
|
-
let DocFloatMenuService = class DocFloatMenuService extends _univerjs_core.Disposable {
|
|
16090
|
-
constructor(_context, _docSelectionManagerService, _docCanvasPopManagerService, _componentManager, _univerInstanceService, _docSelectionRenderService) {
|
|
16091
|
-
super();
|
|
16092
|
-
this._context = _context;
|
|
16093
|
-
this._docSelectionManagerService = _docSelectionManagerService;
|
|
16094
|
-
this._docCanvasPopManagerService = _docCanvasPopManagerService;
|
|
16095
|
-
this._componentManager = _componentManager;
|
|
16096
|
-
this._univerInstanceService = _univerInstanceService;
|
|
16097
|
-
this._docSelectionRenderService = _docSelectionRenderService;
|
|
16098
|
-
_defineProperty(this, "_floatMenu", null);
|
|
16099
|
-
if ((0, _univerjs_core.isInternalEditorID)(this._context.unitId)) return;
|
|
16100
|
-
this._registerFloatMenu();
|
|
16101
|
-
this._initSelectionChange();
|
|
16102
|
-
this.disposeWithMe(() => {
|
|
16103
|
-
this._hideFloatMenu();
|
|
16104
|
-
});
|
|
16105
|
-
}
|
|
16106
|
-
get floatMenu() {
|
|
16107
|
-
return this._floatMenu;
|
|
16108
|
-
}
|
|
16109
|
-
_registerFloatMenu() {
|
|
16110
|
-
this.disposeWithMe(this._componentManager.register(FLOAT_MENU_COMPONENT_KEY, FloatToolbar));
|
|
16111
|
-
}
|
|
16112
|
-
_initSelectionChange() {
|
|
16113
|
-
this.disposeWithMe(this._docSelectionRenderService.onSelectionStart$.subscribe(() => {
|
|
16114
|
-
this._hideFloatMenu();
|
|
16115
|
-
}));
|
|
16116
|
-
this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe((selection) => {
|
|
16117
|
-
const { unitId, textRanges } = selection;
|
|
16118
|
-
if (unitId !== this._context.unitId) return;
|
|
16119
|
-
const range = textRanges.length > 0 && textRanges.find((range) => !range.collapsed);
|
|
16120
|
-
if (range) {
|
|
16121
|
-
var _this$_floatMenu, _this$_floatMenu2;
|
|
16122
|
-
if (range.startOffset === ((_this$_floatMenu = this._floatMenu) === null || _this$_floatMenu === void 0 ? void 0 : _this$_floatMenu.start) && range.endOffset === ((_this$_floatMenu2 = this._floatMenu) === null || _this$_floatMenu2 === void 0 ? void 0 : _this$_floatMenu2.end)) return;
|
|
16123
|
-
this._hideFloatMenu();
|
|
16124
|
-
this._showFloatMenu(unitId, range);
|
|
16125
|
-
return;
|
|
16126
|
-
}
|
|
16127
|
-
this._hideFloatMenu();
|
|
16128
|
-
}));
|
|
16129
|
-
}
|
|
16130
|
-
_hideFloatMenu() {
|
|
16131
|
-
var _this$_floatMenu3;
|
|
16132
|
-
(_this$_floatMenu3 = this._floatMenu) === null || _this$_floatMenu3 === void 0 || _this$_floatMenu3.disposable.dispose();
|
|
16133
|
-
this._floatMenu = null;
|
|
16134
|
-
}
|
|
16135
|
-
_showFloatMenu(unitId, range) {
|
|
16136
|
-
var _documentDataModel$ge, _documentDataModel$ge2;
|
|
16137
|
-
const documentDataModel = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
16138
|
-
if (!documentDataModel || documentDataModel.getDisabled()) return;
|
|
16139
|
-
if (isRangeInCodeBlock(documentDataModel, range)) return;
|
|
16140
|
-
const token = (_documentDataModel$ge = documentDataModel.getBody()) === null || _documentDataModel$ge === void 0 ? void 0 : _documentDataModel$ge.dataStream[range.startOffset];
|
|
16141
|
-
if (range.endOffset - range.startOffset === 1 && token && SKIP_SYMBOLS.includes(token)) return;
|
|
16142
|
-
const wholeCustomRanges = (_documentDataModel$ge2 = documentDataModel.getBody()) === null || _documentDataModel$ge2 === void 0 || (_documentDataModel$ge2 = _documentDataModel$ge2.customRanges) === null || _documentDataModel$ge2 === void 0 ? void 0 : _documentDataModel$ge2.filter((range) => range.wholeEntity);
|
|
16143
|
-
if (wholeCustomRanges === null || wholeCustomRanges === void 0 ? void 0 : wholeCustomRanges.some((customRange) => customRange.startIndex === range.startOffset && customRange.endIndex === range.endOffset - 1)) return;
|
|
16144
|
-
this._floatMenu = {
|
|
16145
|
-
disposable: this._docCanvasPopManagerService.attachPopupToRange(range, {
|
|
16146
|
-
componentKey: FLOAT_MENU_COMPONENT_KEY,
|
|
16147
|
-
direction: range.direction === "backward" || isInSameLine(range.startNodePosition, range.endNodePosition) ? "top-center" : "bottom-center",
|
|
16148
|
-
offset: [0, 4]
|
|
16149
|
-
}, unitId),
|
|
16150
|
-
start: range.startOffset,
|
|
16151
|
-
end: range.endOffset
|
|
16152
|
-
};
|
|
16153
|
-
return (0, _univerjs_core.toDisposable)(() => this._hideFloatMenu());
|
|
16154
|
-
}
|
|
16155
|
-
};
|
|
16156
|
-
DocFloatMenuService = __decorate([
|
|
16157
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
16158
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(DocCanvasPopManagerService)),
|
|
16159
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
|
|
16160
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
16161
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(DocSelectionRenderService))
|
|
16162
|
-
], DocFloatMenuService);
|
|
16163
|
-
function isRangeInCodeBlock(documentDataModel, range) {
|
|
16164
|
-
var _documentDataModel$ge3, _documentDataModel$ge4;
|
|
16165
|
-
return ((_documentDataModel$ge3 = (_documentDataModel$ge4 = documentDataModel.getBody()) === null || _documentDataModel$ge4 === void 0 ? void 0 : _documentDataModel$ge4.blockRanges) !== null && _documentDataModel$ge3 !== void 0 ? _documentDataModel$ge3 : []).some((blockRange) => blockRange.blockType === _univerjs_core.DocumentBlockRangeType.CODE && Math.max(range.startOffset, blockRange.startIndex) <= Math.min(range.endOffset, blockRange.endIndex));
|
|
16166
|
-
}
|
|
16167
|
-
|
|
16168
17482
|
//#endregion
|
|
16169
17483
|
//#region src/services/doc-paragraph-menu.service.ts
|
|
16170
17484
|
const BLOCK_RANGE_ICON_MAP = {
|
|
@@ -19166,13 +20480,14 @@ DocIMEInputController = __decorate([
|
|
|
19166
20480
|
//#endregion
|
|
19167
20481
|
//#region src/controllers/render-controllers/doc-input.controller.ts
|
|
19168
20482
|
let DocInputController = class DocInputController extends _univerjs_core.Disposable {
|
|
19169
|
-
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService, _docMenuStyleService) {
|
|
20483
|
+
constructor(_context, _docSelectionRenderService, _docSkeletonManagerService, _commandService, _docMenuStyleService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
19170
20484
|
super();
|
|
19171
20485
|
this._context = _context;
|
|
19172
20486
|
this._docSelectionRenderService = _docSelectionRenderService;
|
|
19173
20487
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
19174
20488
|
this._commandService = _commandService;
|
|
19175
20489
|
this._docMenuStyleService = _docMenuStyleService;
|
|
20490
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
19176
20491
|
_defineProperty(this, "_onInputSubscription", void 0);
|
|
19177
20492
|
this._init();
|
|
19178
20493
|
}
|
|
@@ -19192,6 +20507,7 @@ let DocInputController = class DocInputController extends _univerjs_core.Disposa
|
|
|
19192
20507
|
const { event, content = "", activeRange } = config;
|
|
19193
20508
|
const e = event;
|
|
19194
20509
|
if (e.defaultPrevented) return;
|
|
20510
|
+
if (!_univerjs_core.SHEET_EDITOR_UNITS.includes(unitId) && this._isEmbedChildInputActive(unitId, e)) return;
|
|
19195
20511
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
19196
20512
|
if (e.data == null || skeleton == null || activeRange == null) return;
|
|
19197
20513
|
const { segmentId } = activeRange;
|
|
@@ -19227,12 +20543,21 @@ let DocInputController = class DocInputController extends _univerjs_core.Disposa
|
|
|
19227
20543
|
if (content === " ") await this._commandService.executeCommand(AfterSpaceCommand.id);
|
|
19228
20544
|
});
|
|
19229
20545
|
}
|
|
20546
|
+
_isEmbedChildInputActive(unitId, event) {
|
|
20547
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
20548
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, event.target, event)) return false;
|
|
20549
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
20550
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, event.target, event)) return true;
|
|
20551
|
+
return false;
|
|
20552
|
+
}
|
|
19230
20553
|
};
|
|
19231
20554
|
DocInputController = __decorate([
|
|
19232
20555
|
__decorateParam(1, (0, _univerjs_core.Inject)(DocSelectionRenderService)),
|
|
19233
20556
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
19234
20557
|
__decorateParam(3, _univerjs_core.ICommandService),
|
|
19235
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(DocMenuStyleService))
|
|
20558
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(DocMenuStyleService)),
|
|
20559
|
+
__decorateParam(5, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedInteractionBoundaryService)),
|
|
20560
|
+
__decorateParam(6, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedRuntimeFocusCoordinator))
|
|
19236
20561
|
], DocInputController);
|
|
19237
20562
|
|
|
19238
20563
|
//#endregion
|
|
@@ -19260,7 +20585,7 @@ DocResizeRenderController = __decorate([__decorateParam(1, (0, _univerjs_core.In
|
|
|
19260
20585
|
//#endregion
|
|
19261
20586
|
//#region src/controllers/render-controllers/doc-selection-render.controller.ts
|
|
19262
20587
|
let DocSelectionRenderController = class DocSelectionRenderController extends _univerjs_core.Disposable {
|
|
19263
|
-
constructor(_context, _commandService, _editorService, _instanceSrv, _docSelectionRenderService, _docSkeletonManagerService, _docSelectionManagerService) {
|
|
20588
|
+
constructor(_context, _commandService, _editorService, _instanceSrv, _docSelectionRenderService, _docSkeletonManagerService, _docSelectionManagerService, _embedInteractionBoundaryService, _embedRuntimeFocusCoordinator) {
|
|
19264
20589
|
super();
|
|
19265
20590
|
this._context = _context;
|
|
19266
20591
|
this._commandService = _commandService;
|
|
@@ -19269,6 +20594,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19269
20594
|
this._docSelectionRenderService = _docSelectionRenderService;
|
|
19270
20595
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
19271
20596
|
this._docSelectionManagerService = _docSelectionManagerService;
|
|
20597
|
+
this._embedRuntimeFocusCoordinator = _embedRuntimeFocusCoordinator;
|
|
19272
20598
|
_defineProperty(this, "_loadedMap", /* @__PURE__ */ new WeakSet());
|
|
19273
20599
|
this._initialize();
|
|
19274
20600
|
}
|
|
@@ -19300,6 +20626,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19300
20626
|
_syncSelection() {
|
|
19301
20627
|
this.disposeWithMe(this._docSelectionRenderService.textSelectionInner$.subscribe((params) => {
|
|
19302
20628
|
if (params == null) return;
|
|
20629
|
+
if (!(0, _univerjs_core.isInternalEditorID)(this._context.unitId) && this._isEmbedChildInteractionActive(this._context.unitId)) return;
|
|
19303
20630
|
this._docSelectionManagerService.__replaceTextRangesWithNoRefresh(params, {
|
|
19304
20631
|
unitId: this._context.unitId,
|
|
19305
20632
|
subUnitId: this._context.unitId
|
|
@@ -19318,8 +20645,10 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19318
20645
|
}));
|
|
19319
20646
|
this.disposeWithMe(document.onPointerDown$.subscribeEvent((evt, state) => {
|
|
19320
20647
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20648
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19321
20649
|
const docDataModel = this._instanceSrv.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
19322
20650
|
if ((docDataModel === null || docDataModel === void 0 ? void 0 : docDataModel.getUnitId()) !== unitId) this._instanceSrv.setCurrentUnitForType(unitId);
|
|
20651
|
+
this._instanceSrv.focusUnit(unitId);
|
|
19323
20652
|
const skeleton = this._docSkeletonManagerService.getSkeleton();
|
|
19324
20653
|
const { offsetX, offsetY } = evt;
|
|
19325
20654
|
const coord = this._getTransformCoordForDocumentOffset(offsetX, offsetY);
|
|
@@ -19352,10 +20681,12 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19352
20681
|
}));
|
|
19353
20682
|
this.disposeWithMe(document.onDblclick$.subscribeEvent((evt) => {
|
|
19354
20683
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20684
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19355
20685
|
this._docSelectionRenderService.__handleDblClick(evt);
|
|
19356
20686
|
}));
|
|
19357
20687
|
this.disposeWithMe(document.onTripleClick$.subscribeEvent((evt) => {
|
|
19358
20688
|
if (this._isEditorReadOnly(unitId)) return;
|
|
20689
|
+
if (this._isEmbedInteractionEvent(evt, unitId)) return;
|
|
19359
20690
|
this._docSelectionRenderService.__handleTripleClick(evt);
|
|
19360
20691
|
}));
|
|
19361
20692
|
}
|
|
@@ -19375,6 +20706,19 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19375
20706
|
_setEditorFocus(unitId) {
|
|
19376
20707
|
this._editorService.focus(unitId);
|
|
19377
20708
|
}
|
|
20709
|
+
_isEmbedInteractionEvent(evt, unitId) {
|
|
20710
|
+
var _this$_embedRuntimeFo, _this$_embedRuntimeFo2, _this$_embedRuntimeFo3;
|
|
20711
|
+
if ((0, _univerjs_core.isInternalEditorID)(unitId)) return false;
|
|
20712
|
+
const target = evt.target;
|
|
20713
|
+
if ((_this$_embedRuntimeFo = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo === void 0 ? void 0 : _this$_embedRuntimeFo.isChildUnitRuntimeEvent(unitId, target, evt)) return false;
|
|
20714
|
+
if ((_this$_embedRuntimeFo2 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo2 === void 0 ? void 0 : _this$_embedRuntimeFo2.isChildUnitInActiveSession(unitId)) return false;
|
|
20715
|
+
if ((_this$_embedRuntimeFo3 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo3 === void 0 ? void 0 : _this$_embedRuntimeFo3.shouldSuppressHostInteraction(unitId, target, evt)) return true;
|
|
20716
|
+
return isEmbedInteractionEvent(evt);
|
|
20717
|
+
}
|
|
20718
|
+
_isEmbedChildInteractionActive(unitId) {
|
|
20719
|
+
var _this$_embedRuntimeFo4;
|
|
20720
|
+
return ((_this$_embedRuntimeFo4 = this._embedRuntimeFocusCoordinator) === null || _this$_embedRuntimeFo4 === void 0 ? void 0 : _this$_embedRuntimeFo4.shouldSuppressHostInteraction(unitId)) === true;
|
|
20721
|
+
}
|
|
19378
20722
|
_commandExecutedListener() {
|
|
19379
20723
|
const updateCommandList = [SetDocZoomRatioOperation.id];
|
|
19380
20724
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
@@ -19382,6 +20726,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19382
20726
|
var _this$_docSelectionMa;
|
|
19383
20727
|
const { unitId: documentId } = command.params;
|
|
19384
20728
|
if (documentId !== ((_this$_docSelectionMa = this._docSelectionManagerService.__getCurrentSelection()) === null || _this$_docSelectionMa === void 0 ? void 0 : _this$_docSelectionMa.unitId)) return;
|
|
20729
|
+
if (this._isEmbedChildInteractionActive(documentId)) return;
|
|
19385
20730
|
this._docSelectionManagerService.refreshSelection();
|
|
19386
20731
|
}
|
|
19387
20732
|
}));
|
|
@@ -19391,6 +20736,7 @@ let DocSelectionRenderController = class DocSelectionRenderController extends _u
|
|
|
19391
20736
|
if (!skeleton) return;
|
|
19392
20737
|
const { unitId } = this._context;
|
|
19393
20738
|
if (!(0, _univerjs_core.isInternalEditorID)(unitId)) {
|
|
20739
|
+
if (this._isEmbedChildInteractionActive(unitId)) return;
|
|
19394
20740
|
this._docSelectionRenderService.focus();
|
|
19395
20741
|
const offset = findFirstCursorOffset(this._context.unit.getSnapshot());
|
|
19396
20742
|
this._docSelectionManagerService.replaceDocRanges([{
|
|
@@ -19410,8 +20756,219 @@ DocSelectionRenderController = __decorate([
|
|
|
19410
20756
|
__decorateParam(3, _univerjs_core.IUniverInstanceService),
|
|
19411
20757
|
__decorateParam(4, (0, _univerjs_core.Inject)(DocSelectionRenderService)),
|
|
19412
20758
|
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_docs.DocSkeletonManagerService)),
|
|
19413
|
-
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService))
|
|
20759
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_docs.DocSelectionManagerService)),
|
|
20760
|
+
__decorateParam(7, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedInteractionBoundaryService)),
|
|
20761
|
+
__decorateParam(8, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedRuntimeFocusCoordinator))
|
|
19414
20762
|
], DocSelectionRenderController);
|
|
20763
|
+
function isEmbedInteractionEvent(evt) {
|
|
20764
|
+
var _document$elementFrom;
|
|
20765
|
+
const target = evt.target;
|
|
20766
|
+
if (typeof Element !== "undefined" && target instanceof Element && target.closest(`[${_univerjs_embed_ui.EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`) != null) return true;
|
|
20767
|
+
if (typeof document === "undefined") return false;
|
|
20768
|
+
const point = getEventClientPoint(evt, target);
|
|
20769
|
+
const clientX = point === null || point === void 0 ? void 0 : point.clientX;
|
|
20770
|
+
const clientY = point === null || point === void 0 ? void 0 : point.clientY;
|
|
20771
|
+
if (typeof clientX !== "number" || typeof clientY !== "number" || !Number.isFinite(clientX) || !Number.isFinite(clientY)) return false;
|
|
20772
|
+
return ((_document$elementFrom = document.elementFromPoint(clientX, clientY)) === null || _document$elementFrom === void 0 ? void 0 : _document$elementFrom.closest(`[${_univerjs_embed_ui.EMBED_INTERACTION_BOUNDARY_OWNER_ATTRIBUTE}]`)) != null;
|
|
20773
|
+
}
|
|
20774
|
+
function getEventClientPoint(evt, target) {
|
|
20775
|
+
if (Number.isFinite(evt.clientX) && Number.isFinite(evt.clientY)) return {
|
|
20776
|
+
clientX: evt.clientX,
|
|
20777
|
+
clientY: evt.clientY
|
|
20778
|
+
};
|
|
20779
|
+
if (typeof Element !== "undefined" && target instanceof Element && Number.isFinite(evt.offsetX) && Number.isFinite(evt.offsetY)) {
|
|
20780
|
+
const rect = target.getBoundingClientRect();
|
|
20781
|
+
return {
|
|
20782
|
+
clientX: rect.left + evt.offsetX,
|
|
20783
|
+
clientY: rect.top + evt.offsetY
|
|
20784
|
+
};
|
|
20785
|
+
}
|
|
20786
|
+
if (Number.isFinite(evt.x) && Number.isFinite(evt.y)) return {
|
|
20787
|
+
clientX: evt.x,
|
|
20788
|
+
clientY: evt.y
|
|
20789
|
+
};
|
|
20790
|
+
}
|
|
20791
|
+
|
|
20792
|
+
//#endregion
|
|
20793
|
+
//#region src/embed-docs-custom-block-refresh.ts
|
|
20794
|
+
function collectDocsTableLikeEmbedChildUnitIds(drawings) {
|
|
20795
|
+
const childUnitIds = /* @__PURE__ */ new Set();
|
|
20796
|
+
Object.values(drawings !== null && drawings !== void 0 ? drawings : {}).forEach((drawing) => {
|
|
20797
|
+
const data = getDrawingData(drawing);
|
|
20798
|
+
const childUnitId = typeof (data === null || data === void 0 ? void 0 : data.childUnitId) === "string" ? data.childUnitId : void 0;
|
|
20799
|
+
const childType = typeof (data === null || data === void 0 ? void 0 : data.childType) === "number" ? data.childType : void 0;
|
|
20800
|
+
if (!childUnitId || !isSheetLikeDocsCustomBlockChildType(childType)) return;
|
|
20801
|
+
childUnitIds.add(childUnitId);
|
|
20802
|
+
});
|
|
20803
|
+
return childUnitIds;
|
|
20804
|
+
}
|
|
20805
|
+
function getDrawingData(drawing) {
|
|
20806
|
+
if (!drawing || typeof drawing !== "object") return;
|
|
20807
|
+
const data = drawing.data;
|
|
20808
|
+
return data && typeof data === "object" ? data : void 0;
|
|
20809
|
+
}
|
|
20810
|
+
function getCommandUnitId(commandParams) {
|
|
20811
|
+
if (!commandParams || typeof commandParams !== "object") return;
|
|
20812
|
+
const params = commandParams;
|
|
20813
|
+
if (typeof params.unitId === "string") return params.unitId;
|
|
20814
|
+
return typeof params.unitID === "string" ? params.unitID : void 0;
|
|
20815
|
+
}
|
|
20816
|
+
function shouldRefreshDocsCustomBlockSizeForCommand(params) {
|
|
20817
|
+
const commandUnitId = getCommandUnitId(params.commandParams);
|
|
20818
|
+
return Boolean(commandUnitId && commandUnitId !== params.hostUnitId && params.childUnitIds.has(commandUnitId));
|
|
20819
|
+
}
|
|
20820
|
+
function createDocsCustomBlockSizeRefreshScheduler(refresh, frameApi = getDefaultFrameApi()) {
|
|
20821
|
+
let pendingFrame;
|
|
20822
|
+
return {
|
|
20823
|
+
dispose: () => {
|
|
20824
|
+
if (pendingFrame == null) return;
|
|
20825
|
+
frameApi.cancelFrame(pendingFrame);
|
|
20826
|
+
pendingFrame = void 0;
|
|
20827
|
+
},
|
|
20828
|
+
schedule: () => {
|
|
20829
|
+
if (pendingFrame != null) return;
|
|
20830
|
+
pendingFrame = frameApi.requestFrame(() => {
|
|
20831
|
+
pendingFrame = void 0;
|
|
20832
|
+
refresh();
|
|
20833
|
+
});
|
|
20834
|
+
}
|
|
20835
|
+
};
|
|
20836
|
+
}
|
|
20837
|
+
function getDefaultFrameApi() {
|
|
20838
|
+
if (typeof requestAnimationFrame === "function" && typeof cancelAnimationFrame === "function") return {
|
|
20839
|
+
cancelFrame: (handle) => cancelAnimationFrame(handle),
|
|
20840
|
+
requestFrame: (callback) => requestAnimationFrame(callback)
|
|
20841
|
+
};
|
|
20842
|
+
return {
|
|
20843
|
+
cancelFrame: (handle) => clearTimeout(handle),
|
|
20844
|
+
requestFrame: (callback) => setTimeout(callback, 16)
|
|
20845
|
+
};
|
|
20846
|
+
}
|
|
20847
|
+
|
|
20848
|
+
//#endregion
|
|
20849
|
+
//#region src/controllers/render-controllers/embed-docs-custom-block-bleed.render-controller.ts
|
|
20850
|
+
let EmbedDocsCustomBlockBleedRenderController = class EmbedDocsCustomBlockBleedRenderController extends _univerjs_core.Disposable {
|
|
20851
|
+
constructor(_context, _univerInstanceService, _commandService, _contentSizeRegistry) {
|
|
20852
|
+
super();
|
|
20853
|
+
this._context = _context;
|
|
20854
|
+
this._univerInstanceService = _univerInstanceService;
|
|
20855
|
+
this._commandService = _commandService;
|
|
20856
|
+
this._contentSizeRegistry = _contentSizeRegistry;
|
|
20857
|
+
_defineProperty(this, "_resolvedChildUnits", /* @__PURE__ */ new Map());
|
|
20858
|
+
_defineProperty(this, "_pendingChildUnits", /* @__PURE__ */ new Map());
|
|
20859
|
+
const refreshScheduler = createDocsCustomBlockSizeRefreshScheduler(() => {
|
|
20860
|
+
const zoomRatio = this._context.unit.zoomRatio;
|
|
20861
|
+
if (typeof zoomRatio !== "number") return;
|
|
20862
|
+
this._commandService.syncExecuteCommand(SetDocZoomRatioOperation.id, {
|
|
20863
|
+
unitId: this._context.unitId,
|
|
20864
|
+
zoomRatio
|
|
20865
|
+
});
|
|
20866
|
+
});
|
|
20867
|
+
this.disposeWithMe(refreshScheduler);
|
|
20868
|
+
this.disposeWithMe({ dispose: () => {
|
|
20869
|
+
this._resolvedChildUnits.clear();
|
|
20870
|
+
this._pendingChildUnits.clear();
|
|
20871
|
+
} });
|
|
20872
|
+
const unregisterRenderViewportProvider = (0, _univerjs_engine_render.setDocsCustomBlockRenderViewportProvider)((unitId, blockId, input) => {
|
|
20873
|
+
var _this$_context$unit$g, _drawing$data, _drawing$data2, _drawing$data3, _this$_contentSizeReg, _contentSize$height, _this$_context$unit$g2;
|
|
20874
|
+
if (unitId !== this._context.unitId) return null;
|
|
20875
|
+
const drawing = (_this$_context$unit$g = this._context.unit.getSnapshot().drawings) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g[blockId];
|
|
20876
|
+
const childType = drawing === null || drawing === void 0 || (_drawing$data = drawing.data) === null || _drawing$data === void 0 ? void 0 : _drawing$data.childType;
|
|
20877
|
+
if (childType !== _univerjs_core.UniverInstanceType.UNIVER_SHEET && childType !== _univerjs_core.UniverInstanceType.UNIVER_BASE) return null;
|
|
20878
|
+
const visibleCanvas = this._getVisibleCanvasDocumentRect();
|
|
20879
|
+
const childUnit = (drawing === null || drawing === void 0 || (_drawing$data2 = drawing.data) === null || _drawing$data2 === void 0 ? void 0 : _drawing$data2.childUnitId) ? this._getChildUnitForMeasurement(drawing.data.childUnitId, childType, refreshScheduler.schedule) : void 0;
|
|
20880
|
+
const contentSize = (drawing === null || drawing === void 0 || (_drawing$data3 = drawing.data) === null || _drawing$data3 === void 0 ? void 0 : _drawing$data3.childUnitId) && childUnit != null ? (_this$_contentSizeReg = this._contentSizeRegistry) === null || _this$_contentSizeReg === void 0 ? void 0 : _this$_contentSizeReg.measureContentSize({
|
|
20881
|
+
childType,
|
|
20882
|
+
childUnit,
|
|
20883
|
+
childUnitId: drawing.data.childUnitId,
|
|
20884
|
+
viewportWidth: input.fallbackWidth
|
|
20885
|
+
}) : void 0;
|
|
20886
|
+
const fallbackSize = resolveDocsCustomBlockSize(childType);
|
|
20887
|
+
const fallbackHeight = normalizeFallbackSize(input.fallbackHeight, fallbackSize.height);
|
|
20888
|
+
const fallbackWidth = normalizeFallbackSize(input.fallbackWidth, fallbackSize.width);
|
|
20889
|
+
return resolveDocsCustomBlockRenderViewport({
|
|
20890
|
+
childType,
|
|
20891
|
+
contentHeight: (_contentSize$height = contentSize === null || contentSize === void 0 ? void 0 : contentSize.height) !== null && _contentSize$height !== void 0 ? _contentSize$height : fallbackHeight,
|
|
20892
|
+
contentWidth: contentSize === null || contentSize === void 0 ? void 0 : contentSize.width,
|
|
20893
|
+
docsLeft: this._getDocsLeft(),
|
|
20894
|
+
documentFlavor: (_this$_context$unit$g2 = this._context.unit.getSnapshot().documentStyle) === null || _this$_context$unit$g2 === void 0 ? void 0 : _this$_context$unit$g2.documentFlavor,
|
|
20895
|
+
fallbackHeight,
|
|
20896
|
+
fallbackWidth,
|
|
20897
|
+
pageMarginLeft: input.pageMarginLeft,
|
|
20898
|
+
pageMarginRight: input.pageMarginRight,
|
|
20899
|
+
pageWidth: input.pageWidth,
|
|
20900
|
+
scale: this._context.scene.getAncestorScale().scaleX || 1,
|
|
20901
|
+
visibleCanvasHeight: visibleCanvas === null || visibleCanvas === void 0 ? void 0 : visibleCanvas.height,
|
|
20902
|
+
visibleCanvasLeft: visibleCanvas === null || visibleCanvas === void 0 ? void 0 : visibleCanvas.left,
|
|
20903
|
+
visibleCanvasWidth: visibleCanvas === null || visibleCanvas === void 0 ? void 0 : visibleCanvas.width
|
|
20904
|
+
});
|
|
20905
|
+
});
|
|
20906
|
+
this.disposeWithMe({ dispose: unregisterRenderViewportProvider });
|
|
20907
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
20908
|
+
if (command.id === SetDocZoomRatioOperation.id) return;
|
|
20909
|
+
if (!shouldRefreshDocsCustomBlockSizeForCommand({
|
|
20910
|
+
childUnitIds: collectDocsTableLikeEmbedChildUnitIds(this._context.unit.getSnapshot().drawings),
|
|
20911
|
+
commandParams: command.params,
|
|
20912
|
+
hostUnitId: this._context.unitId
|
|
20913
|
+
})) return;
|
|
20914
|
+
refreshScheduler.schedule();
|
|
20915
|
+
}));
|
|
20916
|
+
}
|
|
20917
|
+
_getChildUnitForMeasurement(childUnitId, childType, scheduleRefresh) {
|
|
20918
|
+
const cacheKey = `${childType}:${childUnitId}`;
|
|
20919
|
+
if (this._resolvedChildUnits.has(cacheKey)) return this._resolvedChildUnits.get(cacheKey);
|
|
20920
|
+
const unitOrPromise = this._univerInstanceService.getUnit(childUnitId, childType);
|
|
20921
|
+
if (!isPromiseLike(unitOrPromise)) {
|
|
20922
|
+
this._resolvedChildUnits.set(cacheKey, unitOrPromise);
|
|
20923
|
+
return unitOrPromise;
|
|
20924
|
+
}
|
|
20925
|
+
if (!this._pendingChildUnits.has(cacheKey)) {
|
|
20926
|
+
const pending = Promise.resolve(unitOrPromise).then((unit) => {
|
|
20927
|
+
this._pendingChildUnits.delete(cacheKey);
|
|
20928
|
+
this._resolvedChildUnits.set(cacheKey, unit);
|
|
20929
|
+
if (!this._disposed) scheduleRefresh();
|
|
20930
|
+
return unit;
|
|
20931
|
+
}, () => {
|
|
20932
|
+
this._pendingChildUnits.delete(cacheKey);
|
|
20933
|
+
});
|
|
20934
|
+
this._pendingChildUnits.set(cacheKey, pending);
|
|
20935
|
+
}
|
|
20936
|
+
}
|
|
20937
|
+
_getDocsLeft() {
|
|
20938
|
+
var _getOffsetConfig$docs, _this$_context$mainCo, _getOffsetConfig;
|
|
20939
|
+
return (_getOffsetConfig$docs = (_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || (_getOffsetConfig = _this$_context$mainCo.getOffsetConfig) === null || _getOffsetConfig === void 0 || (_getOffsetConfig = _getOffsetConfig.call(_this$_context$mainCo)) === null || _getOffsetConfig === void 0 ? void 0 : _getOffsetConfig.docsLeft) !== null && _getOffsetConfig$docs !== void 0 ? _getOffsetConfig$docs : 0;
|
|
20940
|
+
}
|
|
20941
|
+
_getVisibleCanvasDocumentRect() {
|
|
20942
|
+
var _this$_context$scene$, _this$_context$scene$2, _this$_context$engine, _this$_context$engine2, _this$_context$engine3, _width, _this$_context$mainCo2, _ref, _height, _this$_context$mainCo3, _ref2;
|
|
20943
|
+
const scaleX = this._context.scene.getAncestorScale().scaleX || 1;
|
|
20944
|
+
const scaleY = this._context.scene.getAncestorScale().scaleY || 1;
|
|
20945
|
+
const viewportLeft = (_this$_context$scene$ = (_this$_context$scene$2 = this._context.scene.getViewport("viewMain")) === null || _this$_context$scene$2 === void 0 ? void 0 : _this$_context$scene$2.viewportScrollX) !== null && _this$_context$scene$ !== void 0 ? _this$_context$scene$ : 0;
|
|
20946
|
+
const canvasRect = (_this$_context$engine = (_this$_context$engine2 = this._context.engine).getCanvasElement) === null || _this$_context$engine === void 0 || (_this$_context$engine = _this$_context$engine.call(_this$_context$engine2)) === null || _this$_context$engine === void 0 || (_this$_context$engine3 = _this$_context$engine.getBoundingClientRect) === null || _this$_context$engine3 === void 0 ? void 0 : _this$_context$engine3.call(_this$_context$engine);
|
|
20947
|
+
const canvasWidth = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.width;
|
|
20948
|
+
const canvasHeight = canvasRect === null || canvasRect === void 0 ? void 0 : canvasRect.height;
|
|
20949
|
+
const fallbackWidth = (_width = (_this$_context$mainCo2 = this._context.mainComponent) === null || _this$_context$mainCo2 === void 0 ? void 0 : _this$_context$mainCo2.width) !== null && _width !== void 0 ? _width : this._context.scene.width;
|
|
20950
|
+
const visibleWidth = ((_ref = canvasWidth !== null && canvasWidth !== void 0 ? canvasWidth : fallbackWidth) !== null && _ref !== void 0 ? _ref : 0) / scaleX;
|
|
20951
|
+
const fallbackHeight = (_height = (_this$_context$mainCo3 = this._context.mainComponent) === null || _this$_context$mainCo3 === void 0 ? void 0 : _this$_context$mainCo3.height) !== null && _height !== void 0 ? _height : this._context.scene.height;
|
|
20952
|
+
const visibleHeight = ((_ref2 = canvasHeight !== null && canvasHeight !== void 0 ? canvasHeight : fallbackHeight) !== null && _ref2 !== void 0 ? _ref2 : 0) / scaleY;
|
|
20953
|
+
if (!visibleWidth || !Number.isFinite(visibleWidth) || visibleWidth <= 0 || !visibleHeight || !Number.isFinite(visibleHeight) || visibleHeight <= 0) return null;
|
|
20954
|
+
return {
|
|
20955
|
+
height: visibleHeight,
|
|
20956
|
+
left: viewportLeft,
|
|
20957
|
+
width: visibleWidth
|
|
20958
|
+
};
|
|
20959
|
+
}
|
|
20960
|
+
};
|
|
20961
|
+
EmbedDocsCustomBlockBleedRenderController = __decorate([
|
|
20962
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.IUniverInstanceService)),
|
|
20963
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
|
|
20964
|
+
__decorateParam(3, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedContentSizeRegistryService))
|
|
20965
|
+
], EmbedDocsCustomBlockBleedRenderController);
|
|
20966
|
+
function isPromiseLike(value) {
|
|
20967
|
+
return !!value && typeof value.then === "function";
|
|
20968
|
+
}
|
|
20969
|
+
function normalizeFallbackSize(value, fallback) {
|
|
20970
|
+
return typeof value === "number" && Number.isFinite(value) && value > 1 ? value : fallback;
|
|
20971
|
+
}
|
|
19415
20972
|
|
|
19416
20973
|
//#endregion
|
|
19417
20974
|
//#region src/controllers/render-controllers/zoom.render-controller.ts
|
|
@@ -19419,7 +20976,7 @@ function shouldHandleDocWheelZoom(event, focusingDoc, _documentFlavor) {
|
|
|
19419
20976
|
return focusingDoc && (event.ctrlKey || event.metaKey);
|
|
19420
20977
|
}
|
|
19421
20978
|
let DocZoomRenderController = class DocZoomRenderController extends _univerjs_core.Disposable {
|
|
19422
|
-
constructor(_context, _contextService, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService, _renderManagerService, _docViewScaleService) {
|
|
20979
|
+
constructor(_context, _contextService, _docSkeletonManagerService, _univerInstanceService, _commandService, _textSelectionManagerService, _editorService, _docPageLayoutService, _renderManagerService, _docViewScaleService, _embedInteractionBoundaryService) {
|
|
19423
20980
|
super();
|
|
19424
20981
|
this._context = _context;
|
|
19425
20982
|
this._contextService = _contextService;
|
|
@@ -19431,6 +20988,7 @@ let DocZoomRenderController = class DocZoomRenderController extends _univerjs_co
|
|
|
19431
20988
|
this._docPageLayoutService = _docPageLayoutService;
|
|
19432
20989
|
this._renderManagerService = _renderManagerService;
|
|
19433
20990
|
this._docViewScaleService = _docViewScaleService;
|
|
20991
|
+
this._embedInteractionBoundaryService = _embedInteractionBoundaryService;
|
|
19434
20992
|
_defineProperty(this, "_isSheetEditor", false);
|
|
19435
20993
|
_defineProperty(this, "_initTimer", void 0);
|
|
19436
20994
|
_defineProperty(this, "_updateTimer", void 0);
|
|
@@ -19480,14 +21038,21 @@ let DocZoomRenderController = class DocZoomRenderController extends _univerjs_co
|
|
|
19480
21038
|
}));
|
|
19481
21039
|
}
|
|
19482
21040
|
updateViewZoom(zoomRatio, needRefreshSelection = true) {
|
|
19483
|
-
var
|
|
21041
|
+
var _this$_embedInteracti;
|
|
19484
21042
|
const docObject = neoGetDocObject(this._context);
|
|
19485
21043
|
const viewScale = this._docViewScaleService.getViewScale(zoomRatio);
|
|
19486
21044
|
docObject.scene.scale(viewScale, viewScale);
|
|
19487
21045
|
if (!this._editorService.isEditor(this._context.unitId)) this._docPageLayoutService.calculatePagePosition();
|
|
19488
|
-
if (needRefreshSelection && !this._editorService.isEditor(this._context.unitId)) this._textSelectionManagerService.refreshSelection();
|
|
19489
|
-
if ((0, _univerjs_core.isInternalEditorID)(this._context.unitId))
|
|
19490
|
-
|
|
21046
|
+
if (needRefreshSelection && !this._editorService.isEditor(this._context.unitId) && !((_this$_embedInteracti = this._embedInteractionBoundaryService) === null || _this$_embedInteracti === void 0 ? void 0 : _this$_embedInteracti.hasRecentInteraction())) this._textSelectionManagerService.refreshSelection();
|
|
21047
|
+
if (!(0, _univerjs_core.isInternalEditorID)(this._context.unitId)) {
|
|
21048
|
+
var _docObject$scene$getT;
|
|
21049
|
+
(_docObject$scene$getT = docObject.scene.getTransformer()) === null || _docObject$scene$getT === void 0 || _docObject$scene$getT.clearSelectedObjects();
|
|
21050
|
+
}
|
|
21051
|
+
const createOptions = this._univerInstanceService.getUnitCreateOptions(this._context.unitId);
|
|
21052
|
+
if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.embeddedRender) === true || (createOptions === null || createOptions === void 0 ? void 0 : createOptions.skipAutoRender) === true) {
|
|
21053
|
+
this._context.scene.makeDirty();
|
|
21054
|
+
this._context.scene.render();
|
|
21055
|
+
}
|
|
19491
21056
|
}
|
|
19492
21057
|
_initZoomEventListener() {
|
|
19493
21058
|
const scene = this._context.scene;
|
|
@@ -19514,7 +21079,8 @@ DocZoomRenderController = __decorate([
|
|
|
19514
21079
|
__decorateParam(6, IEditorService),
|
|
19515
21080
|
__decorateParam(7, (0, _univerjs_core.Inject)(DocPageLayoutService)),
|
|
19516
21081
|
__decorateParam(8, _univerjs_engine_render.IRenderManagerService),
|
|
19517
|
-
__decorateParam(9, (0, _univerjs_core.Inject)(DocViewScaleService))
|
|
21082
|
+
__decorateParam(9, (0, _univerjs_core.Inject)(DocViewScaleService)),
|
|
21083
|
+
__decorateParam(10, (0, _univerjs_core.Optional)(_univerjs_embed_ui.EmbedInteractionBoundaryService))
|
|
19518
21084
|
], DocZoomRenderController);
|
|
19519
21085
|
|
|
19520
21086
|
//#endregion
|
|
@@ -19597,11 +21163,15 @@ let DocsRenderService = class DocsRenderService extends _univerjs_core.RxDisposa
|
|
|
19597
21163
|
}
|
|
19598
21164
|
_init() {
|
|
19599
21165
|
this._renderManagerService.createRender$.pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((unitId) => this._createRenderWithId(unitId));
|
|
19600
|
-
this._instanceSrv.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_DOC).forEach((documentModel) =>
|
|
19601
|
-
|
|
21166
|
+
this._instanceSrv.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_DOC).forEach((documentModel) => {
|
|
21167
|
+
var _this$_instanceSrv$ge;
|
|
21168
|
+
return this._createRenderer(documentModel, (_this$_instanceSrv$ge = this._instanceSrv.getUnitCreateOptions(documentModel.getUnitId())) !== null && _this$_instanceSrv$ge !== void 0 ? _this$_instanceSrv$ge : void 0);
|
|
21169
|
+
});
|
|
21170
|
+
this._instanceSrv.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((event) => this._createRenderer(event.unit, event.options));
|
|
19602
21171
|
this._instanceSrv.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((doc) => this._disposeRenderer(doc));
|
|
19603
21172
|
}
|
|
19604
|
-
_createRenderer(doc) {
|
|
21173
|
+
_createRenderer(doc, createUnitOptions) {
|
|
21174
|
+
if (createUnitOptions === null || createUnitOptions === void 0 ? void 0 : createUnitOptions.skipAutoRender) return;
|
|
19605
21175
|
const unitId = doc.getUnitId();
|
|
19606
21176
|
this._renderManagerService.created$.subscribe((renderer) => {
|
|
19607
21177
|
if (renderer.unitId === unitId) {
|
|
@@ -19785,6 +21355,9 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
19785
21355
|
this._initializeShortcut();
|
|
19786
21356
|
this._initCommand();
|
|
19787
21357
|
}
|
|
21358
|
+
onStarting() {
|
|
21359
|
+
registerDocsEmbedUIContributions(this._injector);
|
|
21360
|
+
}
|
|
19788
21361
|
onReady() {
|
|
19789
21362
|
this._initRenderBasics();
|
|
19790
21363
|
this._markDocAsFocused();
|
|
@@ -19968,6 +21541,8 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
19968
21541
|
const doc = currentService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
19969
21542
|
if (!doc) return;
|
|
19970
21543
|
const id = doc.getUnitId();
|
|
21544
|
+
const createOptions = currentService.getUnitCreateOptions(id);
|
|
21545
|
+
if ((createOptions === null || createOptions === void 0 ? void 0 : createOptions.makeCurrent) === false) return;
|
|
19971
21546
|
if (!editorService.isEditor(id)) currentService.focusUnit(doc.getUnitId());
|
|
19972
21547
|
} catch (err) {
|
|
19973
21548
|
this._logService.warn(err);
|
|
@@ -20002,7 +21577,8 @@ let UniverDocsUIPlugin = class UniverDocsUIPlugin extends _univerjs_core.Plugin
|
|
|
20002
21577
|
[DocClipboardController],
|
|
20003
21578
|
[DocInputController],
|
|
20004
21579
|
[DocIMEInputController],
|
|
20005
|
-
[DocEditorBridgeController]
|
|
21580
|
+
[DocEditorBridgeController],
|
|
21581
|
+
[EmbedDocsCustomBlockBleedRenderController]
|
|
20006
21582
|
].forEach((m) => {
|
|
20007
21583
|
this._renderManagerSrv.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_DOC, m);
|
|
20008
21584
|
});
|
|
@@ -20697,6 +22273,7 @@ Object.defineProperty(exports, 'DocsRenderService', {
|
|
|
20697
22273
|
}
|
|
20698
22274
|
});
|
|
20699
22275
|
exports.DocsUIMenuSchema = menuSchema;
|
|
22276
|
+
exports.EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY = EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY;
|
|
20700
22277
|
exports.EMPTY_PARAGRAPH_MENU_ID = EMPTY_PARAGRAPH_MENU_ID;
|
|
20701
22278
|
exports.Editor = Editor;
|
|
20702
22279
|
Object.defineProperty(exports, 'EditorService', {
|
|
@@ -20778,7 +22355,17 @@ exports.calcDocFitToWidthScale = calcDocFitToWidthScale;
|
|
|
20778
22355
|
exports.calcDocRangePositions = calcDocRangePositions;
|
|
20779
22356
|
exports.convertBodyToHtml = convertBodyToHtml;
|
|
20780
22357
|
exports.convertPositionsToRectRanges = convertPositionsToRectRanges;
|
|
22358
|
+
exports.createDocsCustomBlockHostAdapterContribution = createDocsCustomBlockHostAdapterContribution;
|
|
22359
|
+
exports.createDocsCustomBlockHostContainerContribution = createDocsCustomBlockHostContainerContribution;
|
|
22360
|
+
exports.createDocsCustomBlockInsertMutation = createDocsCustomBlockInsertMutation;
|
|
22361
|
+
exports.createDocsCustomBlockRemoveMutation = createDocsCustomBlockRemoveMutation;
|
|
22362
|
+
exports.createDocsEmbedBlockContribution = createDocsEmbedBlockContribution;
|
|
22363
|
+
exports.createDocsEmbedChildViewContribution = createDocsEmbedChildViewContribution;
|
|
22364
|
+
exports.createDocsFloatingMenuContributions = createDocsFloatingMenuContributions;
|
|
20781
22365
|
exports.createEditorUndoRedoKeyboardConfig = createEditorUndoRedoKeyboardConfig;
|
|
22366
|
+
exports.createEmbedDocsCustomBlockData = createEmbedDocsCustomBlockData;
|
|
22367
|
+
exports.createInsertCustomBlockActions = createInsertCustomBlockActions;
|
|
22368
|
+
exports.createRemoveCustomBlockActions = createRemoveCustomBlockActions;
|
|
20782
22369
|
exports.deleteCustomDecorationFactory = deleteCustomDecorationFactory;
|
|
20783
22370
|
exports.docDrawingPositionToTransform = docDrawingPositionToTransform;
|
|
20784
22371
|
exports.executeEditorUndoRedoCommand = executeEditorUndoRedoCommand;
|
|
@@ -20804,12 +22391,17 @@ exports.getTableColumn = getTableColumn;
|
|
|
20804
22391
|
exports.hasParagraphInTable = hasParagraphInTable;
|
|
20805
22392
|
exports.hideMenuWhenSelectionInBlockRange = hideMenuWhenSelectionInBlockRange;
|
|
20806
22393
|
exports.isInSameTableCell = isInSameTableCell;
|
|
22394
|
+
exports.isSheetLikeDocsCustomBlockChildType = isSheetLikeDocsCustomBlockChildType;
|
|
20807
22395
|
exports.isTextRangeInAnyBlockRange = isTextRangeInAnyBlockRange;
|
|
20808
22396
|
exports.isValidRectRange = isValidRectRange;
|
|
20809
22397
|
exports.neoGetDocObject = neoGetDocObject;
|
|
20810
22398
|
exports.normalizeDocFitToWidthOptions = normalizeDocFitToWidthOptions;
|
|
22399
|
+
exports.registerDocsEmbedProductMenus = registerDocsEmbedProductMenus;
|
|
22400
|
+
exports.registerDocsEmbedUIContributions = registerDocsEmbedUIContributions;
|
|
20811
22401
|
exports.resolveDocFitBaseWidth = resolveDocFitBaseWidth;
|
|
20812
22402
|
exports.resolveDocViewScale = resolveDocViewScale;
|
|
22403
|
+
exports.resolveDocsCustomBlockRenderViewport = resolveDocsCustomBlockRenderViewport;
|
|
22404
|
+
exports.resolveDocsFloatingMenuStage = resolveDocsFloatingMenuStage;
|
|
20813
22405
|
exports.transformToDocDrawingPosition = transformToDocDrawingPosition;
|
|
20814
22406
|
exports.useEditor = useEditor;
|
|
20815
22407
|
exports.useEditorClickOutside = useEditorClickOutside;
|