@univerjs/docs-drawing-ui 0.4.0 → 0.4.1-experimental.20241022-507567a

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/es/index.js CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { CommandType, ICommandService, IUniverInstanceService, TextX, JSONX, MemoryCursor, TextXActionType, IUndoRedoService, BuildTextUtils, Tools, Inject, LocaleService, Disposable, BooleanNumber, PositionedObjectLayoutType, WrapTextType, ObjectRelativeFromH, ObjectRelativeFromV, FOCUSING_COMMON_DRAWINGS, IContextService, UniverInstanceType, Direction, useDependency, FOCUSING_UNIVER_EDITOR, UndoCommand, RedoCommand, toDisposable, throttle, COLORS, RxDisposable, LifecycleService, fromEventSubject, LifecycleStages, DependentOn, Injector, Plugin, IConfigService } from "@univerjs/core";
5
+ import { CommandType, ICommandService, IUniverInstanceService, TextX, JSONX, MemoryCursor, TextXActionType, IUndoRedoService, BuildTextUtils, Tools, Inject, LocaleService, Disposable, BooleanNumber, PositionedObjectLayoutType, WrapTextType, ObjectRelativeFromH, ObjectRelativeFromV, FOCUSING_COMMON_DRAWINGS, IContextService, UniverInstanceType, Direction, useDependency, DocumentFlavor, FOCUSING_UNIVER_EDITOR, UndoCommand, RedoCommand, toDisposable, throttle, COLORS, RxDisposable, LifecycleService, fromEventSubject, LifecycleStages, DependentOn, Injector, Plugin, IConfigService } from "@univerjs/core";
6
6
  import { IDocDrawingService, UniverDocsDrawingPlugin } from "@univerjs/docs-drawing";
7
7
  import { ArrangeTypeEnum, DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DrawingTypeEnum, getDrawingShapeKeyByDrawingSearch, IImageIoService, IDrawingManagerService, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, UniverDrawingPlugin } from "@univerjs/drawing";
8
8
  import { DrawingCommonPanel, ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
@@ -10,7 +10,7 @@ import { IRenderManagerService, DocumentEditArea, Liquid, PageLayoutType, Docume
10
10
  import { IMessageService, ILocalFileService, ISidebarService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, KeyCode, ComponentManager, IMenuManagerService, IShortcutService, UniverUIPlugin } from "@univerjs/ui";
11
11
  import { RichTextEditingMutation, DocSelectionManagerService, DocSkeletonManagerService } from "@univerjs/docs";
12
12
  import { DocSelectionRenderService, getRichTextEditPath, getCustomBlockIdsInSelections, docDrawingPositionToTransform, NodePositionConvertToCursor, getOneTextSelectionRange, getAnchorBounding, TEXT_RANGE_LAYER_INDEX, getDocObject, DocCanvasPopManagerService, IEditorService, SetDocZoomRatioOperation } from "@univerjs/docs-ui";
13
- import { MessageType, RadioGroup, Radio, InputNumber, Select, Checkbox } from "@univerjs/design";
13
+ import { MessageType, InputNumber, Select, Checkbox, RadioGroup, Radio } from "@univerjs/design";
14
14
  import { BehaviorSubject, Observable, takeUntil, filter, debounceTime } from "rxjs";
15
15
  import React, { forwardRef, useRef, createElement, useState, useEffect } from "react";
16
16
  const PLUGIN_CONFIG_KEY = "docs-drawing-ui.config", defaultPluginConfig = {};
@@ -371,8 +371,8 @@ let DocDrawingUpdateRenderController = (_a = class extends Disposable {
371
371
  posOffset: position.left
372
372
  },
373
373
  positionV: {
374
- relativeFrom: ObjectRelativeFromV.MARGIN,
375
- posOffset: position.top
374
+ relativeFrom: ObjectRelativeFromV.PARAGRAPH,
375
+ posOffset: 0
376
376
  },
377
377
  angle: 0
378
378
  };
@@ -939,22 +939,6 @@ const UpdateDocDrawingWrappingStyleCommand = {
939
939
  const drawingManagerService = accessor.get(IDrawingManagerService), commandService = accessor.get(ICommandService);
940
940
  return params == null ? !1 : (drawingManagerService.focusDrawing([params]), commandService.executeCommand(SidebarDocDrawingOperation.id, { value: "open" }), !0);
941
941
  }, "handler")
942
- }, imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", sheetImageMenu = "univer-sheet-image-menu", sheetImageMenuInput = "univer-sheet-image-menu-input", styles = {
943
- imageCommonPanel,
944
- imageCommonPanelGrid,
945
- imageCommonPanelBorder,
946
- imageCommonPanelTitle,
947
- imageCommonPanelSubtitle,
948
- imageCommonPanelRow,
949
- imageCommonPanelRowVertical,
950
- imageCommonPanelColumn,
951
- imageCommonPanelColumnCenter,
952
- imageCommonPanelInline,
953
- imageCommonPanelSpan2,
954
- imageCommonPanelSpan3,
955
- imageCommonPanelInput,
956
- sheetImageMenu,
957
- sheetImageMenuInput
958
942
  };
