@univerjs/docs-ui 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -237,7 +237,7 @@ function getCustomDecorationAtPosition(customDecorations, position) {
237
237
  return customDecorations.filter((customDecoration) => position > customDecoration.startIndex && position <= customDecoration.endIndex);
238
238
  }
239
239
 
240
- // \0@oxc-project+runtime@0.156.0/helpers/esm/typeof.js
240
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
241
241
  function _typeof(o) {
242
242
  "@babel/helpers - typeof";
243
243
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -247,25 +247,25 @@ function _typeof(o) {
247
247
  }, _typeof(o);
248
248
  }
249
249
 
250
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPrimitive.js
251
- function toPrimitive(t, r) {
250
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
251
+ function toPrimitive(t, e) {
252
252
  if ("object" != _typeof(t) || !t) return t;
253
- var e = t[Symbol.toPrimitive];
254
- if (void 0 !== e) {
255
- var i = e.call(t, r || "default");
253
+ var r;
254
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
255
+ var i = r.call(t, e || "default");
256
256
  if ("object" != _typeof(i)) return i;
257
257
  throw new TypeError("@@toPrimitive must return a primitive value.");
258
258
  }
259
- return ("string" === r ? String : Number)(t);
259
+ return ("string" === e ? String : Number)(t);
260
260
  }
261
261
 
262
- // \0@oxc-project+runtime@0.156.0/helpers/esm/toPropertyKey.js
262
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
263
263
  function toPropertyKey(t) {
264
264
  var i = toPrimitive(t, "string");
265
265
  return "symbol" == _typeof(i) ? i : i + "";
266
266
  }
267
267
 
268
- // \0@oxc-project+runtime@0.156.0/helpers/esm/defineProperty.js
268
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
269
269
  function _defineProperty(e, r, t) {
270
270
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
271
271
  value: t,
@@ -275,14 +275,14 @@ function _defineProperty(e, r, t) {
275
275
  }) : e[r] = t, e;
276
276
  }
277
277
 
278
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
278
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
279
279
  function __decorateParam(paramIndex, decorator) {
280
280
  return function(target, key) {
281
281
  decorator(target, key, paramIndex);
282
282
  };
283
283
  }
284
284
 
