Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat: support drawing object list metadata (#7195)
Univerf58a5372b46e
diff --git a/packages/core/src/types/interfaces/i-document-data.ts b/packages/core/src/types/interfaces/i-document-data.tsindex db82b75489..60524928f3 100644--- a/packages/core/src/types/interfaces/i-document-data.ts+++ b/packages/core/src/types/interfaces/i-document-data.ts@@ -669,9 +669,9 @@ export interface IBullet {export interface IDocDrawingBase extends IDrawingParam {drawingId: string;- title: string;+ title?: string;- description: string;+ description?: string;// embeddedObjectBorder?: IDocsBorder;diff --git a/packages/core/src/types/interfaces/i-drawing.ts b/packages/core/src/types/interfaces/i-drawing.tsindex 09268b4295..1611dc45a6 100644--- a/packages/core/src/types/interfaces/i-drawing.ts+++ b/packages/core/src/types/interfaces/i-drawing.ts@@ -115,6 +115,19 @@ export interface ITransformStateDisableOption {export interface ITransformState extends IAbsoluteTransform, IRotationSkewFlipTransform, ITransformStateDisableOption { }+export interface IDrawingObjectLocks {+ /**+ * Prevent selecting the drawing directly from the canvas. Layer/object panels may still select it for management.+ */+ noSelect?: boolean;+ noMove?: boolean;+ noResize?: boolean;+ noRotate?: boolean;+ noTextEdit?: boolean;+ noEditPoints?: boolean;+ noChangeAspect?: boolean;+}+export interface IDrawingParam extends IDrawingSearch {drawingType: DrawingType;transform?: Nullable<ITransformState>;@@ -133,6 +146,14 @@ export interface IDrawingParam extends IDrawingSearch {* The drawing element is hidden when render*/hidden?: boolean;+ name?: string;+ description?: string;+ /**+ * Compatibility shortcut for whether the drawing can be selected from the canvas.+ * Prefer locks.noSelect for fine-grained behavior when available.+ */+ selectable?: boolean;+ locks?: IDrawingObjectLocks;}/**diff --git a/packages/docs-drawing-ui/src/controllers/doc-drawing-notification.controller.ts b/packages/docs-drawing-ui/src/controllers/doc-drawing-notification.controller.tsindex ed256e078e..a6257b508e 100644--- a/packages/docs-drawing-ui/src/controllers/doc-drawing-notification.controller.ts+++ b/packages/docs-drawing-ui/src/controllers/doc-drawing-notification.controller.ts@@ -19,7 +19,7 @@import type { DocumentDataModel, ICommandInfo, IDrawingSearch, JSONXActions, Nullable } from '@univerjs/core';import type { IRichTextEditingMutationParams } from '@univerjs/docs';import type { IDocDrawing } from '@univerjs/docs-drawing';-import type { IDrawingJsonUndo1, IDrawingOrderMapParam } from '@univerjs/drawing';+import type { IDrawingJsonUndo1, IDrawingMapItemData, IDrawingOrderMapParam } from '@univerjs/drawing';import {Disposable,ICommandService,@@ -117,6 +117,35 @@ function getReOrderedDrawings(actions: JSONXActions): number[] {return drawingIndexes;}+function collectUpdatedDrawingIds(actions: JSONXActions, drawingIds = new Set<string>()): Set<string> {+ if (JSONX.isNoop(actions) || !Array.isArray(actions)) {+ return drawingIds;+ }++ if (actions[0] === 'drawings') {+ const drawingKeyOrOps = actions[1];+ if (typeof drawingKeyOrOps === 'string') {+ drawingIds.add(drawingKeyOrOps);+ return drawingIds;+ }++ actions.slice(1).forEach((action) => {+ if (Array.isArray(action) && typeof action[0] === 'string') {+ drawingIds.add(action[0]);+ }+ });+ return drawingIds;+ }++ actions.forEach((action) => {+ if (Array.isArray(action)) {+ collectUpdatedDrawingIds(action as JSONXActions, drawingIds);+ }+ });++ return drawingIds;+}+export class DocDrawingAddRemoveController extends Disposable {constructor(@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,@@ -174,6 +203,11 @@ export class DocDrawingAddRemoveController extends Disposable {if (reOrderedDrawings.length > 0) {this._updateDrawingsOrder(unitId);}++ const updatedDrawingIds = [...collectUpdatedDrawingIds(actions)];+ if (updatedDrawingIds.length > 0) {+ this._syncDrawingDataFromSnapshot(unitId, updatedDrawingIds);+ }}));@@ -272,4 +306,32 @@ export class DocDrawingAddRemoveController extends Disposable {drawingIds: drawingsOrder,});}++ private _syncDrawingDataFromSnapshot(unitId: string, drawingIds: string[]) {+ const documentDataModel = this._univerInstanceService.getUnit<DocumentDataModel>(unitId, UniverInstanceType.UNIVER_DOC);++ if (documentDataModel == null) {+ return;+ }++ const { drawings = {}, drawingsOrder = [] } = documentDataModel.getSnapshot();+ const drawingData = drawings as IDrawingMapItemData<IDocDrawing>;+ const renderOrder = getDocDrawingRenderOrder(drawingsOrder, drawings);++ this._docDrawingService.setDrawingData(unitId, unitId, drawingData);+ this._drawingManagerService.setDrawingData(unitId, unitId, drawingData);+ this._docDrawingService.setDrawingOrder(unitId, unitId, drawingsOrder);+ this._drawingManagerService.setDrawingOrder(unitId, unitId, renderOrder);++ const objects = drawingIds+ .filter((drawingId) => drawingData[drawingId] != null)+ .map((drawingId) => ({ unitId, subUnitId: unitId, drawingId }));++ if (objects.length === 0) {+ return;+ }++ this._docDrawingService.updateNotification(objects);+ this._drawingManagerService.updateNotification(objects);+ }}diff --git a/packages/docs-drawing-ui/src/index.ts b/packages/docs-drawing-ui/src/index.tsindex 6fdd5d1fbd..0d6c8064a4 100644--- a/packages/docs-drawing-ui/src/index.ts+++ b/packages/docs-drawing-ui/src/index.ts@@ -35,3 +35,5 @@ export { DOCS_SHAPE_BELOW_MENU_ID, DOCS_SHAPE_MENU_ID } from './menu/shape.menu'export { UniverDocsDrawingUIPlugin } from './plugin';export { DocDrawingPosition } from './views/doc-image-panel/DocDrawingPosition';export { DocDrawingTextWrap } from './views/doc-image-panel/DocDrawingTextWrap';+export { IDocDrawingService } from '@univerjs/docs-drawing';+export type { IDocDrawing } from '@univerjs/docs-drawing';diff --git a/packages/drawing-ui/src/index.ts b/packages/drawing-ui/src/index.tsindex 2cf656321e..995cc4dc6c 100644--- a/packages/drawing-ui/src/index.ts+++ b/packages/drawing-ui/src/index.ts@@ -45,4 +45,26 @@ export { DrawingRenderService } from './services/drawing-render.service';export { getUpdateParams } from './utils/get-update-params';export { ImageCropperObject } from './views/crop/image-cropper-object';export { COMPONENT_IMAGE_POPUP_MENU } from './views/image-popup-menu/component-name';+export {+ getObjectListPanelSectionIdForDrawingType,+ isFloatingObjectListDrawingType,+ OBJECT_LIST_CANVAS_SECTION_ID,+ OBJECT_LIST_FLOATING_SECTION_ID,+} from './views/object-list-panel/object-list-panel-layer';+export type { ObjectListPanelSectionId } from './views/object-list-panel/object-list-panel-layer';+export {+ DrawingObjectListPanel,+ getObjectListPanelLabels,+ getObjectListPanelTypeName,+ ObjectListPanelBase,+} from './views/object-list-panel/ObjectListPanelBase';+export type {+ IDrawingObjectListItem,+ IDrawingObjectListPanelLabels,+ IDrawingObjectListPanelProps,+ IObjectListPanelBaseProps,+ IObjectListPanelItem,+ IObjectListPanelLabels,+ ObjectListPanelTypeNameKey,+} from './views/object-list-panel/ObjectListPanelBase';export { DrawingCommonPanel } from './views/panel/DrawingCommonPanel';diff --git a/packages/drawing-ui/src/locale/ar-SA.ts b/packages/drawing-ui/src/locale/ar-SA.tsindex 8a42346685..058a0f3a4f 100644--- a/packages/drawing-ui/src/locale/ar-SA.ts+++ b/packages/drawing-ui/src/locale/ar-SA.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'لا يمكن قص الكائنات غير الصورية.',},+ objectListPanel: {+ title: 'الكائنات',+ empty: 'لا توجد كائنات',+ showAll: 'إظهار الكل',+ hideAll: 'إخفاء الكل',+ moveForward: 'إحضار للأمام',+ moveBackward: 'إرسال للخلف',+ close: 'إغلاق',+ show: 'إظهار',+ hide: 'إخفاء',+ lock: 'قفل',+ unlock: 'إلغاء القفل',+ name: 'الاسم',+ nameInput: 'اسم الكائن',+ description: 'الوصف',+ descriptionPlaceholder: 'إضافة وصف',+ details: 'التفاصيل',+ locate: 'تحديد الموضع',+ expand: 'توسيع',+ collapse: 'طي',+ dragToReorder: 'اسحب لإعادة الترتيب',+ search: 'بحث',+ filterAll: 'الكل',+ filterHidden: 'المخفية',+ filterLocked: 'المقفلة',+ sectionCanvas: 'طبقة اللوحة',+ sectionFloating: 'الطبقة العائمة',+ typeNames: {+ object: 'كائن',+ shape: 'شكل',+ connector: 'موصل',+ image: 'صورة',+ chart: 'مخطط',+ table: 'جدول',+ smartArt: 'SmartArt',+ video: 'فيديو',+ group: 'مجموعة',+ unit: 'وحدة',+ dom: 'DOM',+ text: 'نص',+ placeholder: 'عنصر نائب',+ container: 'حاوية',+ },+ noSelection: 'حدد كائنا لتحرير تفاصيله',+ },'image-panel': {arrange: {title: 'ترتيب',diff --git a/packages/drawing-ui/src/locale/ca-ES.ts b/packages/drawing-ui/src/locale/ca-ES.tsindex 8c94e989a3..5f5a9c74ce 100644--- a/packages/drawing-ui/src/locale/ca-ES.ts+++ b/packages/drawing-ui/src/locale/ca-ES.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'No es poden retallar objectes que no siguin imatges.',},+ objectListPanel: {+ title: 'Objectes',+ empty: 'Sense objectes',+ showAll: 'Mostra-ho tot',+ hideAll: 'Amaga-ho tot',+ moveForward: 'Porta endavant',+ moveBackward: 'Envia enrere',+ close: 'Tanca',+ show: 'Mostra',+ hide: 'Amaga',+ lock: 'Bloqueja',+ unlock: 'Desbloqueja',+ name: 'Nom',+ nameInput: 'Nom de l\'objecte',+ description: 'Descripcio',+ descriptionPlaceholder: 'Afegeix descripcio',+ details: 'Detalls',+ locate: 'Localitza',+ expand: 'Expandeix',+ collapse: 'Replega',+ dragToReorder: 'Arrossegueu per reordenar',+ search: 'Cerca',+ filterAll: 'Tot',+ filterHidden: 'Ocults',+ filterLocked: 'Bloquejats',+ sectionCanvas: 'Capa del llenç',+ sectionFloating: 'Capa flotant',+ typeNames: {+ object: 'Objecte',+ shape: 'Forma',+ connector: 'Connector',+ image: 'Imatge',+ chart: 'Gràfic',+ table: 'Taula',+ smartArt: 'SmartArt',+ video: 'Vídeo',+ group: 'Grup',+ unit: 'Unitat',+ dom: 'DOM',+ text: 'Text',+ placeholder: 'Marcador de posició',+ container: 'Contenidor',+ },+ noSelection: 'Seleccioneu un objecte per editar-ne els detalls',+ },'image-panel': {arrange: {title: 'Organitza',diff --git a/packages/drawing-ui/src/locale/de-DE.ts b/packages/drawing-ui/src/locale/de-DE.tsindex 68a4827e40..76d9b2eb56 100644--- a/packages/drawing-ui/src/locale/de-DE.ts+++ b/packages/drawing-ui/src/locale/de-DE.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Nicht-Bildobjekte können nicht zugeschnitten werden.',},+ objectListPanel: {+ title: 'Objekte',+ empty: 'Keine Objekte',+ showAll: 'Alle anzeigen',+ hideAll: 'Alle ausblenden',+ moveForward: 'Eine Ebene nach vorne',+ moveBackward: 'Eine Ebene nach hinten',+ close: 'Schliessen',+ show: 'Anzeigen',+ hide: 'Ausblenden',+ lock: 'Sperren',+ unlock: 'Entsperren',+ name: 'Name',+ nameInput: 'Objektname',+ description: 'Beschreibung',+ descriptionPlaceholder: 'Beschreibung hinzufuegen',+ details: 'Details',+ locate: 'Suchen',+ expand: 'Erweitern',+ collapse: 'Reduzieren',+ dragToReorder: 'Zum Neuordnen ziehen',+ search: 'Suchen',+ filterAll: 'Alle',+ filterHidden: 'Ausgeblendet',+ filterLocked: 'Gesperrt',+ sectionCanvas: 'Canvas-Ebene',+ sectionFloating: 'Schwebende Ebene',+ typeNames: {+ object: 'Objekt',+ shape: 'Form',+ connector: 'Verbinder',+ image: 'Bild',+ chart: 'Diagramm',+ table: 'Tabelle',+ smartArt: 'SmartArt',+ video: 'Video',+ group: 'Gruppe',+ unit: 'Einheit',+ dom: 'DOM',+ text: 'Text',+ placeholder: 'Platzhalter',+ container: 'Container',+ },+ noSelection: 'Wählen Sie ein Objekt aus, um Details zu bearbeiten',+ },'image-panel': {arrange: {title: 'Anordnen',diff --git a/packages/drawing-ui/src/locale/en-US.ts b/packages/drawing-ui/src/locale/en-US.tsindex b3d92ee7a1..1be4eec8d0 100644--- a/packages/drawing-ui/src/locale/en-US.ts+++ b/packages/drawing-ui/src/locale/en-US.ts@@ -19,6 +19,51 @@ const locale = {'image-cropper': {error: 'Cannot crop non-image objects.',},+ objectListPanel: {+ title: 'Object list',+ empty: 'No objects',+ showAll: 'Show all',+ hideAll: 'Hide all',+ moveForward: 'Bring forward',+ moveBackward: 'Send backward',+ close: 'Close',+ show: 'Show',+ hide: 'Hide',+ lock: 'Lock',+ unlock: 'Unlock',+ name: 'Name',+ nameInput: 'Object name',+ description: 'Description',+ descriptionPlaceholder: 'Add description',+ details: 'Details',+ locate: 'Locate',+ expand: 'Expand',+ collapse: 'Collapse',+ dragToReorder: 'Drag to reorder',+ search: 'Search objects',+ filterAll: 'All',+ filterHidden: 'Hidden',+ filterLocked: 'Locked',+ sectionCanvas: 'Canvas layer',+ sectionFloating: 'Floating layer',+ typeNames: {+ object: 'Object',+ shape: 'Shape',+ connector: 'Connector',+ image: 'Image',+ chart: 'Chart',+ table: 'Table',+ smartArt: 'SmartArt',+ video: 'Video',+ group: 'Group',+ unit: 'Unit',+ dom: 'DOM',+ text: 'Text',+ placeholder: 'Placeholder',+ container: 'Container',+ },+ noSelection: 'Select an object to edit its details',+ },'image-panel': {arrange: {title: 'Arrange',diff --git a/packages/drawing-ui/src/locale/es-ES.ts b/packages/drawing-ui/src/locale/es-ES.tsindex 4ee209817e..c17d19ddd6 100644--- a/packages/drawing-ui/src/locale/es-ES.ts+++ b/packages/drawing-ui/src/locale/es-ES.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'No se pueden recortar objetos que no sean imágenes.',},+ objectListPanel: {+ title: 'Objetos',+ empty: 'Sin objetos',+ showAll: 'Mostrar todo',+ hideAll: 'Ocultar todo',+ moveForward: 'Traer hacia delante',+ moveBackward: 'Enviar hacia atras',+ close: 'Cerrar',+ show: 'Mostrar',+ hide: 'Ocultar',+ lock: 'Bloquear',+ unlock: 'Desbloquear',+ name: 'Nombre',+ nameInput: 'Nombre del objeto',+ description: 'Descripcion',+ descriptionPlaceholder: 'Agregar descripcion',+ details: 'Detalles',+ locate: 'Localizar',+ expand: 'Expandir',+ collapse: 'Contraer',+ dragToReorder: 'Arrastre para reordenar',+ search: 'Buscar objetos',+ filterAll: 'Todo',+ filterHidden: 'Ocultos',+ filterLocked: 'Bloqueados',+ sectionCanvas: 'Capa de lienzo',+ sectionFloating: 'Capa flotante',+ typeNames: {+ object: 'Objeto',+ shape: 'Forma',+ connector: 'Conector',+ image: 'Imagen',+ chart: 'Gráfico',+ table: 'Tabla',+ smartArt: 'SmartArt',+ video: 'Vídeo',+ group: 'Grupo',+ unit: 'Unidad',+ dom: 'DOM',+ text: 'Texto',+ placeholder: 'Marcador de posición',+ container: 'Contenedor',+ },+ noSelection: 'Seleccione un objeto para editar sus detalles',+ },'image-panel': {arrange: {title: 'Organizar',diff --git a/packages/drawing-ui/src/locale/fa-IR.ts b/packages/drawing-ui/src/locale/fa-IR.tsindex de93086d59..9e135a9ec8 100644--- a/packages/drawing-ui/src/locale/fa-IR.ts+++ b/packages/drawing-ui/src/locale/fa-IR.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'کراپ کردن اشیاء غیرتصویری امکانپذیر نیست.',},+ objectListPanel: {+ title: 'اشیا',+ empty: 'هیچ شیئی وجود ندارد',+ showAll: 'نمایش همه',+ hideAll: 'پنهان کردن همه',+ moveForward: 'آوردن به جلو',+ moveBackward: 'فرستادن به عقب',+ close: 'بستن',+ show: 'نمایش',+ hide: 'پنهان کردن',+ lock: 'قفل',+ unlock: 'باز کردن قفل',+ name: 'نام',+ nameInput: 'نام شیء',+ description: 'توضیحات',+ descriptionPlaceholder: 'افزودن توضیحات',+ details: 'جزئیات',+ locate: 'مکانیابی',+ expand: 'گسترش',+ collapse: 'جمع کردن',+ dragToReorder: 'برای مرتبسازی بکشید',+ search: 'جستجوی اشیا',+ filterAll: 'همه',+ filterHidden: 'پنهان',+ filterLocked: 'قفل شده',+ sectionCanvas: 'لایه بوم',+ sectionFloating: 'لایه شناور',+ typeNames: {+ object: 'شیء',+ shape: 'شکل',+ connector: 'رابط',+ image: 'تصویر',+ chart: 'نمودار',+ table: 'جدول',+ smartArt: 'SmartArt',+ video: 'ویدیو',+ group: 'گروه',+ unit: 'واحد',+ dom: 'DOM',+ text: 'متن',+ placeholder: 'نگهدارنده مکان',+ container: 'محفظه',+ },+ noSelection: 'برای ویرایش جزئیات یک شیء را انتخاب کنید',+ },'image-panel': {arrange: {title: 'ترتیبدهی',diff --git a/packages/drawing-ui/src/locale/fr-FR.ts b/packages/drawing-ui/src/locale/fr-FR.tsindex 6cdf46b182..972788fa45 100644--- a/packages/drawing-ui/src/locale/fr-FR.ts+++ b/packages/drawing-ui/src/locale/fr-FR.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Impossible de rogner des objets non image.',},+ objectListPanel: {+ title: 'Objets',+ empty: 'Aucun objet',+ showAll: 'Tout afficher',+ hideAll: 'Tout masquer',+ moveForward: 'Avancer',+ moveBackward: 'Reculer',+ close: 'Fermer',+ show: 'Afficher',+ hide: 'Masquer',+ lock: 'Verrouiller',+ unlock: 'Deverrouiller',+ name: 'Nom',+ nameInput: 'Nom de l\'objet',+ description: 'Description',+ descriptionPlaceholder: 'Ajouter une description',+ details: 'Details',+ locate: 'Localiser',+ expand: 'Développer',+ collapse: 'Réduire',+ dragToReorder: 'Faire glisser pour réorganiser',+ search: 'Rechercher des objets',+ filterAll: 'Tous',+ filterHidden: 'Masqués',+ filterLocked: 'Verrouillés',+ sectionCanvas: 'Calque du canevas',+ sectionFloating: 'Calque flottant',+ typeNames: {+ object: 'Objet',+ shape: 'Forme',+ connector: 'Connecteur',+ image: 'Image',+ chart: 'Graphique',+ table: 'Tableau',+ smartArt: 'SmartArt',+ video: 'Vidéo',+ group: 'Groupe',+ unit: 'Unité',+ dom: 'DOM',+ text: 'Texte',+ placeholder: 'Espace réservé',+ container: 'Conteneur',+ },+ noSelection: 'Sélectionnez un objet pour modifier ses détails',+ },'image-panel': {arrange: {title: 'Arranger',diff --git a/packages/drawing-ui/src/locale/id-ID.ts b/packages/drawing-ui/src/locale/id-ID.tsindex aac0302090..30e8b8a6df 100644--- a/packages/drawing-ui/src/locale/id-ID.ts+++ b/packages/drawing-ui/src/locale/id-ID.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Tidak dapat memangkas objek non-gambar.',},+ objectListPanel: {+ title: 'Objek',+ empty: 'Tidak ada objek',+ showAll: 'Tampilkan semua',+ hideAll: 'Sembunyikan semua',+ moveForward: 'Bawa ke depan',+ moveBackward: 'Kirim ke belakang',+ close: 'Tutup',+ show: 'Tampilkan',+ hide: 'Sembunyikan',+ lock: 'Kunci',+ unlock: 'Buka kunci',+ name: 'Nama',+ nameInput: 'Nama objek',+ description: 'Deskripsi',+ descriptionPlaceholder: 'Tambahkan deskripsi',+ details: 'Detail',+ locate: 'Temukan',+ expand: 'Bentangkan',+ collapse: 'Ciutkan',+ dragToReorder: 'Seret untuk mengurutkan',+ search: 'Cari objek',+ filterAll: 'Semua',+ filterHidden: 'Tersembunyi',+ filterLocked: 'Terkunci',+ sectionCanvas: 'Lapisan kanvas',+ sectionFloating: 'Lapisan mengambang',+ typeNames: {+ object: 'Objek',+ shape: 'Bentuk',+ connector: 'Konektor',+ image: 'Gambar',+ chart: 'Bagan',+ table: 'Tabel',+ smartArt: 'SmartArt',+ video: 'Video',+ group: 'Grup',+ unit: 'Unit',+ dom: 'DOM',+ text: 'Teks',+ placeholder: 'Placeholder',+ container: 'Kontainer',+ },+ noSelection: 'Pilih objek untuk mengedit detailnya',+ },'image-panel': {arrange: {title: 'Atur',diff --git a/packages/drawing-ui/src/locale/it-IT.ts b/packages/drawing-ui/src/locale/it-IT.tsindex 15b463b6c5..0dca660471 100644--- a/packages/drawing-ui/src/locale/it-IT.ts+++ b/packages/drawing-ui/src/locale/it-IT.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Impossibile ritagliare oggetti non immagine.',},+ objectListPanel: {+ title: 'Oggetti',+ empty: 'Nessun oggetto',+ showAll: 'Mostra tutto',+ hideAll: 'Nascondi tutto',+ moveForward: 'Porta avanti',+ moveBackward: 'Manda indietro',+ close: 'Chiudi',+ show: 'Mostra',+ hide: 'Nascondi',+ lock: 'Blocca',+ unlock: 'Sblocca',+ name: 'Nome',+ nameInput: 'Nome oggetto',+ description: 'Descrizione',+ descriptionPlaceholder: 'Aggiungi descrizione',+ details: 'Dettagli',+ locate: 'Individua',+ expand: 'Espandi',+ collapse: 'Comprimi',+ dragToReorder: 'Trascina per riordinare',+ search: 'Cerca oggetti',+ filterAll: 'Tutti',+ filterHidden: 'Nascosti',+ filterLocked: 'Bloccati',+ sectionCanvas: 'Livello canvas',+ sectionFloating: 'Livello mobile',+ typeNames: {+ object: 'Oggetto',+ shape: 'Forma',+ connector: 'Connettore',+ image: 'Immagine',+ chart: 'Grafico',+ table: 'Tabella',+ smartArt: 'SmartArt',+ video: 'Video',+ group: 'Gruppo',+ unit: 'Unità',+ dom: 'DOM',+ text: 'Testo',+ placeholder: 'Segnaposto',+ container: 'Contenitore',+ },+ noSelection: 'Seleziona un oggetto per modificarne i dettagli',+ },'image-panel': {arrange: {title: 'Disponi',diff --git a/packages/drawing-ui/src/locale/ja-JP.ts b/packages/drawing-ui/src/locale/ja-JP.tsindex 2e906250b3..3b0ab4f2c1 100644--- a/packages/drawing-ui/src/locale/ja-JP.ts+++ b/packages/drawing-ui/src/locale/ja-JP.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: '画像以外のオブジェクトはトリミングできません。',},+ objectListPanel: {+ title: 'オブジェクト',+ empty: 'オブジェクトがありません',+ showAll: 'すべて表示',+ hideAll: 'すべて非表示',+ moveForward: '前面へ移動',+ moveBackward: '背面へ移動',+ close: '閉じる',+ show: '表示',+ hide: '非表示',+ lock: 'ロック',+ unlock: 'ロック解除',+ name: '名前',+ nameInput: 'オブジェクト名',+ description: '説明',+ descriptionPlaceholder: '説明を追加',+ details: '詳細',+ locate: '位置を表示',+ expand: '展開',+ collapse: '折りたたむ',+ dragToReorder: 'ドラッグして並べ替え',+ search: 'オブジェクトを検索',+ filterAll: 'すべて',+ filterHidden: '非表示',+ filterLocked: 'ロック済み',+ sectionCanvas: 'キャンバスレイヤー',+ sectionFloating: 'フローティングレイヤー',+ typeNames: {+ object: 'オブジェクト',+ shape: '図形',+ connector: 'コネクタ',+ image: '画像',+ chart: 'グラフ',+ table: '表',+ smartArt: 'SmartArt',+ video: 'ビデオ',+ group: 'グループ',+ unit: 'ユニット',+ dom: 'DOM',+ text: 'テキスト',+ placeholder: 'プレースホルダー',+ container: 'コンテナー',+ },+ noSelection: 'オブジェクトを選択して詳細を編集',+ },'image-panel': {arrange: {title: '配置',diff --git a/packages/drawing-ui/src/locale/ko-KR.ts b/packages/drawing-ui/src/locale/ko-KR.tsindex 3b989d3e0e..a00716eb30 100644--- a/packages/drawing-ui/src/locale/ko-KR.ts+++ b/packages/drawing-ui/src/locale/ko-KR.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: '이미지가 아닌 객체는 자를 수 없습니다.',},+ objectListPanel: {+ title: '개체',+ empty: '개체 없음',+ showAll: '모두 표시',+ hideAll: '모두 숨기기',+ moveForward: '앞으로 가져오기',+ moveBackward: '뒤로 보내기',+ close: '닫기',+ show: '표시',+ hide: '숨기기',+ lock: '잠금',+ unlock: '잠금 해제',+ name: '이름',+ nameInput: '개체 이름',+ description: '설명',+ descriptionPlaceholder: '설명 추가',+ details: '세부 정보',+ locate: '위치 찾기',+ expand: '펼치기',+ collapse: '접기',+ dragToReorder: '드래그하여 순서 변경',+ search: '개체 검색',+ filterAll: '전체',+ filterHidden: '숨김',+ filterLocked: '잠김',+ sectionCanvas: '캔버스 레이어',+ sectionFloating: '플로팅 레이어',+ typeNames: {+ object: '개체',+ shape: '도형',+ connector: '연결선',+ image: '이미지',+ chart: '차트',+ table: '표',+ smartArt: 'SmartArt',+ video: '비디오',+ group: '그룹',+ unit: '단위',+ dom: 'DOM',+ text: '텍스트',+ placeholder: '자리 표시자',+ container: '컨테이너',+ },+ noSelection: '세부 정보를 편집할 개체를 선택하세요',+ },'image-panel': {arrange: {title: '정렬',diff --git a/packages/drawing-ui/src/locale/pl-PL.ts b/packages/drawing-ui/src/locale/pl-PL.tsindex ae9af3fc39..4439bc0c64 100644--- a/packages/drawing-ui/src/locale/pl-PL.ts+++ b/packages/drawing-ui/src/locale/pl-PL.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Nie można przyciąć obiektów innych niż obraz.',},+ objectListPanel: {+ title: 'Obiekty',+ empty: 'Brak obiektow',+ showAll: 'Pokaz wszystko',+ hideAll: 'Ukryj wszystko',+ moveForward: 'Przesun do przodu',+ moveBackward: 'Przesun do tylu',+ close: 'Zamknij',+ show: 'Pokaz',+ hide: 'Ukryj',+ lock: 'Zablokuj',+ unlock: 'Odblokuj',+ name: 'Nazwa',+ nameInput: 'Nazwa obiektu',+ description: 'Opis',+ descriptionPlaceholder: 'Dodaj opis',+ details: 'Szczegoly',+ locate: 'Zlokalizuj',+ expand: 'Rozwiń',+ collapse: 'Zwiń',+ dragToReorder: 'Przeciągnij, aby zmienić kolejność',+ search: 'Szukaj obiektów',+ filterAll: 'Wszystkie',+ filterHidden: 'Ukryte',+ filterLocked: 'Zablokowane',+ sectionCanvas: 'Warstwa kanwy',+ sectionFloating: 'Warstwa pływająca',+ typeNames: {+ object: 'Obiekt',+ shape: 'Kształt',+ connector: 'Łącznik',+ image: 'Obraz',+ chart: 'Wykres',+ table: 'Tabela',+ smartArt: 'SmartArt',+ video: 'Wideo',+ group: 'Grupa',+ unit: 'Jednostka',+ dom: 'DOM',+ text: 'Tekst',+ placeholder: 'Symbol zastępczy',+ container: 'Kontener',+ },+ noSelection: 'Wybierz obiekt, aby edytować szczegóły',+ },'image-panel': {arrange: {title: 'Rozmieść',diff --git a/packages/drawing-ui/src/locale/pt-BR.ts b/packages/drawing-ui/src/locale/pt-BR.tsindex 0441454256..0d23e52179 100644--- a/packages/drawing-ui/src/locale/pt-BR.ts+++ b/packages/drawing-ui/src/locale/pt-BR.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Não é possível cortar objetos que não são imagens.',},+ objectListPanel: {+ title: 'Objetos',+ empty: 'Nenhum objeto',+ showAll: 'Mostrar tudo',+ hideAll: 'Ocultar tudo',+ moveForward: 'Trazer para frente',+ moveBackward: 'Enviar para tras',+ close: 'Fechar',+ show: 'Mostrar',+ hide: 'Ocultar',+ lock: 'Bloquear',+ unlock: 'Desbloquear',+ name: 'Nome',+ nameInput: 'Nome do objeto',+ description: 'Descricao',+ descriptionPlaceholder: 'Adicionar descricao',+ details: 'Detalhes',+ locate: 'Localizar',+ expand: 'Expandir',+ collapse: 'Recolher',+ dragToReorder: 'Arraste para reordenar',+ search: 'Pesquisar objetos',+ filterAll: 'Todos',+ filterHidden: 'Ocultos',+ filterLocked: 'Bloqueados',+ sectionCanvas: 'Camada da tela',+ sectionFloating: 'Camada flutuante',+ typeNames: {+ object: 'Objeto',+ shape: 'Forma',+ connector: 'Conector',+ image: 'Imagem',+ chart: 'Gráfico',+ table: 'Tabela',+ smartArt: 'SmartArt',+ video: 'Vídeo',+ group: 'Grupo',+ unit: 'Unidade',+ dom: 'DOM',+ text: 'Texto',+ placeholder: 'Espaço reservado',+ container: 'Contêiner',+ },+ noSelection: 'Selecione um objeto para editar seus detalhes',+ },'image-panel': {arrange: {title: 'Organizar',diff --git a/packages/drawing-ui/src/locale/ru-RU.ts b/packages/drawing-ui/src/locale/ru-RU.tsindex 5dd5240753..00d880a385 100644--- a/packages/drawing-ui/src/locale/ru-RU.ts+++ b/packages/drawing-ui/src/locale/ru-RU.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Невозможно обрезать не изображения.',},+ objectListPanel: {+ title: 'Объекты',+ empty: 'Нет объектов',+ showAll: 'Показать все',+ hideAll: 'Скрыть все',+ moveForward: 'Переместить вперед',+ moveBackward: 'Переместить назад',+ close: 'Закрыть',+ show: 'Показать',+ hide: 'Скрыть',+ lock: 'Заблокировать',+ unlock: 'Разблокировать',+ name: 'Имя',+ nameInput: 'Имя объекта',+ description: 'Описание',+ descriptionPlaceholder: 'Добавить описание',+ details: 'Сведения',+ locate: 'Найти',+ expand: 'Развернуть',+ collapse: 'Свернуть',+ dragToReorder: 'Перетащите, чтобы изменить порядок',+ search: 'Поиск объектов',+ filterAll: 'Все',+ filterHidden: 'Скрытые',+ filterLocked: 'Заблокированные',+ sectionCanvas: 'Слой холста',+ sectionFloating: 'Плавающий слой',+ typeNames: {+ object: 'Объект',+ shape: 'Фигура',+ connector: 'Соединитель',+ image: 'Изображение',+ chart: 'Диаграмма',+ table: 'Таблица',+ smartArt: 'SmartArt',+ video: 'Видео',+ group: 'Группа',+ unit: 'Единица',+ dom: 'DOM',+ text: 'Текст',+ placeholder: 'Заполнитель',+ container: 'Контейнер',+ },+ noSelection: 'Выберите объект, чтобы изменить сведения',+ },'image-panel': {arrange: {title: 'Расположение',diff --git a/packages/drawing-ui/src/locale/sk-SK.ts b/packages/drawing-ui/src/locale/sk-SK.tsindex d31381cb7b..ac2c1b8d1e 100644--- a/packages/drawing-ui/src/locale/sk-SK.ts+++ b/packages/drawing-ui/src/locale/sk-SK.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Nedá sa orezať neobrázkový objekt.',},+ objectListPanel: {+ title: 'Objekty',+ empty: 'Ziadne objekty',+ showAll: 'Zobrazit vsetko',+ hideAll: 'Skryt vsetko',+ moveForward: 'Presunut dopredu',+ moveBackward: 'Presunut dozadu',+ close: 'Zavriet',+ show: 'Zobrazit',+ hide: 'Skryt',+ lock: 'Zamknut',+ unlock: 'Odomknut',+ name: 'Nazov',+ nameInput: 'Nazov objektu',+ description: 'Popis',+ descriptionPlaceholder: 'Pridat popis',+ details: 'Podrobnosti',+ locate: 'Nájsť',+ expand: 'Rozbaliť',+ collapse: 'Zbaliť',+ dragToReorder: 'Potiahnutím zmeňte poradie',+ search: 'Hľadať objekty',+ filterAll: 'Všetky',+ filterHidden: 'Skryté',+ filterLocked: 'Zamknuté',+ sectionCanvas: 'Vrstva plátna',+ sectionFloating: 'Plávajúca vrstva',+ typeNames: {+ object: 'Objekt',+ shape: 'Tvar',+ connector: 'Spojnica',+ image: 'Obrázok',+ chart: 'Graf',+ table: 'Tabuľka',+ smartArt: 'SmartArt',+ video: 'Video',+ group: 'Skupina',+ unit: 'Jednotka',+ dom: 'DOM',+ text: 'Text',+ placeholder: 'Zástupný symbol',+ container: 'Kontajner',+ },+ noSelection: 'Vyberte objekt na úpravu podrobností',+ },'image-panel': {arrange: {title: 'Usporiadať',diff --git a/packages/drawing-ui/src/locale/vi-VN.ts b/packages/drawing-ui/src/locale/vi-VN.tsindex b3bd23cb37..298bae05a4 100644--- a/packages/drawing-ui/src/locale/vi-VN.ts+++ b/packages/drawing-ui/src/locale/vi-VN.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: 'Không thể cắt phần tử không phải hình ảnh',},+ objectListPanel: {+ title: 'Doi tuong',+ empty: 'Khong co doi tuong',+ showAll: 'Hien thi tat ca',+ hideAll: 'An tat ca',+ moveForward: 'Dua len truoc',+ moveBackward: 'Dua ra sau',+ close: 'Dong',+ show: 'Hien thi',+ hide: 'An',+ lock: 'Khoa',+ unlock: 'Mo khoa',+ name: 'Ten',+ nameInput: 'Ten doi tuong',+ description: 'Mo ta',+ descriptionPlaceholder: 'Them mo ta',+ details: 'Chi tiet',+ locate: 'Định vị',+ expand: 'Mở rộng',+ collapse: 'Thu gọn',+ dragToReorder: 'Kéo để sắp xếp lại',+ search: 'Tìm đối tượng',+ filterAll: 'Tất cả',+ filterHidden: 'Đã ẩn',+ filterLocked: 'Đã khóa',+ sectionCanvas: 'Lớp canvas',+ sectionFloating: 'Lớp nổi',+ typeNames: {+ object: 'Đối tượng',+ shape: 'Hình dạng',+ connector: 'Đường nối',+ image: 'Hình ảnh',+ chart: 'Biểu đồ',+ table: 'Bảng',+ smartArt: 'SmartArt',+ video: 'Video',+ group: 'Nhóm',+ unit: 'Đơn vị',+ dom: 'DOM',+ text: 'Văn bản',+ placeholder: 'Chỗ dành sẵn',+ container: 'Vùng chứa',+ },+ noSelection: 'Chọn một đối tượng để chỉnh sửa chi tiết',+ },'image-panel': {arrange: {title: 'Sắp xếp',diff --git a/packages/drawing-ui/src/locale/zh-CN.ts b/packages/drawing-ui/src/locale/zh-CN.tsindex 70c6e1fbbc..c00197d8e4 100644--- a/packages/drawing-ui/src/locale/zh-CN.ts+++ b/packages/drawing-ui/src/locale/zh-CN.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: '无法裁剪非图片元素',},+ objectListPanel: {+ title: '对象',+ empty: '暂无对象',+ showAll: '全部显示',+ hideAll: '全部隐藏',+ moveForward: '上移一层',+ moveBackward: '下移一层',+ close: '关闭',+ show: '显示',+ hide: '隐藏',+ lock: '锁定',+ unlock: '解锁',+ name: '名称',+ nameInput: '对象名称',+ description: '描述',+ descriptionPlaceholder: '添加描述',+ details: '详情',+ locate: '定位',+ expand: '展开',+ collapse: '折叠',+ dragToReorder: '拖拽调整层级',+ search: '搜索对象',+ filterAll: '全部',+ filterHidden: '隐藏',+ filterLocked: '锁定',+ sectionCanvas: '画布层',+ sectionFloating: '浮动层',+ typeNames: {+ object: '对象',+ shape: '形状',+ connector: '连接线',+ image: '图片',+ chart: '图表',+ table: '表格',+ smartArt: 'SmartArt',+ video: '视频',+ group: '组合',+ unit: '单元',+ dom: 'DOM',+ text: '文本',+ placeholder: '占位符',+ container: '容器',+ },+ noSelection: '选择一个对象以编辑详情',+ },'image-panel': {arrange: {title: '排列',diff --git a/packages/drawing-ui/src/locale/zh-HK.ts b/packages/drawing-ui/src/locale/zh-HK.tsindex 696c4eab40..f0267ecb8c 100644--- a/packages/drawing-ui/src/locale/zh-HK.ts+++ b/packages/drawing-ui/src/locale/zh-HK.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: '無法裁切非圖片元素',},+ objectListPanel: {+ title: '物件',+ empty: '暫無物件',+ showAll: '全部顯示',+ hideAll: '全部隱藏',+ moveForward: '上移一層',+ moveBackward: '下移一層',+ close: '關閉',+ show: '顯示',+ hide: '隱藏',+ lock: '鎖定',+ unlock: '解鎖',+ name: '名稱',+ nameInput: '物件名稱',+ description: '描述',+ descriptionPlaceholder: '新增描述',+ details: '詳情',+ locate: '定位',+ expand: '展開',+ collapse: '摺疊',+ dragToReorder: '拖曳調整圖層',+ search: '搜尋物件',+ filterAll: '全部',+ filterHidden: '隱藏',+ filterLocked: '鎖定',+ sectionCanvas: '畫布層',+ sectionFloating: '浮動層',+ typeNames: {+ object: '物件',+ shape: '形狀',+ connector: '連接線',+ image: '圖片',+ chart: '圖表',+ table: '表格',+ smartArt: 'SmartArt',+ video: '影片',+ group: '群組',+ unit: '單元',+ dom: 'DOM',+ text: '文字',+ placeholder: '佔位符',+ container: '容器',+ },+ noSelection: '請選取一個物件以編輯詳細資訊',+ },'image-panel': {arrange: {title: '排列',diff --git a/packages/drawing-ui/src/locale/zh-TW.ts b/packages/drawing-ui/src/locale/zh-TW.tsindex 696c4eab40..946aa262c6 100644--- a/packages/drawing-ui/src/locale/zh-TW.ts+++ b/packages/drawing-ui/src/locale/zh-TW.ts@@ -21,6 +21,51 @@ const locale: typeof enUS = {'image-cropper': {error: '無法裁切非圖片元素',},+ objectListPanel: {+ title: '物件',+ empty: '暫無物件',+ showAll: '全部顯示',+ hideAll: '全部隱藏',+ moveForward: '上移一層',+ moveBackward: '下移一層',+ close: '關閉',+ show: '顯示',+ hide: '隱藏',+ lock: '鎖定',+ unlock: '解鎖',+ name: '名稱',+ nameInput: '物件名稱',+ description: '描述',+ descriptionPlaceholder: '新增描述',+ details: '詳細資料',+ locate: '定位',+ expand: '展開',+ collapse: '摺疊',+ dragToReorder: '拖曳調整圖層',+ search: '搜尋物件',+ filterAll: '全部',+ filterHidden: '隱藏',+ filterLocked: '鎖定',+ sectionCanvas: '畫布層',+ sectionFloating: '浮動層',+ typeNames: {+ object: '物件',+ shape: '形狀',+ connector: '連接線',+ image: '圖片',+ chart: '圖表',+ table: '表格',+ smartArt: 'SmartArt',+ video: '影片',+ group: '群組',+ unit: '單元',+ dom: 'DOM',+ text: '文字',+ placeholder: '預留位置',+ container: '容器',+ },+ noSelection: '請選取一個物件以編輯詳細資訊',+ },'image-panel': {arrange: {title: '排列',diff --git a/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx b/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsxnew file mode 100644index 0000000000..7ca009232b--- /dev/null+++ b/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx@@ -0,0 +1,862 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { DragEvent, FocusEvent, KeyboardEvent, MouseEvent } from 'react';+import { Button, clsx, Input } from '@univerjs/design';+import { ArrowDownIcon, ArrowUpIcon, CloseIcon, EyeIcon, EyelashIcon, LockIcon, MoreDownIcon, MoreRightIcon } from '@univerjs/icons';+import { useEffect, useMemo, useRef, useState } from 'react';+import { OBJECT_LIST_CANVAS_SECTION_ID, OBJECT_LIST_FLOATING_SECTION_ID } from './object-list-panel-layer';++export interface IObjectListPanelCapabilities {+ arrange?: boolean;+ description?: boolean;+ locate?: boolean;+ name?: boolean;+ reorder?: boolean;+ selectable?: boolean;+ visible?: boolean;+}++type ObjectListFilterMode = 'all' | 'hidden' | 'locked';++export interface IObjectListPanelItem {+ id: string;+ name: string;+ description?: string;+ visible: boolean;+ selectable?: boolean;+ disabled?: boolean;+ level?: number;+ isGroup?: boolean;+ expanded?: boolean;+ canMoveForward?: boolean;+ canMoveBackward?: boolean;+ canReorder?: boolean;+ parentId?: string;+ sectionId?: string;+ sectionTitle?: string;+ capabilities?: IObjectListPanelCapabilities;+}++export interface IObjectListPanelLabels {+ title: string;+ empty: string;+ showAll: string;+ hideAll: string;+ moveForward: string;+ moveBackward: string;+ close: string;+ show: string;+ hide: string;+ lock: string;+ unlock: string;+ name: string;+ nameInput: string;+ description: string;+ descriptionPlaceholder: string;+ details: string;+ noSelection: string;+ locate: string;+ expand: string;+ collapse: string;+ dragToReorder: string;+ search: string;+ filterAll: string;+ filterHidden: string;+ filterLocked: string;+ sectionCanvas: string;+ sectionFloating: string;+}++export type ObjectListPanelTypeNameKey =+ | 'chart'+ | 'connector'+ | 'container'+ | 'dom'+ | 'group'+ | 'image'+ | 'object'+ | 'placeholder'+ | 'shape'+ | 'smartArt'+ | 'table'+ | 'text'+ | 'unit'+ | 'video';++interface IObjectListPanelLocaleService {+ t: (key: string) => string;+}++const objectListPanelLabelKeys: Record<keyof IObjectListPanelLabels, string> = {+ title: 'drawing-ui.objectListPanel.title',+ empty: 'drawing-ui.objectListPanel.empty',+ showAll: 'drawing-ui.objectListPanel.showAll',+ hideAll: 'drawing-ui.objectListPanel.hideAll',+ moveForward: 'drawing-ui.objectListPanel.moveForward',+ moveBackward: 'drawing-ui.objectListPanel.moveBackward',+ close: 'drawing-ui.objectListPanel.close',+ show: 'drawing-ui.objectListPanel.show',+ hide: 'drawing-ui.objectListPanel.hide',+ lock: 'drawing-ui.objectListPanel.lock',+ unlock: 'drawing-ui.objectListPanel.unlock',+ name: 'drawing-ui.objectListPanel.name',+ nameInput: 'drawing-ui.objectListPanel.nameInput',+ description: 'drawing-ui.objectListPanel.description',+ descriptionPlaceholder: 'drawing-ui.objectListPanel.descriptionPlaceholder',+ details: 'drawing-ui.objectListPanel.details',+ noSelection: 'drawing-ui.objectListPanel.noSelection',+ locate: 'drawing-ui.objectListPanel.locate',+ expand: 'drawing-ui.objectListPanel.expand',+ collapse: 'drawing-ui.objectListPanel.collapse',+ dragToReorder: 'drawing-ui.objectListPanel.dragToReorder',+ search: 'drawing-ui.objectListPanel.search',+ filterAll: 'drawing-ui.objectListPanel.filterAll',+ filterHidden: 'drawing-ui.objectListPanel.filterHidden',+ filterLocked: 'drawing-ui.objectListPanel.filterLocked',+ sectionCanvas: 'drawing-ui.objectListPanel.sectionCanvas',+ sectionFloating: 'drawing-ui.objectListPanel.sectionFloating',+};++export function getObjectListPanelLabels(localeService: IObjectListPanelLocaleService): IObjectListPanelLabels {+ return Object.fromEntries(+ Object.entries(objectListPanelLabelKeys).map(([labelKey, localeKey]) => [labelKey, localeService.t(localeKey)])+ ) as unknown as IObjectListPanelLabels;+}++export function getObjectListPanelTypeName(localeService: IObjectListPanelLocaleService, typeName: ObjectListPanelTypeNameKey): string {+ return localeService.t(`drawing-ui.objectListPanel.typeNames.${typeName}`);+}++export interface IObjectListPanelBaseProps {+ items: IObjectListPanelItem[];+ selectedIds: string[];+ allObjectIds?: string[];+ focusedId?: string | null;+ labels: IObjectListPanelLabels;+ showHeader?: boolean;+ capabilities?: IObjectListPanelCapabilities;+ onClose?: () => void;+ onSelect: (objectId: string, multiSelect: boolean) => void;+ onSetVisible: (objectIds: string[], visible: boolean) => void;+ onCommitName: (objectId: string, value: string) => void;+ onCommitDescription: (objectId: string, value: string) => void;+ onMoveForward?: (objectId: string) => void;+ onMoveBackward?: (objectId: string) => void;+ onToggleExpanded?: (objectId: string) => void;+ onToggleSelectable?: (objectId: string) => void;+ onLocate?: (objectId: string) => void;+ onReorder?: (sourceObjectId: string, targetObjectId: string) => void;+}++const iconButtonClassName = `+ univer-flex univer-size-7 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-md+ univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 univer-outline-none univer-transition-colors+ hover:univer-bg-gray-100 hover:univer-text-gray-900+ disabled:univer-cursor-not-allowed disabled:univer-opacity-40+ dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-100+`;++const expandButtonClassName = `+ univer-flex univer-size-5 univer-shrink-0 univer-items-center univer-justify-center univer-rounded+ univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 univer-outline-none univer-transition-transform+ hover:univer-bg-gray-100 hover:univer-text-gray-900+ dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-100+`;++const sectionOrder = new Map([+ [OBJECT_LIST_FLOATING_SECTION_ID, 0],+ [OBJECT_LIST_CANVAS_SECTION_ID, 1],+ ['', 2],+]);++function normalizeText(value: string): string {+ return value.trim();+}++function hasCapability(+ panelCapabilities: IObjectListPanelCapabilities | undefined,+ item: IObjectListPanelItem | null | undefined,+ key: keyof IObjectListPanelCapabilities,+ fallback = true+): boolean {+ return item?.capabilities?.[key] ?? panelCapabilities?.[key] ?? fallback;+}++function LocateFixedIcon() {+ return (+ <svg className="univer-size-4" viewBox="0 0 24 24" fill="none" aria-hidden="true">+ <path d="M12 4v3M12 17v3M4 12h3M17 12h3" stroke="currentColor" strokeLinecap="round" strokeWidth="1.8" />+ <circle cx="12" cy="12" r="5" stroke="currentColor" strokeWidth="1.8" />+ <circle cx="12" cy="12" r="1.5" fill="currentColor" />+ </svg>+ );+}++export function ObjectListPanelBase(props: IObjectListPanelBaseProps) {+ const {+ items,+ selectedIds,+ allObjectIds,+ focusedId,+ labels,+ showHeader = true,+ capabilities,+ onClose,+ onSelect,+ onSetVisible,+ onCommitName,+ onCommitDescription,+ onMoveForward,+ onMoveBackward,+ onToggleExpanded,+ onToggleSelectable,+ onLocate,+ onReorder,+ } = props;+ const selectedIdSet = useMemo(() => new Set(selectedIds), [selectedIds]);+ const [draggingId, setDraggingId] = useState<string | null>(null);+ const [searchQuery, setSearchQuery] = useState('');+ const [filterMode, setFilterMode] = useState<ObjectListFilterMode>('all');+ const [collapsedSectionIds, setCollapsedSectionIds] = useState<Set<string>>(() => new Set());+ const selectedItem = useMemo(+ () => items.find((item) => item.id === focusedId) ?? items.find((item) => selectedIdSet.has(item.id)) ?? null,+ [focusedId, items, selectedIdSet]+ );+ const visibleItems = useMemo(() => {+ const normalizedQuery = normalizeText(searchQuery).toLocaleLowerCase();++ return items.filter((item) => {+ if (filterMode === 'hidden' && item.visible !== false) {+ return false;+ }+ if (filterMode === 'locked' && item.selectable !== false) {+ return false;+ }+ if (!normalizedQuery) {+ return true;+ }++ return item.name.toLocaleLowerCase().includes(normalizedQuery) ||+ (item.description ?? '').toLocaleLowerCase().includes(normalizedQuery);+ });+ }, [filterMode, items, searchQuery]);+ const visibleItemSections = useMemo(() => {+ const sectionMap = new Map<string, { id: string; title: string; items: IObjectListPanelItem[] }>();++ visibleItems.forEach((item) => {+ const sectionId = item.sectionId ?? '';+ const existingSection = sectionMap.get(sectionId);+ if (existingSection) {+ existingSection.items.push(item);+ return;+ }++ sectionMap.set(sectionId, {+ id: sectionId,+ title: item.sectionTitle ?? '',+ items: [item],+ });+ });++ return [...sectionMap.values()].sort((a, b) => (sectionOrder.get(a.id) ?? 3) - (sectionOrder.get(b.id) ?? 3));+ }, [visibleItems]);+ const showSectionHeaders = visibleItemSections.length > 1 || visibleItemSections.some((section) => section.id === OBJECT_LIST_FLOATING_SECTION_ID);+ const allIds = useMemo(() => allObjectIds ?? items.map((item) => item.id), [allObjectIds, items]);+ const selectedIndex = selectedItem ? items.findIndex((item) => item.id === selectedItem.id) : -1;+ const canMoveForward = !!selectedItem && !!onMoveForward && !selectedItem.disabled && (+ selectedItem.canMoveForward ?? selectedIndex > 0+ ) && hasCapability(capabilities, selectedItem, 'arrange');+ const canMoveBackward = !!selectedItem && !!onMoveBackward && !selectedItem.disabled && (+ selectedItem.canMoveBackward ?? (selectedIndex >= 0 && selectedIndex < items.length - 1)+ ) && hasCapability(capabilities, selectedItem, 'arrange');+ const showArrangeControls = hasCapability(capabilities, selectedItem, 'arrange') && (!!onMoveForward || !!onMoveBackward);+ const showLocateControl = !!onLocate && hasCapability(capabilities, selectedItem, 'locate');+ const canReorder = !!onReorder && (capabilities?.reorder ?? true);++ const findItem = (objectId: string | null): IObjectListPanelItem | null => {+ return objectId ? items.find((item) => item.id === objectId) ?? null : null;+ };++ const handleDrop = (targetId: string) => {+ const source = findItem(draggingId);+ const target = findItem(targetId);+ setDraggingId(null);+ if (!source || !target || source.id === target.id || source.disabled || target.disabled) {+ return;+ }+ if ((source.parentId ?? '') !== (target.parentId ?? '')) {+ return;+ }+ if ((source.sectionId ?? '') !== (target.sectionId ?? '')) {+ return;+ }+ if (source.canReorder === false || target.canReorder === false) {+ return;+ }++ onReorder?.(source.id, target.id);+ };++ const toggleSectionCollapsed = (sectionId: string) => {+ if (!sectionId) {+ return;+ }++ setCollapsedSectionIds((current) => {+ const next = new Set(current);+ if (next.has(sectionId)) {+ next.delete(sectionId);+ } else {+ next.add(sectionId);+ }++ return next;+ });+ };++ return (+ <div+ className="+ univer-box-border univer-flex univer-size-full univer-min-w-0 univer-max-w-full univer-flex-col+ univer-gap-3 univer-overflow-hidden univer-p-4 univer-text-gray-700+ dark:!univer-text-gray-200+ "+ data-drawing-object-list-panel="true"+ >+ {showHeader && (+ <div className="univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-gap-2">+ <div+ className="+ univer-min-w-0 univer-flex-1 univer-truncate univer-text-sm univer-font-semibold+ univer-text-gray-900+ dark:!univer-text-gray-100+ "+ >+ {labels.title}+ </div>+ {onClose && (+ <Button aria-label={labels.close} className="univer-size-8 univer-shrink-0" size="small" variant="ghost" onClick={onClose}>+ <CloseIcon className="univer-size-4" />+ </Button>+ )}+ </div>+ )}++ <div className="univer-flex univer-min-w-0 univer-items-center univer-justify-between univer-gap-2">+ <div className="univer-flex univer-min-w-0 univer-gap-2">+ <Button size="small" disabled={items.length === 0} onClick={() => onSetVisible(allIds, true)}>+ {labels.showAll}+ </Button>+ <Button size="small" disabled={items.length === 0} onClick={() => onSetVisible(allIds, false)}>+ {labels.hideAll}+ </Button>+ </div>+ <div className="univer-flex univer-shrink-0 univer-gap-1">+ {showLocateControl && (+ <button+ type="button"+ className={iconButtonClassName}+ title={labels.locate}+ aria-label={labels.locate}+ disabled={!selectedItem?.id}+ onClick={() => selectedItem && onLocate?.(selectedItem.id)}+ >+ <LocateFixedIcon />+ </button>+ )}+ {showArrangeControls && (+ <>+ <button+ type="button"+ className={iconButtonClassName}+ title={labels.moveForward}+ aria-label={labels.moveForward}+ disabled={!canMoveForward}+ onClick={() => selectedItem && onMoveForward?.(selectedItem.id)}+ >+ <ArrowUpIcon />+ </button>+ <button+ type="button"+ className={iconButtonClassName}+ title={labels.moveBackward}+ aria-label={labels.moveBackward}+ disabled={!canMoveBackward}+ onClick={() => selectedItem && onMoveBackward?.(selectedItem.id)}+ >+ <ArrowDownIcon />+ </button>+ </>+ )}+ </div>+ </div>++ <div className="univer-flex univer-shrink-0 univer-flex-col univer-gap-2">+ <Input+ value={searchQuery}+ aria-label={labels.search}+ placeholder={labels.search}+ onChange={setSearchQuery}+ />+ <div className="univer-flex univer-min-w-0 univer-gap-1">+ {([+ ['all', labels.filterAll],+ ['hidden', labels.filterHidden],+ ['locked', labels.filterLocked],+ ] as const).map(([mode, label]) => (+ <button+ key={mode}+ type="button"+ className={clsx(+ `+ univer-h-7 univer-min-w-0 univer-flex-1 univer-rounded-md univer-border+ univer-border-solid univer-px-2 univer-text-xs univer-outline-none+ univer-transition-colors+ dark:!univer-border-gray-700+ `,+ filterMode === mode+ ? `+ dark:!univer-bg-primary-900/30+ univer-border-primary-500 univer-bg-primary-50 univer-text-primary-600+ dark:!univer-text-primary-200+ `+ : `+ univer-border-gray-200 univer-bg-white univer-text-gray-600+ hover:univer-bg-gray-50+ dark:!univer-bg-gray-900 dark:!univer-text-gray-300+ dark:hover:!univer-bg-gray-800+ `+ )}+ aria-pressed={filterMode === mode}+ onClick={() => setFilterMode(mode)}+ >+ <span className="univer-block univer-truncate">{label}</span>+ </button>+ ))}+ </div>+ </div>++ <div className="univer-min-h-0 univer-flex-1 univer-overflow-y-auto univer-overflow-x-hidden">+ {visibleItems.length === 0+ ? <div className="univer-py-6 univer-text-center univer-text-sm univer-text-gray-500">{labels.empty}</div>+ : (+ <div className="univer-flex univer-min-w-0 univer-flex-col univer-gap-0.5">+ {visibleItemSections.map((section) => (+ <div+ key={section.id || 'default'}+ className="univer-flex univer-min-w-0 univer-flex-col univer-gap-0.5"+ >+ {showSectionHeaders && section.title && (() => {+ const sectionCollapsed = !!section.id && collapsedSectionIds.has(section.id);++ return (+ <button+ type="button"+ className="+ univer-box-border univer-flex univer-h-7 univer-w-full+ univer-items-center univer-gap-1 univer-rounded-md univer-border-0+ univer-bg-transparent univer-px-2 univer-pt-1 univer-text-xs+ univer-font-semibold univer-uppercase univer-text-gray-400+ univer-outline-none+ hover:univer-bg-gray-50 hover:univer-text-gray-600+ disabled:univer-cursor-default+ disabled:hover:univer-bg-transparent+ dark:!univer-text-gray-500+ dark:hover:!univer-bg-gray-800 dark:hover:!univer-text-gray-300+ "+ aria-label={sectionCollapsed ? labels.expand : labels.collapse}+ disabled={!section.id}+ onClick={() => toggleSectionCollapsed(section.id)}+ >+ {section.id+ ? (+ <span+ className="+ univer-flex univer-size-4 univer-shrink-0+ univer-items-center univer-justify-center+ "+ >+ {sectionCollapsed ? <MoreRightIcon /> : <MoreDownIcon />}+ </span>+ )+ : <span className="univer-size-4 univer-shrink-0" />}+ <span+ className="+ univer-min-w-0 univer-flex-1 univer-truncate univer-text-left+ "+ >+ {section.title}+ </span>+ <span+ className="+ univer-shrink-0 univer-text-[10px] univer-font-medium+ univer-text-gray-400+ dark:!univer-text-gray-500+ "+ >+ {section.items.length}+ </span>+ </button>+ );+ })()}+ {(!section.id || !collapsedSectionIds.has(section.id)) && section.items.map((item) => (+ <ObjectListRow+ key={item.id}+ item={item}+ selected={selectedIdSet.has(item.id)}+ labels={labels}+ showLock={!!onToggleSelectable && hasCapability(capabilities, item, 'selectable')}+ showName={hasCapability(capabilities, item, 'name')}+ showVisible={hasCapability(capabilities, item, 'visible')}+ draggable={canReorder && hasCapability(capabilities, item, 'reorder') && !item.disabled && item.canReorder !== false}+ dragging={draggingId === item.id}+ onSelect={(multiSelect) => onSelect(item.id, multiSelect)}+ onToggleExpanded={() => onToggleExpanded?.(item.id)}+ onToggleVisible={() => onSetVisible([item.id], !item.visible)}+ onToggleSelectable={() => onToggleSelectable?.(item.id)}+ onCommitName={(value) => onCommitName(item.id, value)}+ onDragStart={() => setDraggingId(item.id)}+ onDragEnd={() => setDraggingId(null)}+ onDrop={() => handleDrop(item.id)}+ />+ ))}+ </div>+ ))}+ </div>+ )}+ </div>++ <ObjectDetailsEditor+ item={selectedItem}+ labels={labels}+ showName={hasCapability(capabilities, selectedItem, 'name')}+ showDescription={hasCapability(capabilities, selectedItem, 'description')}+ onCommitName={(value) => selectedItem && onCommitName(selectedItem.id, value)}+ onCommitDescription={(value) => selectedItem && onCommitDescription(selectedItem.id, value)}+ />+ </div>+ );+}++function ObjectListRow(props: {+ item: IObjectListPanelItem;+ selected: boolean;+ labels: IObjectListPanelLabels;+ showLock: boolean;+ showName: boolean;+ showVisible: boolean;+ draggable: boolean;+ dragging: boolean;+ onSelect: (multiSelect: boolean) => void;+ onToggleExpanded: () => void;+ onToggleVisible: () => void;+ onToggleSelectable: () => void;+ onCommitName: (value: string) => void;+ onDragStart: () => void;+ onDragEnd: () => void;+ onDrop: () => void;+}) {+ const { item, selected, labels, showLock, showName, showVisible, draggable, dragging, onSelect, onToggleExpanded, onToggleVisible, onToggleSelectable, onCommitName, onDragStart, onDragEnd, onDrop } = props;+ const [draftName, setDraftName] = useState(item.name);+ const skipCommitOnBlurRef = useRef(false);+ const disabled = item.disabled === true;+ const level = item.level ?? 0;+ const locked = item.selectable === false;++ useEffect(() => {+ setDraftName(item.name);+ }, [item.name]);++ const handleBlur = (event: FocusEvent<HTMLInputElement>) => {+ if (disabled) {+ return;+ }+ if (skipCommitOnBlurRef.current) {+ skipCommitOnBlurRef.current = false;+ return;+ }+ if (event.currentTarget.value !== item.name) {+ onCommitName(event.currentTarget.value);+ }+ };++ const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {+ if (event.key === 'Enter') {+ event.currentTarget.blur();+ return;+ }+ if (event.key === 'Escape') {+ skipCommitOnBlurRef.current = true;+ setDraftName(item.name);+ event.currentTarget.blur();+ }+ };++ return (+ <div+ className={clsx(+ `+ univer-box-border univer-flex univer-h-8 univer-w-full univer-min-w-0 univer-max-w-full+ univer-items-center univer-gap-1.5 univer-overflow-hidden univer-rounded-md univer-pr-1.5+ univer-transition-colors+ `,+ !disabled && `+ hover:univer-bg-gray-100+ dark:hover:!univer-bg-gray-800+ `,+ selected && `+ univer-bg-gray-100+ dark:!univer-bg-gray-800+ `,+ disabled && `+ univer-text-gray-400+ dark:!univer-text-gray-500+ `,+ dragging && 'univer-opacity-50'+ )}+ style={{ paddingLeft: level * 14 + 4 }}+ draggable={draggable}+ title={draggable ? labels.dragToReorder : undefined}+ onClick={disabled ? undefined : (event: MouseEvent<HTMLDivElement>) => onSelect(event.ctrlKey || event.metaKey)}+ onDragStart={(event: DragEvent<HTMLDivElement>) => {+ if (!draggable) {+ event.preventDefault();+ return;+ }+ event.dataTransfer.effectAllowed = 'move';+ event.dataTransfer.setData('text/plain', item.id);+ onDragStart();+ }}+ onDragEnd={onDragEnd}+ onDragOver={(event: DragEvent<HTMLDivElement>) => {+ if (draggable) {+ event.preventDefault();+ event.dataTransfer.dropEffect = 'move';+ }+ }}+ onDrop={(event: DragEvent<HTMLDivElement>) => {+ event.preventDefault();+ onDrop();+ }}+ >+ {item.isGroup+ ? (+ <button+ type="button"+ className={expandButtonClassName}+ title={item.expanded ? labels.collapse : labels.expand}+ aria-label={item.expanded ? labels.collapse : labels.expand}+ onClick={(event) => {+ event.stopPropagation();+ onToggleExpanded();+ }}+ >+ {item.expanded ? <MoreDownIcon /> : <MoreRightIcon />}+ </button>+ )+ : <span className="univer-size-5 univer-shrink-0" />}+ {showName+ ? (+ <Input+ key={item.name}+ className={clsx('univer-h-7 univer-w-0 univer-min-w-0 univer-flex-1', disabled && `+ univer-cursor-not-allowed+ `)}+ inputClass={clsx(+ `+ !univer-h-7 univer-min-w-0 univer-overflow-hidden univer-text-ellipsis+ univer-whitespace-nowrap !univer-rounded !univer-border-transparent !univer-bg-transparent+ !univer-px-1 univer-text-sm univer-text-gray-900 !univer-shadow-none+ focus:!univer-border-primary-500 focus:!univer-bg-white focus:!univer-ring-1+ focus:!univer-ring-primary-100+ disabled:!univer-bg-transparent disabled:univer-opacity-100+ dark:!univer-text-gray-100+ dark:focus:!univer-bg-gray-900 dark:focus:!univer-ring-primary-900+ `,+ disabled && `+ univer-text-gray-400+ dark:!univer-text-gray-500+ `+ )}+ inputStyle={{ maxWidth: '100%', boxSizing: 'border-box' }}+ value={draftName}+ disabled={disabled}+ aria-label={labels.nameInput}+ onChange={setDraftName}+ onBlur={handleBlur}+ onKeyDown={handleKeyDown}+ onClick={(event) => {+ event.stopPropagation();+ if (!disabled) {+ onSelect(event.ctrlKey || event.metaKey);+ }+ }}+ />+ )+ : <span className="univer-min-w-0 univer-flex-1 univer-truncate univer-px-1 univer-text-sm">{item.name}</span>}+ {showLock && (+ <button+ type="button"+ className={clsx(iconButtonClassName, !locked && 'univer-opacity-70')}+ disabled={disabled}+ title={locked ? labels.unlock : labels.lock}+ aria-label={locked ? labels.unlock : labels.lock}+ onClick={(event) => {+ event.stopPropagation();+ onToggleSelectable();+ }}+ >+ <LockIcon />+ </button>+ )}+ {showVisible && (+ <button+ type="button"+ className={iconButtonClassName}+ disabled={disabled}+ title={item.visible ? labels.hide : labels.show}+ aria-label={item.visible ? labels.hide : labels.show}+ onClick={(event) => {+ event.stopPropagation();+ onToggleVisible();+ }}+ >+ {item.visible ? <EyeIcon /> : <EyelashIcon />}+ </button>+ )}+ </div>+ );+}++function ObjectDetailsEditor(props: {+ item: IObjectListPanelItem | null;+ labels: IObjectListPanelLabels;+ showName: boolean;+ showDescription: boolean;+ onCommitName: (value: string) => void;+ onCommitDescription: (value: string) => void;+}) {+ const { item, labels, showName, showDescription, onCommitName, onCommitDescription } = props;+ const [draftName, setDraftName] = useState(item?.name ?? '');+ const [draftDescription, setDraftDescription] = useState(item?.description ?? '');+ const disabled = item?.disabled === true;++ useEffect(() => {+ setDraftName(item?.name ?? '');+ setDraftDescription(item?.description ?? '');+ }, [item?.description, item?.id, item?.name]);++ if (!item) {+ return (+ <div+ className="+ univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-p-3 univer-text-sm+ univer-text-gray-500+ dark:!univer-border-gray-700 dark:!univer-text-gray-400+ "+ >+ {labels.noSelection}+ </div>+ );+ }++ return (+ <div+ className="+ univer-flex univer-shrink-0 univer-flex-col univer-gap-2 univer-border-0 univer-border-t+ univer-border-solid univer-border-gray-200 univer-pt-3+ dark:!univer-border-gray-700+ "+ >+ <div+ className="+ univer-text-xs univer-font-semibold univer-uppercase univer-text-gray-500+ dark:!univer-text-gray-400+ "+ >+ {labels.details}+ </div>+ {showName && (+ <label className="univer-flex univer-flex-col univer-gap-1">+ <span+ className="+ univer-text-xs univer-text-gray-500+ dark:!univer-text-gray-400+ "+ >+ {labels.name}+ </span>+ <Input+ value={draftName}+ aria-label={labels.nameInput}+ disabled={disabled}+ onChange={setDraftName}+ onBlur={() => {+ if (!disabled && normalizeText(draftName) !== item.name) {+ onCommitName(draftName);+ }+ }}+ onKeyDown={(event) => {+ if (event.key === 'Enter') {+ event.currentTarget.blur();+ }+ }}+ />+ </label>+ )}+ {showDescription && (+ <label className="univer-flex univer-flex-col univer-gap-1">+ <span+ className="+ univer-text-xs univer-text-gray-500+ dark:!univer-text-gray-400+ "+ >+ {labels.description}+ </span>+ <textarea+ className="+ univer-box-border univer-min-h-16 univer-w-full univer-resize-none univer-rounded-md+ univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-2+ univer-text-sm univer-text-gray-900 univer-outline-none+ focus:univer-border-primary-500 focus:univer-ring-1 focus:univer-ring-primary-100+ disabled:univer-cursor-not-allowed disabled:univer-opacity-70+ dark:!univer-border-gray-700 dark:!univer-bg-gray-900 dark:!univer-text-gray-100+ dark:focus:!univer-ring-primary-900+ "+ value={draftDescription}+ disabled={disabled}+ placeholder={labels.descriptionPlaceholder}+ aria-label={labels.description}+ onChange={(event) => setDraftDescription(event.currentTarget.value)}+ onBlur={() => {+ if (!disabled && normalizeText(draftDescription) !== (item.description ?? '')) {+ onCommitDescription(draftDescription);+ }+ }}+ />+ </label>+ )}+ </div>+ );+}++export const DrawingObjectListPanel = ObjectListPanelBase;++export type IDrawingObjectListItem = IObjectListPanelItem;+export type IDrawingObjectListPanelLabels = IObjectListPanelLabels;+export type IDrawingObjectListPanelProps = IObjectListPanelBaseProps;diff --git a/packages/drawing-ui/src/views/object-list-panel/object-list-panel-layer.ts b/packages/drawing-ui/src/views/object-list-panel/object-list-panel-layer.tsnew file mode 100644index 0000000000..f184a61d15--- /dev/null+++ b/packages/drawing-ui/src/views/object-list-panel/object-list-panel-layer.ts@@ -0,0 +1,37 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import type { DrawingType } from '@univerjs/core';+import { DrawingTypeEnum } from '@univerjs/core';++export const OBJECT_LIST_FLOATING_SECTION_ID = 'floating';+export const OBJECT_LIST_CANVAS_SECTION_ID = 'canvas';++export type ObjectListPanelSectionId =+ | typeof OBJECT_LIST_FLOATING_SECTION_ID+ | typeof OBJECT_LIST_CANVAS_SECTION_ID;++export function isFloatingObjectListDrawingType(drawingType: DrawingType | null | undefined): boolean {+ return drawingType === DrawingTypeEnum.DRAWING_CHART ||+ drawingType === DrawingTypeEnum.DRAWING_DOM ||+ drawingType === DrawingTypeEnum.DRAWING_UNIT;+}++export function getObjectListPanelSectionIdForDrawingType(drawingType: DrawingType | null | undefined): ObjectListPanelSectionId {+ return isFloatingObjectListDrawingType(drawingType)+ ? OBJECT_LIST_FLOATING_SECTION_ID+ : OBJECT_LIST_CANVAS_SECTION_ID;+}diff --git a/packages/drawing/src/services/__tests__/drawing-manager-impl.service.spec.ts b/packages/drawing/src/services/__tests__/drawing-manager-impl.service.spec.tsindex 1db836fa95..101832fd31 100644--- a/packages/drawing/src/services/__tests__/drawing-manager-impl.service.spec.ts+++ b/packages/drawing/src/services/__tests__/drawing-manager-impl.service.spec.ts@@ -110,6 +110,20 @@ describe('UnitDrawingService', () => {expect(service.getOldDrawingByParam(createSearch('b'))).toMatchObject(drawingB);});+ it('should build and apply update operations for newly added metadata fields', () => {+ const drawingA = createDrawing('a');++ service.applyJson1(unitId, subUnitId, service.getBatchAddOp([drawingA]).redo);++ const updateOp = service.getBatchUpdateOp([{ ...drawingA, hidden: true }]);+ service.applyJson1(unitId, subUnitId, updateOp.redo);++ expect(service.getDrawingByParam(createSearch('a'))).toMatchObject({+ drawingId: 'a',+ hidden: true,+ });+ });+it('expands grouped remove operations to include all nested drawing records', () => {service.applyJson1(unitId, subUnitId, service.getBatchAddOp([createDrawing('group', { drawingType: DrawingTypeEnum.DRAWING_GROUP }),diff --git a/packages/drawing/src/services/drawing-manager-impl.service.ts b/packages/drawing/src/services/drawing-manager-impl.service.tsindex 6dc5257c20..e1f460e31b 100644--- a/packages/drawing/src/services/drawing-manager-impl.service.ts+++ b/packages/drawing/src/services/drawing-manager-impl.service.ts@@ -42,6 +42,38 @@ enum DrawingMapItemType {order = 'order',}+function isNonEmptyOp(op: JSONOp): boolean {+ return Array.isArray(op) && op.length > 0;+}++function isJsonValueEqual(left: unknown, right: unknown): boolean {+ if (left === right) {+ return true;+ }++ if (left == null || right == null || typeof left !== 'object' || typeof right !== 'object') {+ return false;+ }++ if (Array.isArray(left) || Array.isArray(right)) {+ if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) {+ return false;+ }++ return left.every((item, index) => isJsonValueEqual(item, right[index]));+ }++ const leftRecord = left as Record<string, unknown>;+ const rightRecord = right as Record<string, unknown>;+ const leftKeys = Object.keys(leftRecord);+ const rightKeys = Object.keys(rightRecord);+ if (leftKeys.length !== rightKeys.length) {+ return false;+ }++ return leftKeys.every((key) => Object.prototype.hasOwnProperty.call(rightRecord, key) && isJsonValueEqual(leftRecord[key], rightRecord[key]));+}+interface IDrawingRefreshMetadata {behindText?: unknown;}@@ -349,11 +381,20 @@ export class UnitDrawingService<T extends IDrawingParam> implements IUnitDrawingconst invertOps: JSONOp[] = [];updateParams.forEach((updateParam) => {const { op, invertOp } = this._updateByParam(updateParam);+ if (!isNonEmptyOp(op)) {+ return;+ }+objects.push({ unitId: updateParam.unitId, subUnitId: updateParam.subUnitId, drawingId: updateParam.drawingId });ops.push(op);invertOps.push(invertOp);});+ if (ops.length === 0) {+ const { unitId, subUnitId } = updateParams[0];+ return { undo: null as unknown as JSONOp, redo: null as unknown as JSONOp, unitId, subUnitId, objects };+ }+const op = ops.reduce(json1.type.compose, null);const invertOp = invertOps.reduce(json1.type.compose, null);@@ -874,6 +915,10 @@ export class UnitDrawingService<T extends IDrawingParam> implements IUnitDrawing// this.drawingManagerInfo[unitId][subUnitId][drawingId] = newObject;+ if (ops.length === 0) {+ return { op: [] as unknown as JSONOp, invertOp: [] as unknown as JSONOp };+ }+const op = ops.reduce(json1.type.compose, null);const invertOp = json1.type.invertWithDoc(op, this.drawingManagerData as unknown as json1.Doc);@@ -894,16 +939,38 @@ export class UnitDrawingService<T extends IDrawingParam> implements IUnitDrawingconst ops: JSONOp[] = [];Object.keys(newParam as IDrawingParam).forEach((key) => {const newVal = newParam[key as keyof IDrawingParam];-+ const hasOldKey = Object.prototype.hasOwnProperty.call(oldParam, key);const oldVal = oldParam[key as keyof IDrawingParam];- if (oldVal === newVal) {+ if (hasOldKey && isJsonValueEqual(oldVal, newVal)) {return;}- ops.push(- json1.replaceOp([unitId, subUnitId, DrawingMapItemType.data, drawingId, key], oldVal as unknown as json1.Doc, newVal as unknown as json1.Doc)- );+ const path = [unitId, subUnitId, DrawingMapItemType.data, drawingId, key];+ if (!hasOldKey) {+ if (newVal === undefined) {+ return;+ }++ const op = json1.insertOp(path, newVal as unknown as json1.Doc);+ if (isNonEmptyOp(op)) {+ ops.push(op);+ }+ return;+ }++ if (newVal === undefined) {+ const op = json1.removeOp(path, true);+ if (isNonEmptyOp(op)) {+ ops.push(op);+ }+ return;+ }++ const op = json1.replaceOp(path, oldVal as unknown as json1.Doc, newVal as unknown as json1.Doc);+ if (isNonEmptyOp(op)) {+ ops.push(op);+ }});return ops;}diff --git a/packages/sheets-drawing-ui/src/services/__tests__/canvas-float-dom-manager.service.spec.ts b/packages/sheets-drawing-ui/src/services/__tests__/canvas-float-dom-manager.service.spec.tsindex a1b330bf35..2877aa99b6 100644--- a/packages/sheets-drawing-ui/src/services/__tests__/canvas-float-dom-manager.service.spec.ts+++ b/packages/sheets-drawing-ui/src/services/__tests__/canvas-float-dom-manager.service.spec.ts@@ -15,7 +15,9 @@*/import type { IWorkbookData } from '@univerjs/core';+import type { IDrawingJsonUndo1 } from '@univerjs/drawing';import type { IRender, IRenderManagerService as IRenderManagerServiceType, Scene } from '@univerjs/engine-render';+import type { ISheetFloatDom } from '@univerjs/sheets-drawing';import type { IFloatDom, IFloatDomLayout } from '@univerjs/ui';import type { ICanvasFloatDomInfo, ISheetFloatDomRenderObjectFactoryContext } from '../canvas-float-dom-manager.service';import {@@ -29,7 +31,7 @@ import {UniverInstanceType,} from '@univerjs/core';import { IRenderManagerService, Rect, SHEET_VIEWPORT_KEY, SpreadsheetSkeleton } from '@univerjs/engine-render';-import { InsertSheetDrawingCommand, ISheetDrawingService, RemoveSheetDrawingCommand, SetSheetDrawingCommand } from '@univerjs/sheets-drawing';+import { DrawingApplyType, InsertSheetDrawingCommand, ISheetDrawingService, RemoveSheetDrawingCommand, SetDrawingApplyMutation, SetSheetDrawingCommand } from '@univerjs/sheets-drawing';import { ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univerjs/sheets-ui';import { CanvasFloatDomService } from '@univerjs/ui';import { BehaviorSubject, Subject } from 'rxjs';@@ -612,6 +614,82 @@ describe('SheetCanvasFloatDomManagerService', () => {expect(findFloatDom(canvasFloatDomService, 'header-card')).toBeUndefined();});+ it('removes and restores float dom layers when the drawing hidden state changes', async () => {+ const fixture = setup();+ disposables.push(fixture);+ const canvasFloatDomService = fixture.get(CanvasFloatDomService);++ const drawing: ISheetFloatDom = {+ unitId: 'test',+ subUnitId: 'sheet1',+ drawingId: 'range-card',+ drawingType: DrawingTypeEnum.DRAWING_DOM,+ componentKey: 'RangeCard',+ data: { label: 'Range order' },+ allowTransform: true,+ transform: { left: 88, top: 34, width: 80, height: 24 },+ sheetTransform: {+ from: { row: 1, column: 1, rowOffset: 0, columnOffset: 0 },+ to: { row: 2, column: 2, rowOffset: 0, columnOffset: 0 },+ },+ axisAlignSheetTransform: {+ from: { row: 1, column: 1, rowOffset: 0, columnOffset: 0 },+ to: { row: 2, column: 2, rowOffset: 0, columnOffset: 0 },+ },+ };+ const addOp = fixture.get(ISheetDrawingService).getBatchAddOp([drawing]) as IDrawingJsonUndo1;++ expect(fixture.commandService.syncExecuteCommand(SetDrawingApplyMutation.id, {+ unitId: 'test',+ subUnitId: 'sheet1',+ op: addOp.redo,+ objects: addOp.objects,+ type: DrawingApplyType.INSERT,+ })).toBe(true);++ expect(findFloatDom(canvasFloatDomService, 'range-card')).toBeDefined();+ const rangeDrawing = fixture.get(ISheetDrawingService).getDrawingByParam({+ unitId: 'test',+ subUnitId: 'sheet1',+ drawingId: 'range-card',+ })!;+ const hiddenOp = fixture.get(ISheetDrawingService).getBatchUpdateOp([{ ...rangeDrawing, hidden: true }]) as IDrawingJsonUndo1;+ expect(hiddenOp.redo).not.toEqual([]);+ expect(hiddenOp.redo).not.toBeNull();++ expect(fixture.commandService.syncExecuteCommand(SetDrawingApplyMutation.id, {+ unitId: 'test',+ subUnitId: 'sheet1',+ op: hiddenOp.redo,+ objects: hiddenOp.objects,+ type: DrawingApplyType.UPDATE,+ })).toBe(true);++ expect(fixture.get(ISheetDrawingService).getDrawingByParam({+ unitId: 'test',+ subUnitId: 'sheet1',+ drawingId: 'range-card',+ })?.hidden).toBe(true);+ expect(findFloatDom(canvasFloatDomService, 'range-card')).toBeUndefined();++ const visibleDrawing = fixture.get(ISheetDrawingService).getDrawingByParam({+ unitId: 'test',+ subUnitId: 'sheet1',+ drawingId: 'range-card',+ })!;+ const visibleOp = fixture.get(ISheetDrawingService).getBatchUpdateOp([{ ...visibleDrawing, hidden: false }]) as IDrawingJsonUndo1;++ fixture.commandService.syncExecuteCommand(SetDrawingApplyMutation.id, {+ unitId: 'test',+ subUnitId: 'sheet1',+ op: visibleOp.redo,+ objects: visibleOp.objects,+ type: DrawingApplyType.UPDATE,+ });++ expect(findFloatDom(canvasFloatDomService, 'range-card')).toBeDefined();+ });+it('uses the registered render object factory for chart float dom rects without affecting normal float doms', () => {const fixture = setup();disposables.push(fixture);diff --git a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.tsindex b081210651..20228cfba0 100644--- a/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts+++ b/packages/sheets-drawing-ui/src/services/canvas-float-dom-manager.service.ts@@ -789,6 +789,16 @@ export class SheetCanvasFloatDomManagerService extends Disposable {return;}+ if (sheetDrawing.hidden) {+ this._removeDom(data.drawingId);+ return;+ }++ if (!this._domLayerInfoMap.has(data.drawingId)) {+ this._drawingManagerService.addNotification([data]);+ return;+ }+const newValue = {...sheetDrawing.transform,};