@univerjs/sheets-drawing-ui 1.0.0-rc.0 → 1.0.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.
Files changed (100) hide show
  1. package/lib/cjs/index.js +542 -73
  2. package/lib/cjs/locale/ar-SA.js +5 -1
  3. package/lib/cjs/locale/ca-ES.js +5 -1
  4. package/lib/cjs/locale/de-DE.js +5 -1
  5. package/lib/cjs/locale/en-US.js +5 -1
  6. package/lib/cjs/locale/es-ES.js +5 -1
  7. package/lib/cjs/locale/fa-IR.js +5 -1
  8. package/lib/cjs/locale/fr-FR.js +5 -1
  9. package/lib/cjs/locale/id-ID.js +5 -1
  10. package/lib/cjs/locale/it-IT.js +5 -1
  11. package/lib/cjs/locale/ja-JP.js +5 -1
  12. package/lib/cjs/locale/ko-KR.js +5 -1
  13. package/lib/cjs/locale/pl-PL.js +5 -1
  14. package/lib/cjs/locale/pt-BR.js +5 -1
  15. package/lib/cjs/locale/ru-RU.js +5 -1
  16. package/lib/cjs/locale/sk-SK.js +5 -1
  17. package/lib/cjs/locale/vi-VN.js +5 -1
  18. package/lib/cjs/locale/zh-CN.js +5 -1
  19. package/lib/cjs/locale/zh-HK.js +5 -1
  20. package/lib/cjs/locale/zh-TW.js +5 -1
  21. package/lib/es/index.js +546 -79
  22. package/lib/es/locale/ar-SA.js +5 -0
  23. package/lib/es/locale/ca-ES.js +5 -0
  24. package/lib/es/locale/de-DE.js +5 -0
  25. package/lib/es/locale/en-US.js +5 -0
  26. package/lib/es/locale/es-ES.js +5 -0
  27. package/lib/es/locale/fa-IR.js +5 -0
  28. package/lib/es/locale/fr-FR.js +5 -0
  29. package/lib/es/locale/id-ID.js +5 -0
  30. package/lib/es/locale/it-IT.js +5 -0
  31. package/lib/es/locale/ja-JP.js +5 -0
  32. package/lib/es/locale/ko-KR.js +5 -0
  33. package/lib/es/locale/pl-PL.js +5 -0
  34. package/lib/es/locale/pt-BR.js +5 -0
  35. package/lib/es/locale/ru-RU.js +5 -0
  36. package/lib/es/locale/sk-SK.js +5 -0
  37. package/lib/es/locale/vi-VN.js +5 -0
  38. package/lib/es/locale/zh-CN.js +5 -0
  39. package/lib/es/locale/zh-HK.js +5 -0
  40. package/lib/es/locale/zh-TW.js +5 -0
  41. package/lib/index.js +546 -79
  42. package/lib/locale/ar-SA.js +5 -0
  43. package/lib/locale/ca-ES.js +5 -0
  44. package/lib/locale/de-DE.js +5 -0
  45. package/lib/locale/en-US.js +5 -0
  46. package/lib/locale/es-ES.js +5 -0
  47. package/lib/locale/fa-IR.js +5 -0
  48. package/lib/locale/fr-FR.js +5 -0
  49. package/lib/locale/id-ID.js +5 -0
  50. package/lib/locale/it-IT.js +5 -0
  51. package/lib/locale/ja-JP.js +5 -0
  52. package/lib/locale/ko-KR.js +5 -0
  53. package/lib/locale/pl-PL.js +5 -0
  54. package/lib/locale/pt-BR.js +5 -0
  55. package/lib/locale/ru-RU.js +5 -0
  56. package/lib/locale/sk-SK.js +5 -0
  57. package/lib/locale/vi-VN.js +5 -0
  58. package/lib/locale/zh-CN.js +5 -0
  59. package/lib/locale/zh-HK.js +5 -0
  60. package/lib/locale/zh-TW.js +5 -0
  61. package/lib/types/commands/commands/worksheet-background-image.command.d.ts +21 -0
  62. package/lib/types/controllers/render-controllers/worksheet-background.render-controller.d.ts +21 -0
  63. package/lib/types/controllers/sheet-drawing-copy-paste.controller.d.ts +2 -2
  64. package/lib/types/controllers/sheet-drawing-group-copy-paste.controller.d.ts +6 -1
  65. package/lib/types/controllers/sheet-drawing-transform-affected.controller.d.ts +55 -0
  66. package/lib/types/controllers/sheet-drawing-update.controller.d.ts +2 -1
  67. package/lib/types/controllers/sheet-drawing.controller.d.ts +29 -0
  68. package/lib/types/controllers/ui.controller.d.ts +2 -4
  69. package/lib/types/facade/f-range.d.ts +1 -1
  70. package/lib/types/facade/f-worksheet.d.ts +1 -1
  71. package/lib/types/index.d.ts +3 -0
  72. package/lib/types/locale/en-US.d.ts +5 -0
  73. package/lib/types/menu/mobile-schema.d.ts +17 -0
  74. package/lib/types/menu/mobile-sheet-drawing-menu.controller.d.ts +20 -0
  75. package/lib/types/menu/sheet-drawing-menu.controller.d.ts +20 -0
  76. package/lib/types/menu/worksheet-background-image.menu.d.ts +22 -0
  77. package/lib/types/utils/worksheet-background-image.d.ts +25 -0
  78. package/lib/types/views/background/worksheet-background-image.extension.d.ts +27 -0
  79. package/lib/types/views/printing-float-dom/index.d.ts +25 -0
  80. package/lib/umd/index.js +2 -2
  81. package/lib/umd/locale/ar-SA.js +1 -1
  82. package/lib/umd/locale/ca-ES.js +1 -1
  83. package/lib/umd/locale/de-DE.js +1 -1
  84. package/lib/umd/locale/en-US.js +1 -1
  85. package/lib/umd/locale/es-ES.js +1 -1
  86. package/lib/umd/locale/fa-IR.js +1 -1
  87. package/lib/umd/locale/fr-FR.js +1 -1
  88. package/lib/umd/locale/id-ID.js +1 -1
  89. package/lib/umd/locale/it-IT.js +1 -1
  90. package/lib/umd/locale/ja-JP.js +1 -1
  91. package/lib/umd/locale/ko-KR.js +1 -1
  92. package/lib/umd/locale/pl-PL.js +1 -1
  93. package/lib/umd/locale/pt-BR.js +1 -1
  94. package/lib/umd/locale/ru-RU.js +1 -1
  95. package/lib/umd/locale/sk-SK.js +1 -1
  96. package/lib/umd/locale/vi-VN.js +1 -1
  97. package/lib/umd/locale/zh-CN.js +1 -1
  98. package/lib/umd/locale/zh-HK.js +1 -1
  99. package/lib/umd/locale/zh-TW.js +1 -1
  100. package/package.json +16 -16
package/lib/cjs/index.js CHANGED
@@ -288,7 +288,147 @@ const UngroupSheetDrawingCommand = {
288
288
  };
289
289
 
290
290
  //#endregion