285
- // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
285
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
286
286
  function __decorate(decorators, target, key, desc) {
287
287
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
288
288
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -21413,7 +21413,7 @@ function resolveDocsCustomBlockRenderViewport(params) {
21413
21413
 
21414
21414
  // package.json
21415
21415
  var name = "@univerjs/docs-ui";
21416
- var version = "1.4.0";
21416
+ var version = "1.5.0";
21417
21417
 
21418
21418
  // src/commands/commands/doc-paragraph-setting.command.ts
21419
21419
  const DocParagraphSettingCommand = {
@@ -23028,7 +23028,7 @@ function MobileDocPasteOptions({ popup }) {
23028
23028
  if (!state || state.unitId !== unitId) return null;
23029
23029
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
23030
23030
  "aria-label": localeService.t("docs-ui.pasteOptions.title"),
23031
- className: "univer-min-h-11 univer-min-w-11 univer-shadow-sm [&_svg]:!univer-size-6",
23031
+ className: "[&_svg]:! univer-min-w-11 univer-shadow-sm",
23032
23032
  style: keyboard.visible ? {
23033
23033
  position: "fixed",
23034
23034
  bottom: keyboard.inset + 56,
@@ -23038,6 +23038,7 @@ function MobileDocPasteOptions({ popup }) {
23038
23038
  selection === null || selection === void 0 || selection.suspendMobileEditingInput();
23039
23039
  setOpen(true);
23040
23040
  },
23041
+ size: "icon",
23041
23042
  children: /* @__PURE__ */ jsx(DocPasteOptionsIcon, { "aria-hidden": "true" })
23042
23043
  }), open && /* @__PURE__ */ jsx("div", {
23043
23044
  className: "univer-pointer-events-none univer-fixed univer-inset-x-0 univer-top-0",
@@ -23055,8 +23056,8 @@ function MobileDocPasteOptions({ popup }) {
23055
23056
  className: "univer-flex univer-w-full univer-items-center univer-justify-between univer-gap-2 univer-px-4",
23056
23057
  children: [/* @__PURE__ */ jsx("span", { children: localeService.t("docs-ui.pasteOptions.title") }), /* @__PURE__ */ jsx(Button, {
23057
23058
  variant: "text",
23058
- className: "univer-min-h-11",
23059
23059
  onClick: () => setOpen(false),
23060
+ size: "middle",
23060
23061
  children: localeService.t("docs-ui.mobile.done")
23061
23062
  })]
23062
23063
  }),
@@ -23069,8 +23070,9 @@ function MobileDocPasteOptions({ popup }) {
23069
23070
  "aria-checked": state.mode === option.value,
23070
23071
  disabled: busy,
23071
23072
  variant: "text",
23072
- className: "!univer-h-auto univer-min-h-11 univer-justify-start univer-whitespace-normal univer-py-3 univer-text-start",
23073
+ className: "univer-justify-start univer-whitespace-normal univer-text-start",
23073
23074
  onClick: () => changeMode(option.value),
23075
+ size: "middle",
23074
23076
  children: [/* @__PURE__ */ jsx("span", {
23075
23077
  className: "univer-inline-flex univer-size-5 univer-shrink-0 univer-items-center",
23076
23078
  children: state.mode === option.value && /* @__PURE__ */ jsx(CheckMarkIcon, {})
@@ -23281,9 +23283,9 @@ function DocHeaderFooterOptionsContent({ unitId }) {
23281
23283
  }) })]
23282
23284
  }),
23283
23285
  /* @__PURE__ */ jsxs("div", {
23284
- className: "univer-mb-1 univer-flex",
23286
+ className: "univer-mb-1 univer-grid univer-grid-cols-2 univer-items-end univer-gap-4",
23285
23287
  children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", { children: localeService.t("docs-ui.headerFooter.headerTopMargin") }), /* @__PURE__ */ jsx(InputNumber, {
23286
- className: "univer-mt-1.5 univer-w-4/5",
23288
+ className: "univer-mt-1.5 univer-w-full",
23287
23289
  min: 0,
23288
23290
  max: 200,
23289
23291
  precision: 1,
@@ -23292,7 +23294,7 @@ function DocHeaderFooterOptionsContent({ unitId }) {
23292
23294
  handleMarginChange(val ?? 0, "marginHeader");
23293
23295
  }
23294
23296
  })] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", { children: localeService.t("docs-ui.headerFooter.footerBottomMargin") }), /* @__PURE__ */ jsx(InputNumber, {
23295
- className: "univer-mt-1.5 univer-w-4/5",
23297
+ className: "univer-mt-1.5 univer-w-full",
23296
23298
  min: 0,
23297
23299
  max: 200,
23298
23300
  precision: 1,
@@ -24405,13 +24407,16 @@ function MobileSettingRow({ label, unit, children }) {
24405
24407
  const MobileSettingNumber = forwardRef((props, ref) => /* @__PURE__ */ jsx(InputNumber, {
24406
24408
  ...props,
24407
24409
  ref,
24408
- className: clsx(props.className, "univer-h-12 univer-w-full"),
24409
- inputClassName: clsx(props.inputClassName, "univer-text-base")
24410
+ className: clsx(props.className, "univer-w-full"),
24411
+ inputClassName: clsx(props.inputClassName, ""),
24412
+ size: "small",
24413
+ controls: false
24410
24414
  }));
24411
24415
  function MobileSettingSelect(props) {
24412
24416
  return /* @__PURE__ */ jsx(MobileSelect, {
24413
24417
  ...props,
24414
- className: clsx(props.className, "univer-h-12 univer-w-full")
24418
+ className: clsx(props.className, "univer-w-full"),
24419
+ size: "small"
24415
24420
  });
24416
24421
  }
24417
24422
  function MobileParagraphNumber({ min = 0, max = 100, step = .1, precision = 1, onChange, ...props }) {
@@ -24430,8 +24435,9 @@ function MobileParagraphAlignmentButton({ label, selected, onClick, children })
24430
24435
  variant: "text",
24431
24436
  "aria-label": label,
24432
24437
  "aria-pressed": selected,
24433
- className: clsx("univer-h-12 univer-w-full", { "!univer-bg-gray-200 dark:!univer-bg-gray-700": selected }),
24438
+ className: clsx("univer-w-full", { "!univer-bg-gray-200 dark:!univer-bg-gray-700": selected }),
24434
24439
  onClick,
24440
+ size: "middle",
24435
24441
  children: /* @__PURE__ */ jsx("span", {
24436
24442
  className: "univer-flex univer-size-5 univer-items-center univer-justify-center univer-text-lg",
24437
24443
  children
@@ -24532,8 +24538,9 @@ function MobileHeaderFooterOptions({ unitId }) {
24532
24538
  /* @__PURE__ */ jsx("div", {
24533
24539
  className: "univer-flex",
24534
24540
  children: /* @__PURE__ */ jsx(Button, {
24535
- className: "univer-h-12 univer-w-full",
24541
+ className: "univer-w-full",
24536
24542
  onClick: closeHeaderFooter,
24543
+ size: "middle",
24537
24544
  children: localeService.t("docs-ui.headerFooter.closeHeaderFooter")
24538
24545
  })
24539
24546
  })
@@ -24852,6 +24859,7 @@ function useMobileDocEditState() {
24852
24859
  const unitId = currentDoc === null || currentDoc === void 0 ? void 0 : currentDoc.getUnitId();
24853
24860
  const selectionService = unitId ? (_renderManagerService = renderManagerService.getRenderUnitById(unitId)) === null || _renderManagerService === void 0 ? void 0 : _renderManagerService.with(DocSelectionRenderService) : void 0;
24854
24861
  return {
24862
+ unitId,
24855
24863
  isEditing: useObservable(selectionService === null || selectionService === void 0 ? void 0 : selectionService.mobileEditMode$, (selectionService === null || selectionService === void 0 ? void 0 : selectionService.isMobileEditMode) ?? false),
24856
24864
  isReadOnly: unitId ? ((_editorService$getEdi = editorService.getEditor(unitId)) === null || _editorService$getEdi === void 0 ? void 0 : _editorService$getEdi.isReadOnly()) === true : true,
24857
24865
  selectionService
@@ -24875,7 +24883,10 @@ function MobileDocToolbar() {
24875
24883
  const menuManagerService = useDependency(IMenuManagerService);
24876
24884
  const workbenchService = useDependency(IWorkbenchService);
24877
24885
  const rootUnitType = useObservable(workbenchService.rootUnitType$, null, true);
24878
- const { isEditing, isReadOnly, selectionService } = useMobileDocEditState();
24886
+ const { unitId, isEditing, isReadOnly, selectionService } = useMobileDocEditState();
24887
+ const injector = useDependency(Injector);
24888
+ const focusCoordinator = injector.has(IDocEmbedRuntimeFocusCoordinator) ? injector.get(IDocEmbedRuntimeFocusCoordinator) : void 0;
24889
+ const embeddedDocActive = useObservable(() => (focusCoordinator === null || focusCoordinator === void 0 ? void 0 : focusCoordinator.runtimeSessionChanged$.pipe(startWith(void 0), map(() => focusCoordinator.isChildUnitInActiveSession(unitId)))) ?? of(false), (focusCoordinator === null || focusCoordinator === void 0 ? void 0 : focusCoordinator.isChildUnitInActiveSession(unitId)) ?? false, false, [focusCoordinator, unitId]);
24879
24890
  const keyboardState = useObservable(selectionService === null || selectionService === void 0 ? void 0 : selectionService.mobileKeyboardState$, {
24880
24891
  visible: false,
24881
24892
  inset: 0
@@ -24903,13 +24914,13 @@ function MobileDocToolbar() {
24903
24914
  return () => subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
24904
24915
  }, [selectionService, closeDrawer]);
24905
24916
  const drawerSchemas = useMemo(() => drawer ? menuSchemas[drawer] : [], [drawer, menuSchemas]);
24906
- if (rootUnitType !== UniverInstanceType.UNIVER_DOC) return null;
24917
+ if (rootUnitType !== UniverInstanceType.UNIVER_DOC && !embeddedDocActive) return null;
24907
24918
  if (!isEditing) {
24908
24919
  if (isReadOnly) return null;
24909
24920
  return /* @__PURE__ */ jsx("button", {
24910
24921
  type: "button",
24911
24922
  "aria-label": localeService.t("docs-ui.mobile.edit"),
24912
- className: clsx(resetButtonClassName, "univer-pointer-events-auto univer-absolute univer-bottom-4 univer-z-30 univer-flex univer-size-14 univer-items-center univer-justify-center univer-rounded-full univer-bg-primary-600 univer-text-2xl univer-text-white univer-shadow-lg active:univer-scale-95 active:univer-bg-primary-700 dark:!univer-bg-primary-500 dark:active:!univer-bg-primary-600"),
24923
+ className: clsx(resetButtonClassName, "univer-pointer-events-auto univer-absolute univer-bottom-4 univer-z-50 univer-flex univer-size-14 univer-items-center univer-justify-center univer-rounded-full univer-bg-primary-600 univer-text-2xl univer-text-white univer-shadow-lg active:univer-scale-95 active:univer-bg-primary-700 dark:!univer-bg-primary-500 dark:active:!univer-bg-primary-600"),
24913
24924
  style: {
24914
24925
  insetInlineEnd: "1rem",
24915
24926
  marginBottom: "env(safe-area-inset-bottom, 0px)"
@@ -24955,7 +24966,7 @@ function MobileDocToolbar() {
24955
24966
  const quickMenuType = quickMenu === "block" ? DOC_PARAGRAPH_T_EDIT_MENU_ID : DOC_PARAGRAPH_T_ALIGN_MENU_ID;
24956
24967
  return /* @__PURE__ */ jsxs(Fragment, { children: [
24957
24968
  keyboardVisible && quickMenu && /* @__PURE__ */ jsx("div", {
24958
- className: "univer-pointer-events-auto univer-absolute univer-inset-x-3 univer-z-30 univer-overflow-hidden",
24969
+ className: "univer-pointer-events-auto univer-absolute univer-inset-x-3 univer-z-50 univer-overflow-hidden",
24959
24970
  style: { bottom: `${keyboardState.inset + 48}px` },
24960
24971
  children: /* @__PURE__ */ jsx(MobileMenu, {
24961
24972
  menuType: quickMenuType,
@@ -24964,7 +24975,7 @@ function MobileDocToolbar() {
24964
24975
  })
24965
24976
  }),
24966
24977
  keyboardVisible && !drawer && /* @__PURE__ */ jsxs("div", {
24967
- className: "univer-pointer-events-auto univer-absolute univer-inset-x-0 univer-z-30 univer-box-border univer-flex univer-h-12 univer-items-center univer-gap-0.5 univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-1 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
24978
+ className: "univer-pointer-events-auto univer-absolute univer-inset-x-0 univer-z-50 univer-box-border univer-flex univer-h-12 univer-items-center univer-gap-0.5 univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-1 dark:!univer-border-gray-700 dark:!univer-bg-gray-800",
24968
24979
  style: {
24969
24980
  bottom: `${keyboardState.inset}px`,
24970
24981
  paddingBottom: "env(safe-area-inset-bottom, 0px)"
@@ -31899,10 +31910,8 @@ function MobileRichTextToolbar({ editorId, className }) {
31899
31910
  return /* @__PURE__ */ jsx("div", {
31900
31911
  "data-u-comp": "mobile-rich-text-toolbar",
31901
31912
  className: clsx("univer-box-border univer-bg-gray-0 univer-shadow-[0_1px_0_rgba(0,0,0,0.06)] dark:!univer-bg-gray-800", className),
31902
- onPointerDown: (event) => {
31903
- event.preventDefault();
31904
- event.stopPropagation();
31905
- },
31913
+ onPointerDown: (event) => event.stopPropagation(),
31914
+ onMouseDown: (event) => event.preventDefault(),
31906
31915
  children: !colorsVisible ? /* @__PURE__ */ jsxs("div", {
31907
31916
  className: "univer-grid univer-h-11 univer-grid-cols-7 univer-gap-1 univer-px-2",
31908
31917
  children: [
@@ -31992,7 +32001,7 @@ function MobileRichTextToolbar({ editorId, className }) {
31992
32001
  variant: "text",
31993
32002
  size: "icon",
31994
32003
  "aria-label": localeService.t("docs-ui.toolbar.textColor.main"),
31995
- className: "univer-size-7 univer-justify-self-center",
32004
+ className: "univer-justify-self-center",
31996
32005
  children: /* @__PURE__ */ jsx(ColorWheelMultiIcon, { className: "!univer-size-6" })
31997
32006
  })
31998
32007
  })
@@ -32363,6 +32372,8 @@ function useOnChange(editor, onChange) {
32363
32372
  function resizeEditor(editor, isSingle, layoutSize, pixelRatio, documentLayoutSize) {
32364
32373
  var _editor$render$compon;
32365
32374
  if (editor.render.isDisposed()) return;
32375
+ const selection = editor.docSelectionRenderService;
32376
+ const restoreSelection = selection.isFocusing || selection.getAllTextRanges().length > 0 || selection.getAllRectRanges().length > 0;
32366
32377
  const { scene, mainComponent } = editor.render;
32367
32378
  const docSkeletonManagerService = editor.render.with(DocSkeletonManagerService);
32368
32379
  const { width, height } = layoutSize ?? editor.getBoundingClientRect();
@@ -32378,7 +32389,7 @@ function resizeEditor(editor, isSingle, layoutSize, pixelRatio, documentLayoutSi
32378
32389
  mainComponent === null || mainComponent === void 0 || mainComponent.translate(0, 0);
32379
32390
  (_editor$render$compon = editor.render.components.get("__Document_Render_Background__")) === null || _editor$render$compon === void 0 || _editor$render$compon.translate(0, 0);
32380
32391
  const selectionRanges = editor.getSelectionRanges();
32381
- if (selectionRanges.length > 0) editor.setSelectionRanges(selectionRanges, false);
32392
+ if (restoreSelection && selectionRanges.length > 0) editor.setSelectionRanges(selectionRanges, false);
32382
32393
  }
32383
32394
  const useResize = (editor, isSingle = true, autoScrollbar, autoScroll, layoutSize, pixelRatio, documentLayoutSize) => {
32384
32395
  const resize = useCallback(() => {
@@ -32636,6 +32647,21 @@ const RichTextEditor = (props) => {
32636
32647
  };
32637
32648
 
32638
32649
  // src/views/mobile-rich-text-editor/MobileRichTextEditor.tsx
32650
+ /**
32651
+ * Copyright 2023-present DreamNum Co., Ltd.
32652
+ *
32653
+ * Licensed under the Apache License, Version 2.0 (the "License");
32654
+ * you may not use this file except in compliance with the License.
32655
+ * You may obtain a copy of the License at
32656
+ *
32657
+ * http://www.apache.org/licenses/LICENSE-2.0
32658
+ *
32659
+ * Unless required by applicable law or agreed to in writing, software
32660
+ * distributed under the License is distributed on an "AS IS" BASIS,
32661
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32662
+ * See the License for the specific language governing permissions and
32663
+ * limitations under the License.
32664
+ */
32639
32665
  /** Compact object text input; expanding keeps the same document editor mounted. */
32640
32666
  function MobileRichTextEditor(props) {
32641
32667
  var _props$canvasStyle;
@@ -32660,7 +32686,7 @@ function MobileRichTextEditor(props) {
32660
32686
  if (keyboardWasVisibleRef.current && !visible) confirmOnDismiss();
32661
32687
  keyboardWasVisibleRef.current = visible;
32662
32688
  }, [confirmOnDismiss, keyboardInset]);
32663
- const buttonClassName = clsx("univer-h-12 univer-shrink-0 univer-text-lg", expanded ? "univer-flex-1" : "univer-w-10");
32689
+ const buttonClassName = clsx("univer-shrink-0", expanded ? "univer-flex-1" : "univer-w-10");
32664
32690
  const expandButton = /* @__PURE__ */ jsx(Button, {
32665
32691
  variant: "ghost",
32666
32692
  className: buttonClassName,
@@ -32668,6 +32694,7 @@ function MobileRichTextEditor(props) {
32668
32694
  "aria-expanded": expanded,
32669
32695
  onPointerDown: (event) => event.preventDefault(),
32670
32696
  onClick: () => onExpandedChange(!expanded),
32697
+ size: "middle",
32671
32698
  children: /* @__PURE__ */ jsx(DownIcon, { className: clsx("univer-size-5", !expanded && "univer-rotate-180") })
32672
32699
  });
32673
32700
  return /* @__PURE__ */ jsxs("section", {
@@ -32707,6 +32734,7 @@ function MobileRichTextEditor(props) {
32707
32734
  "aria-label": labels.cancel,
32708
32735
  onPointerDown: (event) => event.preventDefault(),
32709
32736
  onClick: onCancel,
32737
+ size: "middle",
32710
32738
  children: /* @__PURE__ */ jsx(CloseIcon, {})
32711
32739
  }),
32712
32740
  /* @__PURE__ */ jsx(Button, {
@@ -32715,6 +32743,7 @@ function MobileRichTextEditor(props) {
32715
32743
  "aria-label": labels.confirm,
32716
32744
  onPointerDown: (event) => event.preventDefault(),
32717
32745
  onClick: onConfirm,
32746
+ size: "middle",
32718
32747
  children: /* @__PURE__ */ jsx(CheckMarkIcon, {})
32719
32748
  }),
32720
32749
  expanded && expandButton