959
943
  function r(e) {
960
944
  var t, f, n = "";
@@ -971,191 +955,27 @@ function clsx() {
971
955
  return n;
972
956
  }
973
957
  __name(clsx, "clsx");
974
- const MIN_MARGIN = 0, MAX_MARGIN = 100, DocDrawingTextWrap = /* @__PURE__ */ __name((props) => {
975
- const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), { drawings } = props, drawingParam = drawings[0];
976
- if (drawingParam == null)
977
- return null;
978
- const { unitId } = drawingParam, documentDataModel = univerInstanceService.getUniverDocInstance(unitId), renderObject = renderManagerService.getRenderById(unitId);
979
- if ((renderObject == null ? void 0 : renderObject.scene) == null)
980
- return null;
981
- const [disableWrapText, setDisableWrapText] = useState(!0), [disableDistTB, setDisableDistTB] = useState(!0), [disableDistLR, setDisableDistLR] = useState(!0), [wrappingStyle, setWrappingStyle] = useState(TextWrappingStyle.INLINE), [wrapText, setWrapText] = useState(""), [distToText, setDistToText] = useState({
982
- distT: 0,
983
- distL: 0,
984
- distB: 0,
985
- distR: 0
986
- }), [showPanel, setShowPanel] = useState(!0);
987
- function handleWrappingStyleChange(value) {
988
- setWrappingStyle(value);
989
- const focusDrawings = drawingManagerService.getFocusDrawings();
990
- if (focusDrawings.length === 0)
991
- return;
992
- const { unitId: unitId2, subUnitId } = focusDrawings[0], drawings2 = focusDrawings.map(({ unitId: unitId3, subUnitId: subUnitId2, drawingId }) => ({
993
- unitId: unitId3,
994
- subUnitId: subUnitId2,
995
- drawingId
996
- }));
997
- commandService.executeCommand(UpdateDocDrawingWrappingStyleCommand.id, {
998
- unitId: unitId2,
999
- subUnitId,
1000
- drawings: drawings2,
1001
- wrappingStyle: value
1002
- });
1003
- }
1004
- __name(handleWrappingStyleChange, "handleWrappingStyleChange");
1005
- function handleWrapTextChange(value) {
1006
- setWrapText(value);
1007
- const focusDrawings = drawingManagerService.getFocusDrawings();
1008
- if (focusDrawings.length === 0)
1009
- return;
1010
- const drawings2 = focusDrawings.map((drawing) => ({
1011
- unitId: drawing.unitId,
1012
- subUnitId: drawing.subUnitId,
1013
- drawingId: drawing.drawingId
1014
- }));
1015
- commandService.executeCommand(UpdateDocDrawingWrapTextCommand.id, {
1016
- unitId: focusDrawings[0].unitId,
1017
- subUnitId: focusDrawings[0].unitId,
1018
- drawings: drawings2,
1019
- wrapText: value
1020
- });
1021
- }
1022
- __name(handleWrapTextChange, "handleWrapTextChange");
1023
- function handleDistToTextChange(value, direction) {
1024
- if (value == null)
1025
- return;
1026
- const newDistToText = { ...distToText, [direction]: value };
1027
- setDistToText(newDistToText);
1028
- const focusDrawings = drawingManagerService.getFocusDrawings();
1029
- if (focusDrawings.length === 0)
1030
- return;
1031
- const drawings2 = focusDrawings.map((drawing) => ({
1032
- unitId: drawing.unitId,
1033
- subUnitId: drawing.subUnitId,
1034
- drawingId: drawing.drawingId
1035
- }));
1036
- commandService.executeCommand(UpdateDocDrawingDistanceCommand.id, {
1037
- unitId: focusDrawings[0].unitId,
1038
- subUnitId: focusDrawings[0].unitId,
1039
- drawings: drawings2,
1040
- dist: {
1041
- [direction]: value
1042
- }
1043
- });
1044
- }
1045
- __name(handleDistToTextChange, "handleDistToTextChange");
1046
- function updateFocusDrawingState() {
1047
- const focusDrawings = drawingManagerService.getFocusDrawings();
1048
- focusDrawings.length !== 0 && updateState(focusDrawings[0]);
1049
- }
1050
- __name(updateFocusDrawingState, "updateFocusDrawingState");
1051
- function updateState(drawingParam2) {
1052
- var _a8, _b;
1053
- const drawing = (_b = (_a8 = documentDataModel == null ? void 0 : documentDataModel.getSnapshot()) == null ? void 0 : _a8.drawings) == null ? void 0 : _b[drawingParam2.drawingId];
1054
- if (drawing == null)
1055
- return;
1056
- const {
1057
- distT = 0,
1058
- distL = 0,
1059
- distB = 0,
1060
- distR = 0,
1061
- layoutType = PositionedObjectLayoutType.INLINE,
1062
- behindDoc = BooleanNumber.FALSE,
1063
- wrapText: wrapText2 = WrapTextType.BOTH_SIDES
1064
- } = drawing;
1065
- if (setDistToText({
1066
- distT,
1067
- distL,
1068
- distB,
1069
- distR
1070
- }), setWrapText(wrapText2), setDisableWrapText(layoutType !== PositionedObjectLayoutType.WRAP_SQUARE), layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.INLINE ? setDisableDistTB(!0) : setDisableDistTB(!1), layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.INLINE || layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM ? setDisableDistLR(!0) : setDisableDistLR(!1), layoutType === PositionedObjectLayoutType.WRAP_NONE)
1071
- behindDoc === BooleanNumber.TRUE ? setWrappingStyle(TextWrappingStyle.BEHIND_TEXT) : setWrappingStyle(TextWrappingStyle.IN_FRONT_OF_TEXT);
1072
- else
1073
- switch (layoutType) {
1074
- case PositionedObjectLayoutType.INLINE:
1075
- setWrappingStyle(TextWrappingStyle.INLINE);
1076
- break;
1077
- case PositionedObjectLayoutType.WRAP_SQUARE:
1078
- setWrappingStyle(TextWrappingStyle.WRAP_SQUARE);
1079
- break;
1080
- case PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM:
1081
- setWrappingStyle(TextWrappingStyle.WRAP_TOP_AND_BOTTOM);
1082
- break;
1083
- default:
1084
- throw new Error(`Unsupported layout type: ${layoutType}`);
1085
- }
1086
- }
1087
- return __name(updateState, "updateState"), useEffect(() => {
1088
- updateFocusDrawingState();
1089
- const subscription = drawingManagerService.focus$.subscribe((drawingParams) => {
1090
- if (drawingParams.length === 0) {
1091
- setShowPanel(!1);
1092
- return;
1093
- }
1094
- setShowPanel(!0), updateState(drawingParams[0]);
1095
- }), mutationListener = commandService.onCommandExecuted(async (command) => {
1096
- command.id === RichTextEditingMutation.id && updateFocusDrawingState();
1097
- });
1098
- return () => {
1099
- subscription.unsubscribe(), mutationListener.dispose();
1100
- };
1101
- }, []), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: showPanel ? "block" : "none" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.title")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.wrappingStyle")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { value: wrappingStyle, onChange: handleWrappingStyleChange, direction: "vertical" }, /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.INLINE }, localeService.t("image-text-wrap.inline")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.WRAP_SQUARE }, localeService.t("image-text-wrap.square")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.WRAP_TOP_AND_BOTTOM }, localeService.t("image-text-wrap.topAndBottom")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.BEHIND_TEXT }, localeService.t("image-text-wrap.behindText")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.IN_FRONT_OF_TEXT }, localeService.t("image-text-wrap.inFrontText"))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.wrapText")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { disabled: disableWrapText, value: wrapText, onChange: handleWrapTextChange, direction: "horizontal" }, /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.BOTH_SIDES }, localeService.t("image-text-wrap.bothSide")), /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.LEFT }, localeService.t("image-text-wrap.leftOnly")), /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.RIGHT }, localeService.t("image-text-wrap.rightOnly"))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.distanceFromText")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.top"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1102
- InputNumber,
1103
- {
1104
- min: MIN_MARGIN,
1105
- max: MAX_MARGIN,
1106
- disabled: disableDistTB,
1107
- precision: 1,
1108
- value: distToText.distT,
1109
- onChange: /* @__PURE__ */ __name((val) => {
1110
- handleDistToTextChange(val, "distT");
1111
- }, "onChange"),
1112
- className: styles.imageCommonPanelInput
1113
- }
1114
- ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.left"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1115
- InputNumber,
1116
- {
1117
- min: MIN_MARGIN,
1118
- max: MAX_MARGIN,
1119
- disabled: disableDistLR,
1120
- precision: 1,
1121
- value: distToText.distL,
1122
- onChange: /* @__PURE__ */ __name((val) => {
1123
- handleDistToTextChange(val, "distL");
1124
- }, "onChange"),
1125
- className: styles.imageCommonPanelInput
1126
- }
1127
- )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.bottom"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1128
- InputNumber,
1129
- {
1130
- min: MIN_MARGIN,
1131
- max: MAX_MARGIN,
1132
- disabled: disableDistTB,
1133
- precision: 1,
1134
- value: distToText.distB,
1135
- onChange: /* @__PURE__ */ __name((val) => {
1136
- handleDistToTextChange(val, "distB");
1137
- }, "onChange"),
1138
- className: styles.imageCommonPanelInput
1139
- }
1140
- ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.right"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1141
- InputNumber,
1142
- {
1143
- min: MIN_MARGIN,
1144
- max: MAX_MARGIN,
1145
- disabled: disableDistLR,
1146
- precision: 1,
1147
- value: distToText.distR,
1148
- onChange: /* @__PURE__ */ __name((val) => {
1149
- handleDistToTextChange(val, "distR");
1150
- }, "onChange"),
1151
- className: styles.imageCommonPanelInput
1152
- }
1153
- )))))));
1154
- }, "DocDrawingTextWrap"), MIN_OFFSET = -1e3, MAX_OFFSET = 1e3, DocDrawingPosition = /* @__PURE__ */ __name((props) => {
958
+ const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", sheetImageMenu = "univer-sheet-image-menu", sheetImageMenuInput = "univer-sheet-image-menu-input", styles = {
959
+ imageCommonPanel,
960
+ imageCommonPanelGrid,
961
+ imageCommonPanelBorder,
962
+ imageCommonPanelTitle,
963
+ imageCommonPanelSubtitle,
964
+ imageCommonPanelRow,
965
+ imageCommonPanelRowVertical,
966
+ imageCommonPanelColumn,
967
+ imageCommonPanelColumnCenter,
968
+ imageCommonPanelInline,
969
+ imageCommonPanelSpan2,
970
+ imageCommonPanelSpan3,
971
+ imageCommonPanelInput,
972
+ sheetImageMenu,
973
+ sheetImageMenuInput
974
+ }, MIN_OFFSET = -1e3, MAX_OFFSET = 1e3, DocDrawingPosition = /* @__PURE__ */ __name((props) => {
1155
975
  const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), { drawings } = props, drawingParam = drawings[0];
1156
976
  if (drawingParam == null)
1157
977
  return;
1158
- const { unitId } = drawingParam, documentDataModel = univerInstanceService.getUniverDocInstance(unitId), renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
978
+ const { unitId } = drawingParam, documentDataModel = univerInstanceService.getUniverDocInstance(unitId), documentFlavor = documentDataModel == null ? void 0 : documentDataModel.getSnapshot().documentStyle.documentFlavor, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1159
979
  if (scene == null)
1160
980
  return;
1161
981
  const transformer = scene.getTransformerByCreate(), HORIZONTAL_RELATIVE_FROM = [{
@@ -1169,13 +989,16 @@ const MIN_MARGIN = 0, MAX_MARGIN = 100, DocDrawingTextWrap = /* @__PURE__ */ __n
1169
989
  value: String(ObjectRelativeFromH.MARGIN)
1170
990
  }], VERTICAL_RELATIVE_FROM = [{
1171
991
  label: localeService.t("image-position.line"),
1172
- value: String(ObjectRelativeFromV.LINE)
992
+ value: String(ObjectRelativeFromV.LINE),
993
+ disabled: documentFlavor === DocumentFlavor.MODERN
1173
994
  }, {
1174
995
  label: localeService.t("image-position.page"),
1175
- value: String(ObjectRelativeFromV.PAGE)
996
+ value: String(ObjectRelativeFromV.PAGE),
997
+ disabled: documentFlavor === DocumentFlavor.MODERN
1176
998
  }, {
1177
999
  label: localeService.t("image-position.margin"),
1178
- value: String(ObjectRelativeFromV.MARGIN)
1000
+ value: String(ObjectRelativeFromV.MARGIN),
1001
+ disabled: documentFlavor === DocumentFlavor.MODERN
1179
1002
  }, {
1180
1003
  label: localeService.t("image-position.paragraph"),
1181
1004
  value: String(ObjectRelativeFromV.PARAGRAPH)
@@ -1358,7 +1181,187 @@ const MIN_MARGIN = 0, MAX_MARGIN = 100, DocDrawingTextWrap = /* @__PURE__ */ __n
1358
1181
  onChange: handleVerticalRelativeFromChange
1359
1182
  }
1360
1183
  )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-position.options")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow, style: { marginBottom: "50px" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(Checkbox, { disabled, checked: followTextMove, onChange: handleFollowTextMoveCheck }, localeService.t("image-position.moveObjectWithText")))));
1361
- }, "DocDrawingPosition"), DocDrawingPanel = /* @__PURE__ */ __name(() => {
1184
+ }, "DocDrawingPosition"), MIN_MARGIN = 0, MAX_MARGIN = 100, DocDrawingTextWrap = /* @__PURE__ */ __name((props) => {
1185
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), univerInstanceService = useDependency(IUniverInstanceService), { drawings } = props, drawingParam = drawings[0];
1186
+ if (drawingParam == null)
1187
+ return null;
1188
+ const { unitId } = drawingParam, documentDataModel = univerInstanceService.getUniverDocInstance(unitId), renderObject = renderManagerService.getRenderById(unitId);
1189
+ if ((renderObject == null ? void 0 : renderObject.scene) == null)
1190
+ return null;
1191
+ const [disableWrapText, setDisableWrapText] = useState(!0), [disableDistTB, setDisableDistTB] = useState(!0), [disableDistLR, setDisableDistLR] = useState(!0), [wrappingStyle, setWrappingStyle] = useState(TextWrappingStyle.INLINE), [wrapText, setWrapText] = useState(""), [distToText, setDistToText] = useState({
1192
+ distT: 0,
1193
+ distL: 0,
1194
+ distB: 0,
1195
+ distR: 0
1196
+ }), [showPanel, setShowPanel] = useState(!0);
1197
+ function handleWrappingStyleChange(value) {
1198
+ setWrappingStyle(value);
1199
+ const focusDrawings = drawingManagerService.getFocusDrawings();
1200
+ if (focusDrawings.length === 0)
1201
+ return;
1202
+ const { unitId: unitId2, subUnitId } = focusDrawings[0], drawings2 = focusDrawings.map(({ unitId: unitId3, subUnitId: subUnitId2, drawingId }) => ({
1203
+ unitId: unitId3,
1204
+ subUnitId: subUnitId2,
1205
+ drawingId
1206
+ }));
1207
+ commandService.executeCommand(UpdateDocDrawingWrappingStyleCommand.id, {
1208
+ unitId: unitId2,
1209
+ subUnitId,
1210
+ drawings: drawings2,
1211
+ wrappingStyle: value
1212
+ });
1213
+ }
1214
+ __name(handleWrappingStyleChange, "handleWrappingStyleChange");
1215
+ function handleWrapTextChange(value) {
1216
+ setWrapText(value);
1217
+ const focusDrawings = drawingManagerService.getFocusDrawings();
1218
+ if (focusDrawings.length === 0)
1219
+ return;
1220
+ const drawings2 = focusDrawings.map((drawing) => ({
1221
+ unitId: drawing.unitId,
1222
+ subUnitId: drawing.subUnitId,
1223
+ drawingId: drawing.drawingId
1224
+ }));
1225
+ commandService.executeCommand(UpdateDocDrawingWrapTextCommand.id, {
1226
+ unitId: focusDrawings[0].unitId,
1227
+ subUnitId: focusDrawings[0].unitId,
1228
+ drawings: drawings2,
1229
+ wrapText: value
1230
+ });
1231
+ }
1232
+ __name(handleWrapTextChange, "handleWrapTextChange");
1233
+ function handleDistToTextChange(value, direction) {
1234
+ if (value == null)
1235
+ return;
1236
+ const newDistToText = { ...distToText, [direction]: value };
1237
+ setDistToText(newDistToText);
1238
+ const focusDrawings = drawingManagerService.getFocusDrawings();
1239
+ if (focusDrawings.length === 0)
1240
+ return;
1241
+ const drawings2 = focusDrawings.map((drawing) => ({
1242
+ unitId: drawing.unitId,
1243
+ subUnitId: drawing.subUnitId,
1244
+ drawingId: drawing.drawingId
1245
+ }));
1246
+ commandService.executeCommand(UpdateDocDrawingDistanceCommand.id, {
1247
+ unitId: focusDrawings[0].unitId,
1248
+ subUnitId: focusDrawings[0].unitId,
1249
+ drawings: drawings2,
1250
+ dist: {
1251
+ [direction]: value
1252
+ }
1253
+ });
1254
+ }
1255
+ __name(handleDistToTextChange, "handleDistToTextChange");
1256
+ function updateFocusDrawingState() {
1257
+ const focusDrawings = drawingManagerService.getFocusDrawings();
1258
+ focusDrawings.length !== 0 && updateState(focusDrawings[0]);
1259
+ }
1260
+ __name(updateFocusDrawingState, "updateFocusDrawingState");
1261
+ function updateState(drawingParam2) {
1262
+ var _a8, _b;
1263
+ const drawing = (_b = (_a8 = documentDataModel == null ? void 0 : documentDataModel.getSnapshot()) == null ? void 0 : _a8.drawings) == null ? void 0 : _b[drawingParam2.drawingId];
1264
+ if (drawing == null)
1265
+ return;
1266
+ const {
1267
+ distT = 0,
1268
+ distL = 0,
1269
+ distB = 0,
1270
+ distR = 0,
1271
+ layoutType = PositionedObjectLayoutType.INLINE,
1272
+ behindDoc = BooleanNumber.FALSE,
1273
+ wrapText: wrapText2 = WrapTextType.BOTH_SIDES
1274
+ } = drawing;
1275
+ if (setDistToText({
1276
+ distT,
1277
+ distL,
1278
+ distB,
1279
+ distR
1280
+ }), setWrapText(wrapText2), setDisableWrapText(layoutType !== PositionedObjectLayoutType.WRAP_SQUARE), layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.INLINE ? setDisableDistTB(!0) : setDisableDistTB(!1), layoutType === PositionedObjectLayoutType.WRAP_NONE || layoutType === PositionedObjectLayoutType.INLINE || layoutType === PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM ? setDisableDistLR(!0) : setDisableDistLR(!1), layoutType === PositionedObjectLayoutType.WRAP_NONE)
1281
+ behindDoc === BooleanNumber.TRUE ? setWrappingStyle(TextWrappingStyle.BEHIND_TEXT) : setWrappingStyle(TextWrappingStyle.IN_FRONT_OF_TEXT);
1282
+ else
1283
+ switch (layoutType) {
1284
+ case PositionedObjectLayoutType.INLINE:
1285
+ setWrappingStyle(TextWrappingStyle.INLINE);
1286
+ break;
1287
+ case PositionedObjectLayoutType.WRAP_SQUARE:
1288
+ setWrappingStyle(TextWrappingStyle.WRAP_SQUARE);
1289
+ break;
1290
+ case PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM:
1291
+ setWrappingStyle(TextWrappingStyle.WRAP_TOP_AND_BOTTOM);
1292
+ break;
1293
+ default:
1294
+ throw new Error(`Unsupported layout type: ${layoutType}`);
1295
+ }
1296
+ }
1297
+ return __name(updateState, "updateState"), useEffect(() => {
1298
+ updateFocusDrawingState();
1299
+ const subscription = drawingManagerService.focus$.subscribe((drawingParams) => {
1300
+ if (drawingParams.length === 0) {
1301
+ setShowPanel(!1);
1302
+ return;
1303
+ }
1304
+ setShowPanel(!0), updateState(drawingParams[0]);
1305
+ }), mutationListener = commandService.onCommandExecuted(async (command) => {
1306
+ command.id === RichTextEditingMutation.id && updateFocusDrawingState();
1307
+ });
1308
+ return () => {
1309
+ subscription.unsubscribe(), mutationListener.dispose();
1310
+ };
1311
+ }, []), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: showPanel ? "block" : "none" } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.title")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.wrappingStyle")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { value: wrappingStyle, onChange: handleWrappingStyleChange, direction: "vertical" }, /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.INLINE }, localeService.t("image-text-wrap.inline")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.WRAP_SQUARE }, localeService.t("image-text-wrap.square")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.WRAP_TOP_AND_BOTTOM }, localeService.t("image-text-wrap.topAndBottom")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.BEHIND_TEXT }, localeService.t("image-text-wrap.behindText")), /* @__PURE__ */ React.createElement(Radio, { value: TextWrappingStyle.IN_FRONT_OF_TEXT }, localeService.t("image-text-wrap.inFrontText"))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.wrapText")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { disabled: disableWrapText, value: wrapText, onChange: handleWrapTextChange, direction: "horizontal" }, /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.BOTH_SIDES }, localeService.t("image-text-wrap.bothSide")), /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.LEFT }, localeService.t("image-text-wrap.leftOnly")), /* @__PURE__ */ React.createElement(Radio, { value: WrapTextType.RIGHT }, localeService.t("image-text-wrap.rightOnly"))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSubtitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-text-wrap.distanceFromText")))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.top"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1312
+ InputNumber,
1313
+ {
1314
+ min: MIN_MARGIN,
1315
+ max: MAX_MARGIN,
1316
+ disabled: disableDistTB,
1317
+ precision: 1,
1318
+ value: distToText.distT,
1319
+ onChange: /* @__PURE__ */ __name((val) => {
1320
+ handleDistToTextChange(val, "distT");
1321
+ }, "onChange"),
1322
+ className: styles.imageCommonPanelInput
1323
+ }
1324
+ ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.left"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1325
+ InputNumber,
1326
+ {
1327
+ min: MIN_MARGIN,
1328
+ max: MAX_MARGIN,
1329
+ disabled: disableDistLR,
1330
+ precision: 1,
1331
+ value: distToText.distL,
1332
+ onChange: /* @__PURE__ */ __name((val) => {
1333
+ handleDistToTextChange(val, "distL");
1334
+ }, "onChange"),
1335
+ className: styles.imageCommonPanelInput
1336
+ }
1337
+ )))))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.bottom"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1338
+ InputNumber,
1339
+ {
1340
+ min: MIN_MARGIN,
1341
+ max: MAX_MARGIN,
1342
+ disabled: disableDistTB,
1343
+ precision: 1,
1344
+ value: distToText.distB,
1345
+ onChange: /* @__PURE__ */ __name((val) => {
1346
+ handleDistToTextChange(val, "distB");
1347
+ }, "onChange"),
1348
+ className: styles.imageCommonPanelInput
1349
+ }
1350
+ ))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, localeService.t("image-text-wrap.right"))), /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(
1351
+ InputNumber,
1352
+ {
1353
+ min: MIN_MARGIN,
1354
+ max: MAX_MARGIN,
1355
+ disabled: disableDistLR,
1356
+ precision: 1,
1357
+ value: distToText.distR,
1358
+ onChange: /* @__PURE__ */ __name((val) => {
1359
+ handleDistToTextChange(val, "distR");
1360
+ }, "onChange"),
1361
+ className: styles.imageCommonPanelInput
1362
+ }
1363
+ )))))));
1364
+ }, "DocDrawingTextWrap"), DocDrawingPanel = /* @__PURE__ */ __name(() => {
1362
1365
  const drawingManagerService = useDependency(IDrawingManagerService), focusDrawings = drawingManagerService.getFocusDrawings(), [drawings, setDrawings] = useState(focusDrawings);
1363
1366
  return useEffect(() => {
1364
1367
  const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
@@ -2376,7 +2379,7 @@ let DocDrawingTransformUpdateController = (_a6 = class extends Disposable {
2376
2379
  this._calculateDrawingPosition(unitId, page, docsLeft, docsTop, updateDrawingMap, page.marginTop, page.marginLeft), this._liquid.translatePage(page, pageLayoutType, pageMarginLeft, pageMarginTop);
2377
2380
  }
2378
2381
  const updateDrawings = Object.values(updateDrawingMap), nonMultiDrawings = updateDrawings.filter((drawing) => !drawing.isMultiTransform), multiDrawings = updateDrawings.filter((drawing) => drawing.isMultiTransform);
2379
- nonMultiDrawings.length > 0 && this._drawingManagerService.refreshTransform(nonMultiDrawings), multiDrawings.length > 0 && this._handleMultiDrawingsTransform(multiDrawings);
2382
+ nonMultiDrawings.length > 0 && this._drawingManagerService.refreshTransform(nonMultiDrawings), this._handleMultiDrawingsTransform(multiDrawings);
2380
2383
  }
2381
2384
  _handleMultiDrawingsTransform(multiDrawings) {
2382
2385
  const { scene, unitId } = this._context, transformer = scene.getTransformerByCreate();
@@ -2385,7 +2388,7 @@ let DocDrawingTransformUpdateController = (_a6 = class extends Disposable {
2385
2388
  param != null && (param.transform = updateParam.transform, param.transforms = updateParam.transforms, param.isMultiTransform = updateParam.isMultiTransform);
2386
2389
  });
2387
2390
  const selectedObjectKeys = [...transformer.getSelectedObjectMap().keys()], allMultiDrawings = Object.values(this._drawingManagerService.getDrawingData(unitId, unitId)).filter((drawing) => drawing.isMultiTransform === BooleanNumber.TRUE);
2388
- this._drawingManagerService.removeNotification(allMultiDrawings), this._drawingManagerService.addNotification(multiDrawings);
2391
+ this._drawingManagerService.removeNotification(allMultiDrawings), multiDrawings.length > 0 && this._drawingManagerService.addNotification(multiDrawings);
2389
2392
  for (const key of selectedObjectKeys) {
2390
2393
  const drawingShape = scene.getObject(key);
2391
2394
  drawingShape && transformer.setSelectedControl(drawingShape);
@@ -1,8 +1,8 @@
1
- import { Disposable, ICommandService, IUniverInstanceService, LifecycleService, DocumentDataModel } from '@univerjs/core';
1
+ import { DocumentDataModel, Disposable, ICommandService, IUniverInstanceService, LifecycleService } from '@univerjs/core';
2
+ import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
2
3
  import { DocSkeletonManagerService } from '@univerjs/docs';
3
4
  import { IEditorService } from '@univerjs/docs-ui';
4
5
  import { IDrawingManagerService } from '@univerjs/drawing';
5
- import { IRenderContext, IRenderModule } from '@univerjs/engine-render';
6
6
  import { DocRefreshDrawingsService } from '../../services/doc-refresh-drawings.service';
7
7
  export declare class DocDrawingTransformUpdateController extends Disposable implements IRenderModule {
8
8
  private readonly _context;