291
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
291
+ //#region src/utils/worksheet-background-image.ts
292
+ /**
293
+ * Copyright 2023-present DreamNum Co., Ltd.
294
+ *
295
+ * Licensed under the Apache License, Version 2.0 (the "License");
296
+ * you may not use this file except in compliance with the License.
297
+ * You may obtain a copy of the License at
298
+ *
299
+ * http://www.apache.org/licenses/LICENSE-2.0
300
+ *
301
+ * Unless required by applicable law or agreed to in writing, software
302
+ * distributed under the License is distributed on an "AS IS" BASIS,
303
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
304
+ * See the License for the specific language governing permissions and
305
+ * limitations under the License.
306
+ */
307
+ const WORKSHEET_LAYOUT_DPI = 96;
308
+ const METERS_PER_INCH = .0254;
309
+ /**
310
+ * Excel tiles worksheet background images using their physical resolution,
311
+ * while Canvas tiles them using source pixels. Convert the source resolution
312
+ * to Univer's 96-DPI worksheet layout pixels.
313
+ */
314
+ function getWorksheetBackgroundImageScale(source) {
315
+ const bytes = decodeBase64DataUri(source);
316
+ if (!bytes) return;
317
+ const pixelsPerMeter = readImagePixelsPerMeter(bytes);
318
+ if (!pixelsPerMeter) return;
319
+ const scaleX = WORKSHEET_LAYOUT_DPI / (pixelsPerMeter.x * METERS_PER_INCH);
320
+ const scaleY = WORKSHEET_LAYOUT_DPI / (pixelsPerMeter.y * METERS_PER_INCH);
321
+ if (!Number.isFinite(scaleX) || !Number.isFinite(scaleY)) return;
322
+ if (Math.abs(scaleX - 1) <= .001 && Math.abs(scaleY - 1) <= .001) return;
323
+ return {
324
+ scaleX,
325
+ scaleY
326
+ };
327
+ }
328
+ function decodeBase64DataUri(source) {
329
+ const separator = source.indexOf(",");
330
+ if (separator < 0 || !source.slice(0, separator).toLowerCase().includes(";base64")) return;
331
+ try {
332
+ const binary = globalThis.atob(source.slice(separator + 1));
333
+ const bytes = new Uint8Array(binary.length);
334
+ for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index);
335
+ return bytes;
336
+ } catch {
337
+ return;
338
+ }
339
+ }
340
+ function readImagePixelsPerMeter(bytes) {
341
+ return readPngPixelsPerMeter(bytes) ?? readJpegPixelsPerMeter(bytes);
342
+ }
343
+ function readPngPixelsPerMeter(bytes) {
344
+ if (!hasBytes(bytes, 0, [
345
+ 137,
346
+ 80,
347
+ 78,
348
+ 71,
349
+ 13,
350
+ 10,
351
+ 26,
352
+ 10
353
+ ])) return;
354
+ let offset = 8;
355
+ while (offset + 12 <= bytes.length) {
356
+ const length = readUint32Be(bytes, offset);
357
+ const typeOffset = offset + 4;
358
+ const dataOffset = offset + 8;
359
+ const dataEnd = dataOffset + length;
360
+ const nextOffset = dataEnd + 4;
361
+ if (nextOffset > bytes.length) return;
362
+ if (hasBytes(bytes, typeOffset, [
363
+ 112,
364
+ 72,
365
+ 89,
366
+ 115
367
+ ])) {
368
+ if (length !== 9 || bytes[dataEnd - 1] !== 1) return;
369
+ const x = readUint32Be(bytes, dataOffset);
370
+ const y = readUint32Be(bytes, dataOffset + 4);
371
+ return x > 0 && y > 0 ? {
372
+ x,
373
+ y
374
+ } : void 0;
375
+ }
376
+ offset = nextOffset;
377
+ }
378
+ }
379
+ function readJpegPixelsPerMeter(bytes) {
380
+ if (!hasBytes(bytes, 0, [255, 216])) return;
381
+ let offset = 2;
382
+ while (offset + 4 <= bytes.length) {
383
+ if (bytes[offset] !== 255) {
384
+ offset++;
385
+ continue;
386
+ }
387
+ while (offset < bytes.length && bytes[offset] === 255) offset++;
388
+ const marker = bytes[offset++];
389
+ if (marker == null) return;
390
+ if (marker === 216 || marker === 217 || marker === 1 || marker >= 208 && marker <= 215) continue;
391
+ const length = readUint16Be(bytes, offset);
392
+ if (length < 2) return;
393
+ const dataOffset = offset + 2;
394
+ const dataEnd = offset + length;
395
+ if (dataEnd > bytes.length) return;
396
+ if (marker === 224 && length >= 14 && hasBytes(bytes, dataOffset, [
397
+ 74,
398
+ 70,
399
+ 73,
400
+ 70,
401
+ 0
402
+ ])) {
403
+ const units = bytes[dataOffset + 7];
404
+ const xDensity = readUint16Be(bytes, dataOffset + 8);
405
+ const yDensity = readUint16Be(bytes, dataOffset + 10);
406
+ if (!xDensity || !yDensity) return;
407
+ if (units === 1) return {
408
+ x: Math.round(xDensity / METERS_PER_INCH),
409
+ y: Math.round(yDensity / METERS_PER_INCH)
410
+ };
411
+ if (units === 2) return {
412
+ x: xDensity * 100,
413
+ y: yDensity * 100
414
+ };
415
+ return;
416
+ }
417
+ offset = dataEnd;
418
+ }
419
+ }
420
+ function hasBytes(bytes, offset, expected) {
421
+ return expected.every((value, index) => bytes[offset + index] === value);
422
+ }
423
+ function readUint16Be(bytes, offset) {
424
+ return (bytes[offset] ?? 0) << 8 | (bytes[offset + 1] ?? 0);
425
+ }
426
+ function readUint32Be(bytes, offset) {
427
+ return ((bytes[offset] ?? 0) << 24 >>> 0 | (bytes[offset + 1] ?? 0) << 16 | (bytes[offset + 2] ?? 0) << 8 | (bytes[offset + 3] ?? 0)) >>> 0;
428
+ }
429
+
430
+ //#endregion
431
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
292
432
  function _typeof(o) {
293
433
  "@babel/helpers - typeof";
294
434
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -299,7 +439,7 @@ function _typeof(o) {
299
439
  }
300
440
 
301
441
  //#endregion
302
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
442
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
303
443
  function toPrimitive(t, r) {
304
444
  if ("object" != _typeof(t) || !t) return t;
305
445
  var e = t[Symbol.toPrimitive];
@@ -312,14 +452,14 @@ function toPrimitive(t, r) {
312
452
  }
313
453
 
314
454
  //#endregion
315
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
455
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
316
456
  function toPropertyKey(t) {
317
457
  var i = toPrimitive(t, "string");
318
458
  return "symbol" == _typeof(i) ? i : i + "";
319
459
  }
320
460
 
321
461
  //#endregion
322
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
462
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
323
463
  function _defineProperty(e, r, t) {
324
464
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
325
465
  value: t,
@@ -330,7 +470,7 @@ function _defineProperty(e, r, t) {
330
470
  }
331
471
 
332
472
  //#endregion
333
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
473
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
334
474
  function __decorateParam(paramIndex, decorator) {
335
475
  return function(target, key) {
336
476
  decorator(target, key, paramIndex);
@@ -338,7 +478,7 @@ function __decorateParam(paramIndex, decorator) {
338
478
  }
339
479
 
340
480
  //#endregion
341
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
481
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
342
482
  function __decorate(decorators, target, key, desc) {
343
483
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
344
484
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -440,6 +580,44 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
440
580
  }
441
581
  return false;
442
582
  }
583
+ async setWorksheetBackgroundImage(files) {
584
+ const file = (files ?? await this._fileOpenerService.openFile({
585
+ multiple: false,
586
+ accept: _univerjs_drawing.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
587
+ }))[0];
588
+ if (!file) return false;
589
+ let imageParam;
590
+ try {
591
+ imageParam = await this._imageIoService.saveImage(file);
592
+ } catch (error) {
593
+ const type = error.message;
594
+ if (type === _univerjs_core.ImageUploadStatusType.ERROR_EXCEED_SIZE) this._messageService.show({
595
+ type: _univerjs_design.MessageType.Error,
596
+ content: this._localeService.t("sheets-drawing-ui.update-status.exceedMaxSize", String((0, _univerjs_drawing.getDrawingImageAllowSize)() / 1048576))
597
+ });
598
+ else if (type === _univerjs_core.ImageUploadStatusType.ERROR_IMAGE_TYPE) this._messageService.show({
599
+ type: _univerjs_design.MessageType.Error,
600
+ content: this._localeService.t("sheets-drawing-ui.update-status.invalidImageType")
601
+ });
602
+ else if (type === _univerjs_core.ImageUploadStatusType.ERROR_IMAGE) this._messageService.show({
603
+ type: _univerjs_design.MessageType.Error,
604
+ content: this._localeService.t("sheets-drawing-ui.update-status.invalidImage")
605
+ });
606
+ return false;
607
+ }
608
+ if (!imageParam) return false;
609
+ const { unitId, subUnitId } = this._getUnitInfo();
610
+ const scale = getWorksheetBackgroundImageScale(imageParam.base64Cache || imageParam.source);
611
+ return this._commandService.executeCommand(_univerjs_sheets_drawing.SetWorksheetBackgroundImageCommand.id, {
612
+ unitId,
613
+ subUnitId,
614
+ backgroundImage: {
615
+ source: imageParam.source,
616
+ imageSourceType: imageParam.imageSourceType,
617
+ ...scale
618
+ }
619
+ });
620
+ }
443
621
  insertCellImageByFile(file, location) {
444
622
  return this._insertCellImage(file, location);
445
623
  }
@@ -451,7 +629,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
451
629
  const type = error.message;
452
630
  if (type === _univerjs_core.ImageUploadStatusType.ERROR_EXCEED_SIZE) this._messageService.show({
453
631
  type: _univerjs_design.MessageType.Error,
454
- content: this._localeService.t("sheets-drawing-ui.update-status.exceedMaxSize", String((0, _univerjs_drawing.getDrawingImageAllowSize)() / (1024 * 1024)))
632
+ content: this._localeService.t("sheets-drawing-ui.update-status.exceedMaxSize", String((0, _univerjs_drawing.getDrawingImageAllowSize)() / 1048576))
455
633
  });
456
634
  else if (type === _univerjs_core.ImageUploadStatusType.ERROR_IMAGE_TYPE) this._messageService.show({
457
635
  type: _univerjs_design.MessageType.Error,
@@ -505,7 +683,7 @@ let SheetDrawingUpdateController = class SheetDrawingUpdateController extends _u
505
683
  const type = error.message;
506
684
  if (type === _univerjs_core.ImageUploadStatusType.ERROR_EXCEED_SIZE) this._messageService.show({
507
685
  type: _univerjs_design.MessageType.Error,
508
- content: this._localeService.t("sheets-drawing-ui.update-status.exceedMaxSize", String((0, _univerjs_drawing.getDrawingImageAllowSize)() / (1024 * 1024)))
686
+ content: this._localeService.t("sheets-drawing-ui.update-status.exceedMaxSize", String((0, _univerjs_drawing.getDrawingImageAllowSize)() / 1048576))
509
687
  });
510
688
  else if (type === _univerjs_core.ImageUploadStatusType.ERROR_IMAGE_TYPE) this._messageService.show({
511
689
  type: _univerjs_design.MessageType.Error,
@@ -1348,6 +1526,24 @@ const SaveCellImagesCommand = {
1348
1526
  }
1349
1527
  };
1350
1528
 
1529
+ //#endregion
1530
+ //#region src/commands/commands/worksheet-background-image.command.ts
1531
+ const AddWorksheetBackgroundImageCommand = {
1532
+ id: "sheet.command.add-worksheet-background-image",
1533
+ type: _univerjs_core.CommandType.COMMAND,
1534
+ handler: (accessor, params) => {
1535
+ var _getCurrentTypeOfRend;
1536
+ const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
1537
+ const renderManagerService = accessor.get(_univerjs_engine_render.IRenderManagerService);
1538
+ return ((_getCurrentTypeOfRend = (0, _univerjs_engine_render.getCurrentTypeOfRenderer)(_univerjs_core.UniverInstanceType.UNIVER_SHEET, univerInstanceService, renderManagerService)) === null || _getCurrentTypeOfRend === void 0 ? void 0 : _getCurrentTypeOfRend.with(SheetDrawingUpdateController).setWorksheetBackgroundImage(params === null || params === void 0 ? void 0 : params.files)) ?? false;
1539
+ }
1540
+ };
1541
+ const DeleteWorksheetBackgroundImageCommand = {
1542
+ id: "sheet.command.delete-worksheet-background-image",
1543
+ type: _univerjs_core.CommandType.COMMAND,
1544
+ handler: (accessor) => accessor.get(_univerjs_core.ICommandService).executeCommand(_univerjs_sheets_drawing.SetWorksheetBackgroundImageCommand.id, { backgroundImage: null })
1545
+ };
1546
+
1351
1547
  //#endregion
1352
1548
  //#region src/views/sheet-image-panel/component-name.ts
1353
1549
  /**
@@ -1392,9 +1588,7 @@ const SidebarSheetDrawingOperation = {
1392
1588
  width: 360
1393
1589
  });
1394
1590
  break;
1395
- default:
1396
- sidebarService.close(COMPONENT_SHEET_DRAWING_PANEL);
1397
- break;
1591
+ default: sidebarService.close(COMPONENT_SHEET_DRAWING_PANEL);
1398
1592
  }
1399
1593
  return true;
1400
1594
  }
@@ -1473,20 +1667,32 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
1473
1667
  }
1474
1668
  });
1475
1669
  }
1476
- registerFeaturePasteHook(hook) {
1477
- this._featurePasteHooks.push(hook);
1670
+ registerFeaturePasteHook(hook, options) {
1671
+ const entry = {
1672
+ hook,
1673
+ beforeDrawing: (options === null || options === void 0 ? void 0 : options.beforeDrawing) === true
1674
+ };
1675
+ this._featurePasteHooks.push(entry);
1676
+ return (0, _univerjs_core.toDisposable)(() => {
1677
+ const index = this._featurePasteHooks.indexOf(entry);
1678
+ if (index >= 0) this._featurePasteHooks.splice(index, 1);
1679
+ });
1478
1680
  }
1479
- _getGroupFeaturePasteMutations(params) {
1681
+ _getGroupFeaturePasteMutations(params, beforeDrawing) {
1480
1682
  const redos = [];
1481
1683
  const undos = [];
1482
- for (const hook of this._featurePasteHooks) {
1483
- const result = hook(params);
1684
+ let cancel = false;
1685
+ for (const entry of this._featurePasteHooks) {
1686
+ if (entry.beforeDrawing !== beforeDrawing) continue;
1687
+ const result = entry.hook(params);
1484
1688
  redos.push(...result.redos);
1485
1689
  undos.push(...result.undos);
1690
+ cancel = cancel || result.cancel === true;
1486
1691
  }
1487
1692
  return {
1488
1693
  redos,
1489
- undos
1694
+ undos,
1695
+ cancel
1490
1696
  };
1491
1697
  }
1492
1698
  _generateGroupPasteMutations(pasteTo) {
@@ -1504,6 +1710,19 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
1504
1710
  const origRootGroup = groupNestedParam.groups[groupNestedParam.groups.length - 1];
1505
1711
  const { cloned, idMap } = cloneGroupParams(groupNestedParam);
1506
1712
  const newRootGroupId = cloned.groups[cloned.groups.length - 1].drawingId;
1713
+ const featureParams = {
1714
+ fromUnitId: this._copyInfo.unitId,
1715
+ fromSubUnitId: this._copyInfo.subUnitId,
1716
+ toUnitId: unitId,
1717
+ toSubUnitId: subUnitId,
1718
+ idMap,
1719
+ cloned
1720
+ };
1721
+ const beforeDrawingMutations = this._getGroupFeaturePasteMutations(featureParams, true);
1722
+ if (beforeDrawingMutations.cancel) return {
1723
+ redos: [],
1724
+ undos: []
1725
+ };
1507
1726
  const pasteRange = (0, _univerjs_sheets.discreteRangeToRange)(range);
1508
1727
  const pasteRect = (0, _univerjs_sheets.attachRangeWithCoord)(pasteToSkeleton, {
1509
1728
  startRow: pasteRange.startRow,
@@ -1540,7 +1759,12 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
1540
1759
  };
1541
1760
  })];
1542
1761
  const { undo: removeOp, redo: insertOp, objects } = this._sheetDrawingService.getBatchAddOp(allDrawings);
1543
- const redos = [{
1762
+ const afterDrawingMutations = this._getGroupFeaturePasteMutations(featureParams, false);
1763
+ if (afterDrawingMutations.cancel) return {
1764
+ redos: [],
1765
+ undos: []
1766
+ };
1767
+ const drawingRedo = {
1544
1768
  id: _univerjs_sheets_drawing.SetDrawingApplyMutation.id,
1545
1769
  params: {
1546
1770
  op: insertOp,
@@ -1549,8 +1773,8 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
1549
1773
  objects,
1550
1774
  type: _univerjs_sheets_drawing.DrawingApplyType.INSERT
1551
1775
  }
1552
- }];
1553
- const undos = [{
1776
+ };
1777
+ const drawingUndo = {
1554
1778
  id: _univerjs_sheets_drawing.SetDrawingApplyMutation.id,
1555
1779
  params: {
1556
1780
  op: removeOp,
@@ -1559,20 +1783,18 @@ let SheetsDrawingGroupCopyPasteController = class SheetsDrawingGroupCopyPasteCon
1559
1783
  objects,
1560
1784
  type: _univerjs_sheets_drawing.DrawingApplyType.REMOVE
1561
1785
  }
1562
- }];
1563
- const featureMutations = this._getGroupFeaturePasteMutations({
1564
- fromUnitId: this._copyInfo.unitId,
1565
- fromSubUnitId: this._copyInfo.subUnitId,
1566
- toUnitId: unitId,
1567
- toSubUnitId: subUnitId,
1568
- idMap,
1569
- cloned
1570
- });
1571
- redos.push(...featureMutations.redos);
1572
- undos.push(...featureMutations.undos);
1786
+ };
1573
1787
  return {
1574
- redos,
1575
- undos
1788
+ redos: [
1789
+ ...beforeDrawingMutations.redos,
1790
+ drawingRedo,
1791
+ ...afterDrawingMutations.redos
1792
+ ],
1793
+ undos: [
1794
+ drawingUndo,
1795
+ ...beforeDrawingMutations.undos,
1796
+ ...afterDrawingMutations.undos
1797
+ ]
1576
1798
  };
1577
1799
  }
1578
1800
  dispose() {
@@ -2307,7 +2529,8 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2307
2529
  });
2308
2530
  previewSubscription && disposableCollection.add(previewSubscription);
2309
2531
  }
2310
- const position$ = new rxjs.BehaviorSubject(calcSheetFloatDomPosition(rect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet));
2532
+ const initPosition = calcSheetFloatDomPosition(rect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet);
2533
+ const position$ = new rxjs.BehaviorSubject(initPosition);
2311
2534
  const domId = `${SHEET_FLOAT_DOM_PREFIX}${(0, _univerjs_core.generateRandomId)(6)}`;
2312
2535
  const shouldAutoMountRuntime = shouldAutoMountFloatDomRuntime(floatDomParam);
2313
2536
  const shouldSyncEmbedRuntimeStage = isEmbedFloatDomData(floatDomParam);
@@ -2613,8 +2836,10 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2613
2836
  if (renderObject && sheetDrawing.drawingType !== _univerjs_core.DrawingTypeEnum.DRAWING_CHART) {
2614
2837
  const { scene } = renderObject;
2615
2838
  const floatDomInfo = this._domLayerInfoMap.get(data.drawingId);
2616
- if (floatDomInfo === null || floatDomInfo === void 0 ? void 0 : floatDomInfo.rect) if (sheetDrawing.allowTransform === false) scene.detachTransformerFrom(floatDomInfo.rect);
2617
- else scene.attachTransformerTo(floatDomInfo.rect);
2839
+ if (floatDomInfo === null || floatDomInfo === void 0 ? void 0 : floatDomInfo.rect) {
2840
+ if (sheetDrawing.allowTransform === false) scene.detachTransformerFrom(floatDomInfo.rect);
2841
+ else scene.attachTransformerTo(floatDomInfo.rect);
2842
+ }
2618
2843
  }
2619
2844
  });
2620
2845
  }));
@@ -2848,7 +3073,8 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2848
3073
  subUnitId,
2849
3074
  id: drawingId
2850
3075
  };
2851
- const position$ = new rxjs.BehaviorSubject(calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo));
3076
+ const initedPosition = calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeletonParam.skeleton, target.worksheet, floatDomInfo);
3077
+ const position$ = new rxjs.BehaviorSubject(initedPosition);
2852
3078
  floatDomInfo.position$ = position$;
2853
3079
  let floatDomCfg = {
2854
3080
  position$,
@@ -2890,11 +3116,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
2890
3116
  top: rangePosition.absolute.top
2891
3117
  }
2892
3118
  }, domAnchor);
2893
- const newRect = new _univerjs_engine_render.Rect((0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
3119
+ const rectShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
2894
3120
  unitId,
2895
3121
  subUnitId,
2896
3122
  drawingId
2897
- }), {
3123
+ });
3124
+ const newRect = new _univerjs_engine_render.Rect(rectShapeKey, {
2898
3125
  left: calcOffsetPos.startX,
2899
3126
  top: calcOffsetPos.startY,
2900
3127
  width: domAnchor.width ?? newRangePos.width,
@@ -3023,13 +3250,14 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3023
3250
  top: rangePosition.absolute.top
3024
3251
  }
3025
3252
  }, domLayoutParam);
3026
- const domRect = new _univerjs_engine_render.Rect(rectShapeKey, {
3253
+ const headerRectConfig = {
3027
3254
  left: calcOffsetPos.startX,
3028
3255
  top: calcOffsetPos.startY,
3029
3256
  width: calcOffsetPos.width,
3030
3257
  height: calcOffsetPos.height,
3031
3258
  zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
3032
- });
3259
+ };
3260
+ const domRect = new _univerjs_engine_render.Rect(rectShapeKey, headerRectConfig);
3033
3261
  scene.addObject(domRect, _univerjs_engine_render.DRAWING_OBJECT_LAYER_INDEX);
3034
3262
  if (floatDomParam.allowTransform !== false) scene.attachTransformerTo(domRect);
3035
3263
  const disposableCollection = new _univerjs_core.DisposableCollection();
@@ -3049,7 +3277,8 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3049
3277
  domAnchor: domLayoutParam,
3050
3278
  scrollDirectionResponse: "HORIZONTAL"
3051
3279
  };
3052
- const position$ = new rxjs.BehaviorSubject(calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo));
3280
+ const initedPosition = calcSheetFloatDomPosition(domRect, renderObject.renderUnit.scene, skeleton.skeleton, target.worksheet, floatDomInfo);
3281
+ const position$ = new rxjs.BehaviorSubject(initedPosition);
3053
3282
  floatDomInfo.position$ = position$;
3054
3283
  let floatDomCfg = {
3055
3284
  position$,
@@ -3095,11 +3324,12 @@ let SheetCanvasFloatDomManagerService = _SheetCanvasFloatDomManagerService = cla
3095
3324
  top: rangePosition.absolute.top
3096
3325
  }
3097
3326
  }, domLayoutParam);
3098
- const newRect = new _univerjs_engine_render.Rect((0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
3327
+ const rectShapeKey = (0, _univerjs_drawing.getDrawingShapeKeyByDrawingSearch)({
3099
3328
  unitId,
3100
3329
  subUnitId,
3101
3330
  drawingId
3102
- }), {
3331
+ });
3332
+ const newRect = new _univerjs_engine_render.Rect(rectShapeKey, {
3103
3333
  left: calcOffsetPos.startX,
3104
3334
  top: 0,
3105
3335
  width: domLayoutParam.width,
@@ -3374,6 +3604,64 @@ function SaveCellImagesMenuFactory(accessor) {
3374
3604
  };
3375
3605
  }
3376
3606
 
3607
+ //#endregion
3608
+ //#region src/menu/worksheet-background-image.menu.ts
3609
+ const WORKSHEET_BACKGROUND_IMAGE_MENU_ID = "sheet.menu.worksheet-background-image";
3610
+ function worksheetBackgroundImagePresent$(accessor) {
3611
+ const commandService = accessor.get(_univerjs_core.ICommandService);
3612
+ const instanceService = accessor.get(_univerjs_core.IUniverInstanceService);
3613
+ return new rxjs.Observable((observer) => {
3614
+ const getValue = () => {
3615
+ const workbook = instanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
3616
+ return !!(workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet().getConfig().backgroundImage);
3617
+ };
3618
+ const disposables = new _univerjs_core.DisposableCollection();
3619
+ disposables.add(commandService.onCommandExecuted((command) => {
3620
+ if (command.id === _univerjs_sheets_drawing.SetWorksheetBackgroundImageMutation.id || command.id === _univerjs_sheets.SetWorksheetActiveOperation.id) observer.next(getValue());
3621
+ }));
3622
+ disposables.add(instanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe(() => {
3623
+ observer.next(getValue());
3624
+ }));
3625
+ observer.next(getValue());
3626
+ return () => disposables.dispose();
3627
+ });
3628
+ }
3629
+ function worksheetBackgroundImagePermissionDisabled$(accessor) {
3630
+ return (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {
3631
+ workbookTypes: [_univerjs_sheets.WorkbookEditablePermission],
3632
+ worksheetTypes: [_univerjs_sheets.WorksheetEditPermission]
3633
+ });
3634
+ }
3635
+ function WorksheetBackgroundImageMenuFactory(accessor) {
3636
+ return {
3637
+ id: WORKSHEET_BACKGROUND_IMAGE_MENU_ID,
3638
+ type: _univerjs_ui.MenuItemType.SUBITEMS,
3639
+ icon: "AddImageIcon",
3640
+ tooltip: "sheets-drawing-ui.backgroundImage.title",
3641
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
3642
+ disabled$: worksheetBackgroundImagePermissionDisabled$(accessor)
3643
+ };
3644
+ }
3645
+ function AddWorksheetBackgroundImageMenuFactory(accessor) {
3646
+ return {
3647
+ id: AddWorksheetBackgroundImageCommand.id,
3648
+ type: _univerjs_ui.MenuItemType.BUTTON,
3649
+ title: "sheets-drawing-ui.backgroundImage.add",
3650
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
3651
+ disabled$: worksheetBackgroundImagePermissionDisabled$(accessor)
3652
+ };
3653
+ }
3654
+ function DeleteWorksheetBackgroundImageMenuFactory(accessor) {
3655
+ const permissionDisabled$ = worksheetBackgroundImagePermissionDisabled$(accessor);
3656
+ return {
3657
+ id: DeleteWorksheetBackgroundImageCommand.id,
3658
+ type: _univerjs_ui.MenuItemType.BUTTON,
3659
+ title: "sheets-drawing-ui.backgroundImage.delete",
3660
+ hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
3661
+ disabled$: (0, rxjs.combineLatest)([permissionDisabled$, worksheetBackgroundImagePresent$(accessor)]).pipe((0, rxjs.map)(([permissionDisabled, present]) => permissionDisabled || !present))
3662
+ };
3663
+ }
3664
+
3377
3665
  //#endregion
3378
3666
  //#region src/menu/schema.ts
3379
3667
  const menuSchema = {
@@ -3395,6 +3683,24 @@ const menuSchema = {
3395
3683
  menuItemFactory: UploadCellImageMenuFactory
3396
3684
  }
3397
3685
  } },
3686
+ [_univerjs_ui.RibbonPosition.VIEW]: { [_univerjs_ui.RibbonViewGroup.DISPLAY]: { [WORKSHEET_BACKGROUND_IMAGE_MENU_ID]: {
3687
+ order: .5,
3688
+ gridLayout: {
3689
+ row: 1,
3690
+ column: 2,
3691
+ rowSpan: 2,
3692
+ showLabel: true
3693
+ },
3694
+ menuItemFactory: WorksheetBackgroundImageMenuFactory,
3695
+ [AddWorksheetBackgroundImageCommand.id]: {
3696
+ order: 0,
3697
+ menuItemFactory: AddWorksheetBackgroundImageMenuFactory
3698
+ },
3699
+ [DeleteWorksheetBackgroundImageCommand.id]: {
3700
+ order: 1,
3701
+ menuItemFactory: DeleteWorksheetBackgroundImageMenuFactory
3702
+ }
3703
+ } } },
3398
3704
  [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: { [SaveCellImagesCommand.id]: {
3399
3705
  order: 10,
3400
3706
  menuItemFactory: SaveCellImagesMenuFactory
@@ -3412,7 +3718,7 @@ const menuSchema = {
3412
3718
  //#endregion
3413
3719
  //#region package.json
3414
3720
  var name = "@univerjs/sheets-drawing-ui";
3415
- var version = "1.0.0-rc.0";
3721
+ var version = "1.0.0";
3416
3722
 
3417
3723
  //#endregion
3418
3724
  //#region src/config/config.ts
@@ -3517,7 +3823,7 @@ function BatchSaveImagesDialog({ SelectComponent = _univerjs_design.Select } = {
3517
3823
  }));
3518
3824
  }, [dataColumns]);
3519
3825
  const [selectedColumn, setSelectedColumn] = (0, react.useState)(() => columnOptions.length > 0 ? columnOptions[0].value : "0");
3520
- (0, _univerjs_sheets_ui.useHighlightRange)((0, react.useMemo)(() => {
3826
+ const highlightRanges = (0, react.useMemo)(() => {
3521
3827
  if (!fileNameParts.includes("columnValue") || !rowRange) return [];
3522
3828
  const colIndex = Number(selectedColumn);
3523
3829
  return [{
@@ -3530,7 +3836,8 @@ function BatchSaveImagesDialog({ SelectComponent = _univerjs_design.Select } = {
3530
3836
  fileNameParts,
3531
3837
  selectedColumn,
3532
3838
  rowRange
3533
- ]));
3839
+ ]);
3840
+ (0, _univerjs_sheets_ui.useHighlightRange)(highlightRanges);
3534
3841
  const handleFileNamePartsChange = (0, react.useCallback)((value) => {
3535
3842
  if (value.length === 0) return;
3536
3843
  setFileNameParts(value);
@@ -3655,7 +3962,8 @@ const SheetDrawingAnchor = (props) => {
3655
3962
  const scene = renderObject === null || renderObject === void 0 ? void 0 : renderObject.scene;
3656
3963
  const transformer = scene === null || scene === void 0 ? void 0 : scene.getTransformerByCreate();
3657
3964
  const [anchorShow, setAnchorShow] = (0, react.useState)(true);
3658
- const [value, setValue] = (0, react.useState)(drawingParam ? (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(drawingParam).kind : _univerjs_sheets_drawing.SheetDrawingAnchorType.Position);
3965
+ const type = drawingParam ? (0, _univerjs_sheets_drawing.getSheetDrawingPlacement)(drawingParam).kind : _univerjs_sheets_drawing.SheetDrawingAnchorType.Position;
3966
+ const [value, setValue] = (0, react.useState)(type);
3659
3967
  function getUpdateParams(objects, drawingManagerService) {
3660
3968
  const params = [];
3661
3969
  objects.forEach((object) => {
@@ -3937,6 +4245,70 @@ SheetsDrawingRenderController = __decorate([
3937
4245
  __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetSkeletonService))
3938
4246
  ], SheetsDrawingRenderController);
3939
4247
 
4248
+ //#endregion
4249
+ //#region src/views/background/worksheet-background-image.extension.ts
4250
+ const WORKSHEET_BACKGROUND_IMAGE_EXTENSION_KEY = "WorksheetBackgroundImageExtension";
4251
+ var WorksheetBackgroundImageExtension = class extends _univerjs_engine_render.SheetExtension {
4252
+ constructor(injector, _requestRender) {
4253
+ super();
4254
+ this._requestRender = _requestRender;
4255
+ _defineProperty(this, "uKey", WORKSHEET_BACKGROUND_IMAGE_EXTENSION_KEY);
4256
+ _defineProperty(this, "type", _univerjs_engine_render.SHEET_EXTENSION_TYPE.BACKGROUND);
4257
+ _defineProperty(this, "_imageCache", void 0);
4258
+ this._imageCache = new _univerjs_core.ImageCacheMap(injector);
4259
+ }
4260
+ draw(ctx, _parentScale, spreadsheetSkeleton, diffRanges, drawInfo) {
4261
+ const backgroundImage = spreadsheetSkeleton.worksheet.getConfig().backgroundImage;
4262
+ if (!backgroundImage) return;
4263
+ const image = this._imageCache.getImage(backgroundImage.imageSourceType, backgroundImage.source, this._requestRender, this._requestRender);
4264
+ if (!image || !image.complete || image.naturalWidth === 0 || image.getAttribute("data-error")) return;
4265
+ const pattern = ctx.createPattern(image, "repeat");
4266
+ if (!pattern) return;
4267
+ const scaleX = backgroundImage.scaleX ?? 1;
4268
+ const scaleY = backgroundImage.scaleY ?? 1;
4269
+ if (scaleX !== 1 || scaleY !== 1) pattern.setTransform({
4270
+ a: scaleX,
4271
+ d: scaleY
4272
+ });
4273
+ const ranges = diffRanges.length > 0 ? diffRanges : drawInfo.viewRanges;
4274
+ const { columnWidthAccumulation, rowHeightAccumulation } = spreadsheetSkeleton;
4275
+ if (!columnWidthAccumulation || !rowHeightAccumulation) return;
4276
+ ctx.save();
4277
+ ctx.fillStyle = pattern;
4278
+ ranges.forEach((range) => {
4279
+ const startX = range.startColumn > 0 ? columnWidthAccumulation[range.startColumn - 1] : 0;
4280
+ const startY = range.startRow > 0 ? rowHeightAccumulation[range.startRow - 1] : 0;
4281
+ const endX = columnWidthAccumulation[range.endColumn];
4282
+ const endY = rowHeightAccumulation[range.endRow];
4283
+ if (endX != null && endY != null) ctx.fillRect(startX, startY, endX - startX, endY - startY);
4284
+ });
4285
+ ctx.restore();
4286
+ }
4287
+ };
4288
+
4289
+ //#endregion
4290
+ //#region src/controllers/render-controllers/worksheet-background.render-controller.ts
4291
+ let WorksheetBackgroundRenderController = class WorksheetBackgroundRenderController extends _univerjs_core.Disposable {
4292
+ constructor(_context, commandService, injector) {
4293
+ super();
4294
+ this._context = _context;
4295
+ const spreadsheet = this._context.mainComponent;
4296
+ const extension = new WorksheetBackgroundImageExtension(injector, () => {
4297
+ spreadsheet.makeForceDirty(true);
4298
+ this._context.scene.makeDirty();
4299
+ });
4300
+ this.disposeWithMe(spreadsheet.register(extension));
4301
+ this.disposeWithMe(commandService.onCommandExecuted((command) => {
4302
+ const params = command.params;
4303
+ if (command.id === _univerjs_sheets_drawing.SetWorksheetBackgroundImageMutation.id && (params === null || params === void 0 ? void 0 : params.unitId) === this._context.unitId) {
4304
+ spreadsheet.makeForceDirty(true);
4305
+ this._context.scene.makeDirty();
4306
+ }
4307
+ }));
4308
+ }
4309
+ };
4310
+ WorksheetBackgroundRenderController = __decorate([__decorateParam(1, _univerjs_core.ICommandService), __decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], WorksheetBackgroundRenderController);
4311
+
3940
4312
  //#endregion
3941
4313
  //#region src/controllers/sheet-cell-image.controller.ts
3942
4314
  function resizeImageByCell(injector, location, cell) {
@@ -4253,7 +4625,7 @@ const specialPastes = [
4253
4625
  _univerjs_sheets_ui.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,
4254
4626
  _univerjs_sheets_ui.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA
4255
4627
  ];
4256
- let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController extends _univerjs_core.Disposable {
4628
+ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController extends _univerjs_core.RxDisposable {
4257
4629
  constructor(_sheetClipboardService, _renderManagerService, _sheetSkeletonService, _drawingService, _clipboardInterfaceService, _commandService) {
4258
4630
  super();
4259
4631
  this._sheetClipboardService = _sheetClipboardService;
@@ -4269,7 +4641,7 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
4269
4641
  return this._drawingService.getFocusDrawings();
4270
4642
  }
4271
4643
  _initCopyPaste() {
4272
- this._sheetClipboardService.addClipboardHook({
4644
+ this.disposeWithMe(this._sheetClipboardService.addClipboardHook({
4273
4645
  id: "SHEET_IMAGE_UI_PLUGIN",
4274
4646
  onBeforeCopyFocusedObject: (unitId, _subUnitId, copyType) => {
4275
4647
  this._copyInfo = null;
@@ -4283,12 +4655,12 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
4283
4655
  };
4284
4656
  this._commandService.executeCommand(_univerjs_sheets_drawing.RemoveSheetDrawingCommand.id, params);
4285
4657
  }
4286
- setTimeout(() => {
4658
+ (0, rxjs.timer)(200).pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe(() => {
4287
4659
  const dispose = focusDocument();
4288
4660
  if (drawing.drawingType === _univerjs_core.DrawingTypeEnum.DRAWING_IMAGE && drawing.imageSourceType === _univerjs_core.ImageSourceType.BASE64) copyBase64ToClipboard(drawing.source);
4289
4661
  else this._clipboardInterfaceService.writeText("");
4290
4662
  dispose();
4291
- }, 200);
4663
+ });
4292
4664
  this._copyInfo = {
4293
4665
  unitId: drawing.unitId,
4294
4666
  subUnitId: drawing.subUnitId,
@@ -4373,7 +4745,7 @@ let SheetsDrawingCopyPasteController = class SheetsDrawingCopyPasteController ex
4373
4745
  redos: []
4374
4746
  };
4375
4747
  }
4376
- });
4748
+ }));
4377
4749
  }
4378
4750
  _createDrawingsCopyInfoByRange(unitId, subUnitId, range) {
4379
4751
  const skeleton = this._sheetSkeletonService.getSkeleton(unitId, subUnitId);
@@ -4900,18 +5272,19 @@ function createPrintingFloatDom(info, scene, skeleton, worksheet) {
4900
5272
  }
4901
5273
  const PrintingFloatDom = (props) => {
4902
5274
  const { floatDomInfos, scene, skeleton, worksheet } = props;
5275
+ const floatDomParams = (0, react.useMemo)(() => floatDomInfos.map((info) => createPrintingFloatDom(info, scene, skeleton, worksheet)), [
5276
+ floatDomInfos,
5277
+ scene,
5278
+ skeleton,
5279
+ worksheet
5280
+ ]);
4903
5281
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4904
5282
  style: {
4905
5283
  position: "absolute",
4906
5284
  top: 0,
4907
5285
  left: 0
4908
5286
  },
4909
- children: (0, react.useMemo)(() => floatDomInfos.map((info) => createPrintingFloatDom(info, scene, skeleton, worksheet)), [
4910
- floatDomInfos,
4911
- scene,
4912
- skeleton,
4913
- worksheet
4914
- ]).map(([id, floatDom]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.PrintFloatDomSingle, {
5287
+ children: floatDomParams.map(([id, floatDom]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.PrintFloatDomSingle, {
4915
5288
  layer: floatDom,
4916
5289
  id,
4917
5290
  position: floatDom.position
@@ -4919,7 +5292,8 @@ const PrintingFloatDom = (props) => {
4919
5292
  });
4920
5293
  };
4921
5294
  function mountPrintingFloatDom(props, root, injector) {
4922
- (0, _univerjs_design.render)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)((0, _univerjs_ui.connectInjector)(PrintingFloatDom, injector), { ...props }), root);
5295
+ const PrintingFloatDomInjector = (0, _univerjs_ui.connectInjector)(PrintingFloatDom, injector);
5296
+ (0, _univerjs_design.render)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PrintingFloatDomInjector, { ...props }), root);
4923
5297
  return () => (0, _univerjs_design.unmount)(root);
4924
5298
  }
4925
5299
 
@@ -5237,9 +5611,8 @@ const DeleteDrawingsShortcutItem = {
5237
5611
  * limitations under the License.
5238
5612
  */
5239
5613
  let SheetDrawingUIController = class SheetDrawingUIController extends _univerjs_core.Disposable {
5240
- constructor(_menuManagerService, _commandService, _shortcutService, _drawingManagerService, _sidebarService) {
5614
+ constructor(_commandService, _shortcutService, _drawingManagerService, _sidebarService) {
5241
5615
  super();
5242
- this._menuManagerService = _menuManagerService;
5243
5616
  this._commandService = _commandService;
5244
5617
  this._shortcutService = _shortcutService;
5245
5618
  this._drawingManagerService = _drawingManagerService;
@@ -5247,13 +5620,12 @@ let SheetDrawingUIController = class SheetDrawingUIController extends _univerjs_
5247
5620
  this._init();
5248
5621
  }
5249
5622
  _initCustomComponents() {}
5250
- _initMenus() {
5251
- this._menuManagerService.mergeMenu(menuSchema);
5252
- }
5253
5623
  _initCommands() {
5254
5624
  [
5255
5625
  InsertFloatImageCommand,
5256
5626
  InsertCellImageCommand,
5627
+ AddWorksheetBackgroundImageCommand,
5628
+ DeleteWorksheetBackgroundImageCommand,
5257
5629
  SidebarSheetDrawingOperation,
5258
5630
  EditSheetDrawingOperation,
5259
5631
  GroupSheetDrawingCommand,
@@ -5285,17 +5657,15 @@ let SheetDrawingUIController = class SheetDrawingUIController extends _univerjs_
5285
5657
  _init() {
5286
5658
  this._initCommands();
5287
5659
  this._initCustomComponents();
5288
- this._initMenus();
5289
5660
  this._initShortcuts();
5290
5661
  this._initImagePanel();
5291
5662
  }
5292
5663
  };
5293
5664
  SheetDrawingUIController = __decorate([
5294
- __decorateParam(0, _univerjs_ui.IMenuManagerService),
5295
- __decorateParam(1, _univerjs_core.ICommandService),
5296
- __decorateParam(2, _univerjs_ui.IShortcutService),
5297
- __decorateParam(3, _univerjs_drawing.IDrawingManagerService),
5298
- __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))
5665
+ __decorateParam(0, _univerjs_core.ICommandService),
5666
+ __decorateParam(1, _univerjs_ui.IShortcutService),
5667
+ __decorateParam(2, _univerjs_drawing.IDrawingManagerService),
5668
+ __decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_ui.ISidebarService))
5299
5669
  ], SheetDrawingUIController);
5300
5670
 
5301
5671
  //#endregion
@@ -5577,6 +5947,72 @@ MobileDrawingPopupMenuController = __decorate([
5577
5947
  __decorateParam(11, _univerjs_ui.ILayoutService)
5578
5948
  ], MobileDrawingPopupMenuController);
5579
5949
 
5950
+ //#endregion
5951
+ //#region src/menu/mobile-schema.ts
5952
+ const mobileMenuSchema = {
5953
+ [_univerjs_ui.RibbonInsertGroup.MEDIA]: { [SHEETS_IMAGE_MENU_ID]: {
5954
+ order: 0,
5955
+ menuItemFactory: ImageMenuFactory,
5956
+ [InsertFloatImageCommand.id]: {
5957
+ order: 0,
5958
+ menuItemFactory: UploadFloatImageMenuFactory
5959
+ },
5960
+ [InsertCellImageCommand.id]: {
5961
+ order: 1,
5962
+ menuItemFactory: UploadCellImageMenuFactory
5963
+ }
5964
+ } },
5965
+ [_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [WORKSHEET_BACKGROUND_IMAGE_MENU_ID]: {
5966
+ order: 22,
5967
+ menuItemFactory: WorksheetBackgroundImageMenuFactory,
5968
+ [AddWorksheetBackgroundImageCommand.id]: {
5969
+ order: 0,
5970
+ menuItemFactory: AddWorksheetBackgroundImageMenuFactory
5971
+ },
5972
+ [DeleteWorksheetBackgroundImageCommand.id]: {
5973
+ order: 1,
5974
+ menuItemFactory: DeleteWorksheetBackgroundImageMenuFactory
5975
+ }
5976
+ } },
5977
+ [_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: { [SaveCellImagesCommand.id]: {
5978
+ order: 10,
5979
+ menuItemFactory: SaveCellImagesMenuFactory
5980
+ } } },
5981
+ [_univerjs_ui.ContextMenuPosition.COL_HEADER]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: { [SaveCellImagesCommand.id]: {
5982
+ order: 10,
5983
+ menuItemFactory: SaveCellImagesMenuFactory
5984
+ } } },
5985
+ [_univerjs_ui.ContextMenuPosition.ROW_HEADER]: { [_univerjs_ui.ContextMenuGroup.OTHERS]: { [SaveCellImagesCommand.id]: {
5986
+ order: 10,
5987
+ menuItemFactory: SaveCellImagesMenuFactory
5988
+ } } }
5989
+ };
5990
+
5991
+ //#endregion
5992
+ //#region src/menu/mobile-sheet-drawing-menu.controller.ts
5993
+ /**
5994
+ * Copyright 2023-present DreamNum Co., Ltd.
5995
+ *
5996
+ * Licensed under the Apache License, Version 2.0 (the "License");
5997
+ * you may not use this file except in compliance with the License.
5998
+ * You may obtain a copy of the License at
5999
+ *
6000
+ * http://www.apache.org/licenses/LICENSE-2.0
6001
+ *
6002
+ * Unless required by applicable law or agreed to in writing, software
6003
+ * distributed under the License is distributed on an "AS IS" BASIS,
6004
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6005
+ * See the License for the specific language governing permissions and
6006
+ * limitations under the License.
6007
+ */
6008
+ let MobileSheetDrawingMenuController = class MobileSheetDrawingMenuController extends _univerjs_core.Disposable {
6009
+ constructor(menuManagerService) {
6010
+ super();
6011
+ menuManagerService.mergeMenu(mobileMenuSchema);
6012
+ }
6013
+ };
6014
+ MobileSheetDrawingMenuController = __decorate([__decorateParam(0, _univerjs_ui.IMenuManagerService)], MobileSheetDrawingMenuController);
6015
+
5580
6016
  //#endregion
5581
6017
  //#region src/services/sheet-drawing-hit-test.service.ts
5582
6018
  let SheetDrawingHitTestService = class SheetDrawingHitTestService extends _univerjs_core.Disposable {
@@ -5707,6 +6143,7 @@ let UniverSheetsDrawingMobileUIPlugin = class UniverSheetsDrawingMobileUIPlugin
5707
6143
  [SheetCanvasFloatDomManagerService],
5708
6144
  [SheetDrawingHitTestService],
5709
6145
  [SheetDrawingUIController],
6146
+ [MobileSheetDrawingMenuController],
5710
6147
  [MobileDrawingPopupMenuController],
5711
6148
  [SheetDrawingPrintingController],
5712
6149
  [SheetDrawingPermissionController],
@@ -5736,6 +6173,7 @@ let UniverSheetsDrawingMobileUIPlugin = class UniverSheetsDrawingMobileUIPlugin
5736
6173
  [SheetDrawingPermissionController],
5737
6174
  [SheetDrawingPrintingController],
5738
6175
  [SheetDrawingUIController],
6176
+ [MobileSheetDrawingMenuController],
5739
6177
  [SheetCellImageController],
5740
6178
  [SheetCellImageAutofillController]
5741
6179
  ]);
@@ -5749,7 +6187,8 @@ let UniverSheetsDrawingMobileUIPlugin = class UniverSheetsDrawingMobileUIPlugin
5749
6187
  [SheetDrawingUpdateController],
5750
6188
  [SheetDrawingActiveRenderController],
5751
6189
  [SheetsDrawingRenderController],
5752
- [SheetCellImageHoverRenderController]
6190
+ [SheetCellImageHoverRenderController],
6191
+ [WorksheetBackgroundRenderController]
5753
6192
  ].forEach((module) => {
5754
6193
  this.disposeWithMe(this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET, module));
5755
6194
  });
@@ -6006,6 +6445,31 @@ DrawingPopupMenuController = __decorate([
6006
6445
  __decorateParam(9, _univerjs_core.ICommandService)
6007
6446
  ], DrawingPopupMenuController);
6008
6447
 
6448
+ //#endregion
6449
+ //#region src/menu/sheet-drawing-menu.controller.ts
6450
+ /**
6451
+ * Copyright 2023-present DreamNum Co., Ltd.
6452
+ *
6453
+ * Licensed under the Apache License, Version 2.0 (the "License");
6454
+ * you may not use this file except in compliance with the License.
6455
+ * You may obtain a copy of the License at
6456
+ *
6457
+ * http://www.apache.org/licenses/LICENSE-2.0
6458
+ *
6459
+ * Unless required by applicable law or agreed to in writing, software
6460
+ * distributed under the License is distributed on an "AS IS" BASIS,
6461
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6462
+ * See the License for the specific language governing permissions and
6463
+ * limitations under the License.
6464
+ */
6465
+ let SheetDrawingMenuController = class SheetDrawingMenuController extends _univerjs_core.Disposable {
6466
+ constructor(menuManagerService) {
6467
+ super();
6468
+ menuManagerService.mergeMenu(menuSchema);
6469
+ }
6470
+ };
6471
+ SheetDrawingMenuController = __decorate([__decorateParam(0, _univerjs_ui.IMenuManagerService)], SheetDrawingMenuController);
6472
+
6009
6473
  //#endregion
6010
6474
  //#region src/plugin.ts
6011
6475
  let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends _univerjs_core.Plugin {
@@ -6025,6 +6489,7 @@ let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends _uni
6025
6489
  [SheetCanvasFloatDomManagerService],
6026
6490
  [SheetDrawingHitTestService],
6027
6491
  [SheetDrawingUIController],
6492
+ [SheetDrawingMenuController],
6028
6493
  [DrawingPopupMenuController],
6029
6494
  [SheetDrawingPrintingController],
6030
6495
  [SheetDrawingPermissionController],
@@ -6053,6 +6518,7 @@ let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends _uni
6053
6518
  [SheetDrawingPermissionController],
6054
6519
  [SheetDrawingPrintingController],
6055
6520
  [SheetDrawingUIController],
6521
+ [SheetDrawingMenuController],
6056
6522
  [SheetCellImageController],
6057
6523
  [SheetCellImageAutofillController]
6058
6524
  ]);
@@ -6066,7 +6532,8 @@ let UniverSheetsDrawingUIPlugin = class UniverSheetsDrawingUIPlugin extends _uni
6066
6532
  [SheetDrawingUpdateController],
6067
6533
  [SheetDrawingActiveRenderController],
6068
6534
  [SheetsDrawingRenderController],
6069
- [SheetCellImageHoverRenderController]
6535
+ [SheetCellImageHoverRenderController],
6536
+ [WorksheetBackgroundRenderController]
6070
6537
  ].forEach((m) => {
6071
6538
  this.disposeWithMe(this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET, m));
6072
6539
  });
@@ -6084,6 +6551,7 @@ UniverSheetsDrawingUIPlugin = __decorate([
6084
6551
  ], UniverSheetsDrawingUIPlugin);
6085
6552
 
6086
6553
  //#endregion
6554
+ exports.AddWorksheetBackgroundImageCommand = AddWorksheetBackgroundImageCommand;
6087
6555
  Object.defineProperty(exports, 'BatchSaveImagesService', {
6088
6556
  enumerable: true,
6089
6557
  get: function () {
@@ -6091,6 +6559,7 @@ Object.defineProperty(exports, 'BatchSaveImagesService', {
6091
6559
  }
6092
6560
  });
6093
6561
  exports.DeleteDrawingsCommand = DeleteDrawingsCommand;
6562
+ exports.DeleteWorksheetBackgroundImageCommand = DeleteWorksheetBackgroundImageCommand;
6094
6563
  exports.DrawingContextMenuService = DrawingContextMenuService;
6095
6564
  exports.EditSheetDrawingOperation = EditSheetDrawingOperation;
6096
6565
  exports.FileNamePart = FileNamePart;