Skip to content

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.

chore: add config to set permission background & move watermark ui to… (#4042)

ybzky67b6b8b89e95
diff --git a/packages-experimental/debugger/package.json b/packages-experimental/debugger/package.json
index 85e7e94f90..1c3e168015 100644
--- a/packages-experimental/debugger/package.json
+++ b/packages-experimental/debugger/package.json
@@ -60,11 +60,14 @@
"@univerjs/core": "workspace:*",
"@univerjs/docs-ui": "workspace:*",
"@univerjs/engine-render": "workspace:*",
+ "@univerjs/icons": "^0.2.5",
"@univerjs/mockdata": "workspace:*",
"@univerjs/sheets": "workspace:*",
"@univerjs/sheets-drawing-ui": "workspace:*",
"@univerjs/ui": "workspace:*",
- "@vitejs/plugin-react": "4.3.3"
+ "@univerjs/watermark": "workspace:*",
+ "@vitejs/plugin-react": "4.3.3",
+ "clsx": "^2.1.1"
},
"optionalDependencies": {
"vue": ">=3.0.0"
diff --git a/packages/watermark/src/commands/operations/open-watermark-panel.operation.ts b/packages-experimental/debugger/src/commands/operations/open-watermark-panel.operation.ts
similarity index 97%
rename from packages/watermark/src/commands/operations/open-watermark-panel.operation.ts
rename to packages-experimental/debugger/src/commands/operations/open-watermark-panel.operation.ts
index 33236253e7..51e58f308d 100644
--- a/packages/watermark/src/commands/operations/open-watermark-panel.operation.ts
+++ b/packages-experimental/debugger/src/commands/operations/open-watermark-panel.operation.ts
@@ -17,7 +17,7 @@
import type { ICommand } from '@univerjs/core';
import { CommandType, LocaleService } from '@univerjs/core';
import { ISidebarService } from '@univerjs/ui';
-import { WATERMARK_PANEL, WATERMARK_PANEL_FOOTER } from '../../common/const';
+import { WATERMARK_PANEL, WATERMARK_PANEL_FOOTER } from '../../controllers/watermark.menu.controller';
export const OpenWatermarkPanelOperation: ICommand = {
type: CommandType.OPERATION,
diff --git a/packages-experimental/debugger/src/controllers/debugger.controller.ts b/packages-experimental/debugger/src/controllers/debugger.controller.ts
index c8fa8825d4..646c6de347 100644
--- a/packages-experimental/debugger/src/controllers/debugger.controller.ts
+++ b/packages-experimental/debugger/src/controllers/debugger.controller.ts
@@ -25,15 +25,16 @@ import { DialogOperation } from '../commands/operations/dialog.operation';
import { LocaleOperation } from '../commands/operations/locale.operation';
import { MessageOperation } from '../commands/operations/message.operation';
import { NotificationOperation } from '../commands/operations/notification.operation';
+import { OpenWatermarkPanelOperation } from '../commands/operations/open-watermark-panel.operation';
import { SaveSnapshotOptions } from '../commands/operations/save-snapshot.operations';
import { SetEditable } from '../commands/operations/set.editable.operation';
import { SidebarOperation } from '../commands/operations/sidebar.operation';
import { ThemeOperation } from '../commands/operations/theme.operation';
+
import { ImageDemo } from '../components/Image';
// @ts-ignore
import VueI18nIcon from '../components/VueI18nIcon.vue';
-
import { TEST_EDITOR_CONTAINER_COMPONENT } from '../views/test-editor/component-name';
import { TestEditorContainer } from '../views/test-editor/TestTextEditor';
import { RecordController } from './local-save/record.controller';
@@ -68,6 +69,7 @@ export class DebuggerController extends Disposable {
CreateFloatDomCommand,
ChangeUserCommand,
ShowCellContentOperation,
+ OpenWatermarkPanelOperation,
].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
this._injector.add([RecordController]);
diff --git a/packages-experimental/debugger/src/controllers/menu.schema.ts b/packages-experimental/debugger/src/controllers/menu.schema.ts
index d1f83e0fdd..b93e1299dc 100644
--- a/packages-experimental/debugger/src/controllers/menu.schema.ts
+++ b/packages-experimental/debugger/src/controllers/menu.schema.ts
@@ -24,6 +24,7 @@ import { DialogOperation } from '../commands/operations/dialog.operation';
import { LocaleOperation } from '../commands/operations/locale.operation';
import { MessageOperation } from '../commands/operations/message.operation';
import { NotificationOperation } from '../commands/operations/notification.operation';
+import { OpenWatermarkPanelOperation } from '../commands/operations/open-watermark-panel.operation';
import { SaveSnapshotOptions } from '../commands/operations/save-snapshot.operations';
import { SetEditable } from '../commands/operations/set.editable.operation';
import { SidebarOperation } from '../commands/operations/sidebar.operation';
@@ -49,6 +50,7 @@ import {
ThemeMenuItemFactory,
UNIT_ITEM_MENU_ID,
UnitMenuItemFactory,
+ WatermarkMenuItemFactory,
} from '../controllers/menu';
export const menuSchema: MenuSchemaType = {
@@ -125,5 +127,9 @@ export const menuSchema: MenuSchemaType = {
order: 11,
menuItemFactory: ChangeUserMenuItemFactory,
},
+ [OpenWatermarkPanelOperation.id]: {
+ order: 12,
+ menuItemFactory: WatermarkMenuItemFactory,
+ },
},
};
diff --git a/packages-experimental/debugger/src/controllers/menu.ts b/packages-experimental/debugger/src/controllers/menu.ts
index dadc9461d5..a69601dc7d 100644
--- a/packages-experimental/debugger/src/controllers/menu.ts
+++ b/packages-experimental/debugger/src/controllers/menu.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
+import type { IAccessor } from '@univerjs/core';
+import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
import { LocaleType } from '@univerjs/core';
import { defaultTheme, greenTheme } from '@univerjs/design';
import { MenuItemType } from '@univerjs/ui';
-import type { IAccessor } from '@univerjs/core';
-import type { IMenuButtonItem, IMenuSelectorItem } from '@univerjs/ui';
import { CreateFloatDomCommand } from '../commands/commands/float-dom.command';
import { CreateEmptySheetCommand, DisposeCurrentUnitCommand, DisposeUniverCommand, LoadSheetSnapshotCommand } from '../commands/commands/unit.command';
@@ -29,10 +29,12 @@ import { DialogOperation } from '../commands/operations/dialog.operation';
import { LocaleOperation } from '../commands/operations/locale.operation';
import { MessageOperation } from '../commands/operations/message.operation';
import { NotificationOperation } from '../commands/operations/notification.operation';
+import { OpenWatermarkPanelOperation } from '../commands/operations/open-watermark-panel.operation';
import { SaveSnapshotOptions } from '../commands/operations/save-snapshot.operations';
import { SetEditable } from '../commands/operations/set.editable.operation';
import { SidebarOperation } from '../commands/operations/sidebar.operation';
import { ThemeOperation } from '../commands/operations/theme.operation';
+import { UNIVER_WATERMARK_MENU } from './watermark.menu.controller';
export function LocaleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
return {
@@ -323,3 +325,13 @@ export function ChangeUserMenuItemFactory(): IMenuSelectorItem {
],
};
}
+
+export function WatermarkMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
+ return {
+ id: OpenWatermarkPanelOperation.id,
+ title: 'univer-watermark.title',
+ tooltip: 'univer-watermark.title',
+ icon: UNIVER_WATERMARK_MENU,
+ type: MenuItemType.BUTTON,
+ };
+}
diff --git a/packages/watermark/src/controllers/watermark.menu.controller.ts b/packages-experimental/debugger/src/controllers/watermark.menu.controller.ts
similarity index 78%
rename from packages/watermark/src/controllers/watermark.menu.controller.ts
rename to packages-experimental/debugger/src/controllers/watermark.menu.controller.ts
index aacd6b6d74..3832a85f87 100644
--- a/packages/watermark/src/controllers/watermark.menu.controller.ts
+++ b/packages-experimental/debugger/src/controllers/watermark.menu.controller.ts
@@ -17,10 +17,13 @@
import { Disposable, Inject } from '@univerjs/core';
import { WatermarkSingle } from '@univerjs/icons';
import { ComponentManager, IMenuManagerService } from '@univerjs/ui';
-import { UNIVER_WATERMARK_MENU, WATERMARK_PANEL, WATERMARK_PANEL_FOOTER } from '../common/const';
-import { WatermarkPanel } from '../views/components/WatermarkPanel';
-import { WatermarkPanelFooter } from '../views/components/WatermarkPanelFooter';
-import { menuSchema } from './menu.schema';
+import { WatermarkPanel } from '../views/watermark/WatermarkPanel';
+import { WatermarkPanelFooter } from '../views/watermark/WatermarkPanelFooter';
+
+export const UNIVER_WATERMARK_MENU = 'UNIVER_WATERMARK_MENU';
+export const WATERMARK_PANEL = 'WATERMARK_PANEL';
+
+export const WATERMARK_PANEL_FOOTER = 'WATERMARK_PANEL_FOOTER';
export class UniverWatermarkMenuController extends Disposable {
constructor(
@@ -28,7 +31,6 @@ export class UniverWatermarkMenuController extends Disposable {
@Inject(ComponentManager) private readonly _componentManager: ComponentManager
) {
super();
- this._initMenu();
this._initComponents();
}
@@ -41,8 +43,4 @@ export class UniverWatermarkMenuController extends Disposable {
this.disposeWithMe(this._componentManager.register(key, component));
});
}
-
- private _initMenu() {
- this._menuManagerService.mergeMenu(menuSchema);
- }
}
diff --git a/packages-experimental/debugger/src/debugger-plugin.ts b/packages-experimental/debugger/src/debugger-plugin.ts
index 3447db5d8b..36459ad109 100644
--- a/packages-experimental/debugger/src/debugger-plugin.ts
+++ b/packages-experimental/debugger/src/debugger-plugin.ts
@@ -21,6 +21,7 @@ import { defaultPluginConfig, PLUGIN_CONFIG_KEY } from './controllers/config.sch
import { DebuggerController } from './controllers/debugger.controller';
import { E2EController } from './controllers/e2e/e2e.controller';
import { PerformanceMonitorController } from './controllers/performance-monitor.controller';
+import { UniverWatermarkMenuController } from './controllers/watermark.menu.controller';
export class UniverDebuggerPlugin extends Plugin {
static override pluginName = 'UNIVER_DEBUGGER_PLUGIN';
@@ -47,6 +48,7 @@ export class UniverDebuggerPlugin extends Plugin {
[PerformanceMonitorController],
[DebuggerController],
[E2EController],
+ [UniverWatermarkMenuController],
] as Dependency[]).forEach((d) => this._injector.add(d));
this._injector.get(E2EController);
@@ -58,6 +60,7 @@ export class UniverDebuggerPlugin extends Plugin {
override onRendered(): void {
this._injector.get(PerformanceMonitorController);
+ this._injector.get(UniverWatermarkMenuController);
}
getDebuggerController() {
diff --git a/packages/watermark/src/views/components/WatermarkImageSetting.tsx b/packages-experimental/debugger/src/views/watermark/WatermarkImageSetting.tsx
similarity index 98%
rename from packages/watermark/src/views/components/WatermarkImageSetting.tsx
rename to packages-experimental/debugger/src/views/watermark/WatermarkImageSetting.tsx
index 11b236b203..fea3dc78f4 100644
--- a/packages/watermark/src/views/components/WatermarkImageSetting.tsx
+++ b/packages-experimental/debugger/src/views/watermark/WatermarkImageSetting.tsx
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import type { IImageWatermarkConfig } from '../../common/type';
+import type { IImageWatermarkConfig } from '@univerjs/watermark';
import { LocaleService, useDependency } from '@univerjs/core';
import { Button, Checkbox, InputNumber } from '@univerjs/design';
import { ILocalFileService } from '@univerjs/ui';
+import { WATERMARK_IMAGE_ALLOW_IMAGE_LIST } from '@univerjs/watermark';
import React from 'react';
-import { WATERMARK_IMAGE_ALLOW_IMAGE_LIST } from '../../common/const';
import styles from './index.module.less';
interface IWatermarkImageSettingProps {
diff --git a/packages/watermark/src/views/components/WatermarkPanel.tsx b/packages-experimental/debugger/src/views/watermark/WatermarkPanel.tsx
similarity index 93%
rename from packages/watermark/src/views/components/WatermarkPanel.tsx
rename to packages-experimental/debugger/src/views/watermark/WatermarkPanel.tsx
index 2f55aef18a..367fb70b92 100644
--- a/packages/watermark/src/views/components/WatermarkPanel.tsx
+++ b/packages-experimental/debugger/src/views/watermark/WatermarkPanel.tsx
@@ -14,13 +14,11 @@
* limitations under the License.
*/
-import type { IWatermarkConfig, IWatermarkConfigWithType } from '../../common/type';
+import type { IWatermarkConfig, IWatermarkConfigWithType } from '@univerjs/watermark';
import { ILocalStorageService, LocaleService, useDependency, useObservable } from '@univerjs/core';
import { Select } from '@univerjs/design';
+import { IWatermarkTypeEnum, UNIVER_WATERMARK_STORAGE_KEY, WatermarkImageBaseConfig, WatermarkService, WatermarkTextBaseConfig } from '@univerjs/watermark';
import React, { useCallback, useEffect, useState } from 'react';
-import { UNIVER_WATERMARK_STORAGE_KEY, WatermarkImageBaseConfig, WatermarkTextBaseConfig } from '../../common/const';
-import { IWatermarkTypeEnum } from '../../common/type';
-import { WatermarkService } from '../../services/watermark.service';
import styles from './index.module.less';
import { WatermarkImageSetting } from './WatermarkImageSetting';
import { WatermarkTextSetting } from './WatermarkTextSetting';
diff --git a/packages/watermark/src/views/components/WatermarkPanelFooter.tsx b/packages-experimental/debugger/src/views/watermark/WatermarkPanelFooter.tsx
similarity index 94%
rename from packages/watermark/src/views/components/WatermarkPanelFooter.tsx
rename to packages-experimental/debugger/src/views/watermark/WatermarkPanelFooter.tsx
index aabb9c14b1..9b83b23d34 100644
--- a/packages/watermark/src/views/components/WatermarkPanelFooter.tsx
+++ b/packages-experimental/debugger/src/views/watermark/WatermarkPanelFooter.tsx
@@ -17,10 +17,8 @@
import { LocaleService, useDependency } from '@univerjs/core';
import { Button } from '@univerjs/design';
import { IClipboardInterfaceService, ISidebarService } from '@univerjs/ui';
+import { IWatermarkTypeEnum, WatermarkService, WatermarkTextBaseConfig } from '@univerjs/watermark';
import React from 'react';
-import { WatermarkTextBaseConfig } from '../../common/const';
-import { IWatermarkTypeEnum } from '../../common/type';
-import { WatermarkService } from '../../services/watermark.service';
import styles from './index.module.less';
export const WatermarkPanelFooter: React.FC = () => {
diff --git a/packages/watermark/src/views/components/WatermarkTextSetting.tsx b/packages-experimental/debugger/src/views/watermark/WatermarkTextSetting.tsx
similarity index 99%
rename from packages/watermark/src/views/components/WatermarkTextSetting.tsx
rename to packages-experimental/debugger/src/views/watermark/WatermarkTextSetting.tsx
index 4abbb831a3..2ed93856f8 100644
--- a/packages/watermark/src/views/components/WatermarkTextSetting.tsx
+++ b/packages-experimental/debugger/src/views/watermark/WatermarkTextSetting.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { ITextWatermarkConfig } from '../../common/type';
+import type { ITextWatermarkConfig } from '@univerjs/watermark';
import { LocaleService, useDependency } from '@univerjs/core';
import { Checkbox, ColorPicker, Dropdown, Input, InputNumber, Select } from '@univerjs/design';
import { BoldSingle, FontColor, ItalicSingle } from '@univerjs/icons';
diff --git a/packages/watermark/src/views/components/index.module.less b/packages-experimental/debugger/src/views/watermark/index.module.less
similarity index 100%
rename from packages/watermark/src/views/components/index.module.less
rename to packages-experimental/debugger/src/views/watermark/index.module.less
diff --git a/packages/sheets-ui/src/consts/permission.ts b/packages/sheets-ui/src/consts/permission.ts
index 4341b93fc7..ce327ff614 100644
--- a/packages/sheets-ui/src/consts/permission.ts
+++ b/packages/sheets-ui/src/consts/permission.ts
@@ -19,6 +19,7 @@ import { UnitAction } from '@univerjs/protocol';
export const UNIVER_SHEET_PERMISSION_PLUGIN_NAME = 'UNIVER_SHEET_PERMISSION_PLUGIN';
export const UNIVER_SHEET_PERMISSION_PANEL = 'UNIVER_SHEET_PERMISSION_PANEL';
export const UNIVER_SHEET_PERMISSION_USER_PART = 'UNIVER_SHEET_PERMISSION_USER_PART';
+export const UNIVER_SHEET_PERMISSION_BACKGROUND = 'UNIVER_SHEET_PERMISSION_BACKGROUND';
export const UNIVER_SHEET_PERMISSION_PANEL_FOOTER = 'UNIVER_SHEET_PERMISSION_PANEL_FOOTER';
export const UNIVER_SHEET_PERMISSION_USER_DIALOG = 'UNIVER_SHEET_PERMISSION_USER_DIALOG';
export const UNIVER_SHEET_PERMISSION_DIALOG = 'UNIVER_SHEET_PERMISSION_DIALOG';
diff --git a/packages/sheets-ui/src/controllers/config.schema.ts b/packages/sheets-ui/src/controllers/config.schema.ts
index 81fe980112..eb48fab272 100644
--- a/packages/sheets-ui/src/controllers/config.schema.ts
+++ b/packages/sheets-ui/src/controllers/config.schema.ts
@@ -25,6 +25,7 @@ export interface IUniverSheetsUIConfig {
menu?: MenuConfig;
disableAutoFocus?: true;
override?: DependencyOverride;
+ customComponents?: Set<string>;
/**
* Whether to show the formula bar.
diff --git a/packages/sheets-ui/src/controllers/permission/sheet-permission-render.controller.ts b/packages/sheets-ui/src/controllers/permission/sheet-permission-render.controller.ts
index ffd3aa569b..83f0d26a6e 100644
--- a/packages/sheets-ui/src/controllers/permission/sheet-permission-render.controller.ts
+++ b/packages/sheets-ui/src/controllers/permission/sheet-permission-render.controller.ts
@@ -16,13 +16,13 @@
import type { IRenderContext, IRenderModule, Spreadsheet } from '@univerjs/engine-render';
import type { MenuConfig } from '@univerjs/ui';
-import { connectInjector, Disposable, Inject, Injector, IPermissionService, IUniverInstanceService } from '@univerjs/core';
+import { connectInjector, Disposable, IConfigService, Inject, Injector, IPermissionService, IUniverInstanceService } from '@univerjs/core';
import { IRenderManagerService } from '@univerjs/engine-render';
import { CheckMarkSingle, DeleteSingle, LockSingle, ProtectSingle, WriteSingle } from '@univerjs/icons';
import { RangeProtectionRuleModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';
import { ComponentManager, IUIPartsService } from '@univerjs/ui';
import { merge, throttleTime } from 'rxjs';
-import { permissionCheckIconKey, permissionDeleteIconKey, permissionEditIconKey, permissionLockIconKey, permissionMenuIconKey, UNIVER_SHEET_PERMISSION_DIALOG, UNIVER_SHEET_PERMISSION_PANEL, UNIVER_SHEET_PERMISSION_USER_DIALOG, UNIVER_SHEET_PERMISSION_USER_PART } from '../../consts/permission';
+import { permissionCheckIconKey, permissionDeleteIconKey, permissionEditIconKey, permissionLockIconKey, permissionMenuIconKey, UNIVER_SHEET_PERMISSION_BACKGROUND, UNIVER_SHEET_PERMISSION_DIALOG, UNIVER_SHEET_PERMISSION_PANEL, UNIVER_SHEET_PERMISSION_USER_DIALOG, UNIVER_SHEET_PERMISSION_USER_PART } from '../../consts/permission';
import { SheetSkeletonManagerService } from '../../services/sheet-skeleton-manager.service';
import { SheetPermissionDialog, SheetPermissionPanel, SheetPermissionUserDialog } from '../../views/permission';
import { AlertDialog } from '../../views/permission/error-msg-dialog';
@@ -30,6 +30,7 @@ import { UNIVER_SHEET_PERMISSION_ALERT_DIALOG } from '../../views/permission/err
import { RANGE_PROTECTION_CAN_NOT_VIEW_RENDER_EXTENSION_KEY, RANGE_PROTECTION_CAN_VIEW_RENDER_EXTENSION_KEY, RangeProtectionCanNotViewRenderExtension, RangeProtectionCanViewRenderExtension } from '../../views/permission/extensions/range-protection.render';
import { worksheetProtectionKey, WorksheetProtectionRenderExtension } from '../../views/permission/extensions/worksheet-permission.render';
import { PermissionDetailUserPart } from '../../views/permission/panel-detail/PermissionDetailUserPart';
+import { type IUniverSheetsUIConfig, PLUGIN_CONFIG_KEY } from '../config.schema';
export interface IUniverSheetsPermissionMenuConfig {
menu: MenuConfig;
@@ -70,7 +71,11 @@ export class SheetPermissionRenderManagerController extends Disposable {
}
private _initUiPartComponents(): void {
- this.disposeWithMe(this._uiPartsService.registerComponent(UNIVER_SHEET_PERMISSION_USER_PART, () => connectInjector(PermissionDetailUserPart, this._injector)));
+ const configService = this._injector.get(IConfigService);
+ const config = configService.getConfig<IUniverSheetsUIConfig>(PLUGIN_CONFIG_KEY);
+ if (!config?.customComponents?.has(UNIVER_SHEET_PERMISSION_USER_PART)) {
+ this.disposeWithMe(this._uiPartsService.registerComponent(UNIVER_SHEET_PERMISSION_USER_PART, () => connectInjector(PermissionDetailUserPart, this._injector)));
+ }
}
}
@@ -82,10 +87,15 @@ export class SheetPermissionRenderController extends Disposable implements IRend
private readonly _context: IRenderContext,
@Inject(RangeProtectionRuleModel) private _rangeProtectionRuleModel: RangeProtectionRuleModel,
@Inject(SheetSkeletonManagerService) private _sheetSkeletonManagerService: SheetSkeletonManagerService,
- @IPermissionService private _permissionService: IPermissionService
+ @IPermissionService private _permissionService: IPermissionService,
+ @IConfigService private _configService: IConfigService
) {
super();
+ const config = this._configService.getConfig<IUniverSheetsUIConfig>(PLUGIN_CONFIG_KEY);
+ if (config?.customComponents?.has(UNIVER_SHEET_PERMISSION_BACKGROUND)) {
+ return;
+ }
this._initRender();
this._initSkeleton();
@@ -132,10 +142,16 @@ export class WorksheetProtectionRenderController extends Disposable implements I
@Inject(IRenderManagerService) private _renderManagerService: IRenderManagerService,
@Inject(IUniverInstanceService) private _univerInstanceService: IUniverInstanceService,
@Inject(SheetSkeletonManagerService) private _sheetSkeletonManagerService: SheetSkeletonManagerService,
- @Inject(WorksheetProtectionRuleModel) private _worksheetProtectionRuleModel: WorksheetProtectionRuleModel
-
+ @Inject(WorksheetProtectionRuleModel) private _worksheetProtectionRuleModel: WorksheetProtectionRuleModel,
+ @Inject(IConfigService) private _configService: IConfigService
) {
super();
+
+ const config = this._configService.getConfig<IUniverSheetsUIConfig>(PLUGIN_CONFIG_KEY);
+ if (config?.customComponents?.has(UNIVER_SHEET_PERMISSION_BACKGROUND)) {
+ return;
+ }
+
this._initRender();
this._initSkeleton();
}
diff --git a/packages/sheets-ui/src/index.ts b/packages/sheets-ui/src/index.ts
index 6d6c1c16b4..9ecec6de75 100644
--- a/packages/sheets-ui/src/index.ts
+++ b/packages/sheets-ui/src/index.ts
@@ -185,5 +185,6 @@ export { SetZoomRatioOperation } from './commands/operations/set-zoom-ratio.oper
export { SheetPermissionOpenDialogOperation } from './commands/operations/sheet-permission-open-dialog.operation';
export { SheetPermissionOpenPanelOperation } from './commands/operations/sheet-permission-open-panel.operation';
export { SidebarDefinedNameOperation } from './commands/operations/sidebar-defined-name.operation';
+export { UNIVER_SHEET_PERMISSION_BACKGROUND, UNIVER_SHEET_PERMISSION_USER_PART } from './consts/permission';
// #endregion
diff --git a/packages/watermark/src/controllers/config.schema.ts b/packages/watermark/src/controllers/config.schema.ts
index 7eb5f6ee4c..cadeced012 100644
--- a/packages/watermark/src/controllers/config.schema.ts
+++ b/packages/watermark/src/controllers/config.schema.ts
@@ -23,7 +23,6 @@ export const configSymbol = Symbol(PLUGIN_CONFIG_KEY);
export interface IUniverWatermarkConfig {
menu?: MenuConfig;
- showMenu?: boolean;
userWatermarkSettings?: Partial<IUserInfoWatermarkConfig>;
textWatermarkSettings?: Partial<ITextWatermarkConfig>;
imageWatermarkSettings?: Partial<IImageWatermarkConfig>;
diff --git a/packages/watermark/src/controllers/menu.schema.ts b/packages/watermark/src/controllers/menu.schema.ts
deleted file mode 100644
index c743df00b7..0000000000
--- a/packages/watermark/src/controllers/menu.schema.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * 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 { MenuSchemaType } from '@univerjs/ui';
-import { RibbonStartGroup } from '@univerjs/ui';
-import { OpenWatermarkPanelOperation } from '../commands/operations/open-watermark-panel.operation';
-import { WatermarkMenuItemFactory } from './menu';
-
-export const menuSchema: MenuSchemaType = {
- [RibbonStartGroup.OTHERS]: {
- [OpenWatermarkPanelOperation.id]: {
- order: 0,
- menuItemFactory: WatermarkMenuItemFactory,
- },
- },
-};
-
diff --git a/packages/watermark/src/controllers/menu.ts b/packages/watermark/src/controllers/menu.ts
deleted file mode 100644
index efa6a916ce..0000000000
--- a/packages/watermark/src/controllers/menu.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Inc.
- *
- * 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 { IMenuButtonItem } from '@univerjs/ui';
-import { DOCS_ZEN_EDITOR_UNIT_ID_KEY, type IAccessor, IUniverInstanceService } from '@univerjs/core';
-import { MenuItemType } from '@univerjs/ui';
-import { of, switchMap } from 'rxjs';
-import { OpenWatermarkPanelOperation } from '../commands/operations/open-watermark-panel.operation';
-import { UNIVER_WATERMARK_MENU } from '../common/const';
-
-export function WatermarkMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
- return {
- id: OpenWatermarkPanelOperation.id,
- title: 'univer-watermark.title',
- tooltip: 'univer-watermark.title',
- icon: UNIVER_WATERMARK_MENU,
- type: MenuItemType.BUTTON,
- hidden$: getWatermarkMenuHiddenObservable(accessor),
- };
-}
-
-function getWatermarkMenuHiddenObservable(accessor: IAccessor) {
- const univerInstanceService = accessor.get(IUniverInstanceService);
- return univerInstanceService.focused$.pipe(
- switchMap((id) => {
- if (id === DOCS_ZEN_EDITOR_UNIT_ID_KEY) {
- return of(true);
- } else {
- return of(false);
- }
- })
- );
-}
-
diff --git a/packages/watermark/src/index.ts b/packages/watermark/src/index.ts
index 6b074e1dd3..aa8a2d3f39 100644
--- a/packages/watermark/src/index.ts
+++ b/packages/watermark/src/index.ts
@@ -15,7 +15,9 @@
*/
export { UniverWatermarkPlugin } from './plugin';
-export { WatermarkImageBaseConfig, WatermarkTextBaseConfig, WatermarkUserInfoBaseConfig } from './common/const';
+export { UNIVER_WATERMARK_STORAGE_KEY, WATERMARK_IMAGE_ALLOW_IMAGE_LIST, WatermarkImageBaseConfig, WatermarkTextBaseConfig, WatermarkUserInfoBaseConfig } from './common/const';
export type { IImageWatermarkConfig, ITextWatermarkConfig } from './common/type';
export { IWatermarkTypeEnum } from './common/type';
export { WatermarkService } from './services/watermark.service';
+export type { IWatermarkConfig, IWatermarkConfigWithType } from './common/type';
+
diff --git a/packages/watermark/src/plugin.ts b/packages/watermark/src/plugin.ts
index 229c9b54a8..3b986afbcc 100644
--- a/packages/watermark/src/plugin.ts
+++ b/packages/watermark/src/plugin.ts
@@ -17,12 +17,10 @@
import type { Dependency } from '@univerjs/core';
import type { IWatermarkConfigWithType } from './common/type';
import type { IUniverWatermarkConfig } from './controllers/config.schema';
-import { ICommandService, IConfigService, ILocalStorageService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
+import { IConfigService, ILocalStorageService, Inject, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
import { IRenderManagerService } from '@univerjs/engine-render';
-import { OpenWatermarkPanelOperation } from './commands/operations/open-watermark-panel.operation';
import { UNIVER_WATERMARK_STORAGE_KEY, WatermarkImageBaseConfig, WatermarkTextBaseConfig, WatermarkUserInfoBaseConfig } from './common/const';
import { IWatermarkTypeEnum } from './common/type';
-import { UniverWatermarkMenuController } from './controllers/watermark.menu.controller';
import { WatermarkRenderController } from './controllers/watermark.render.controller';
import { WatermarkService } from './services/watermark.service';
@@ -35,7 +33,6 @@ export class UniverWatermarkPlugin extends Plugin {
private readonly _config: Partial<IUniverWatermarkConfig> = {},
@Inject(Injector) protected override _injector: Injector,
@IConfigService private readonly _configService: IConfigService,
- @Inject(ICommandService) private readonly _commandService: ICommandService,
@IRenderManagerService private readonly _renderManagerSrv: IRenderManagerService,
@Inject(ILocalStorageService) private readonly _localStorageService: ILocalStorageService
) {
@@ -48,7 +45,6 @@ export class UniverWatermarkPlugin extends Plugin {
this._initWatermarkStorage();
this._initDependencies();
- this._initRegisterCommand();
}
private async _initWatermarkStorage() {
@@ -68,27 +64,14 @@ export class UniverWatermarkPlugin extends Plugin {
}
private _initDependencies(): void {
- ([[WatermarkService], [UniverWatermarkMenuController]] as Dependency[]).forEach((d) => {
+ ([[WatermarkService]] as Dependency[]).forEach((d) => {
this._injector.add(d);
});
}
- private _initRegisterCommand(): void {
- [
- OpenWatermarkPanelOperation,
- ].forEach((m) => this._commandService.registerCommand(m));
- }
-
override onRendered(): void {
const injector = this._injector;
injector.get(WatermarkService);
-
- const { userWatermarkSettings, textWatermarkSettings, imageWatermarkSettings, showMenu = true } = this._config;
- const shouldDisplayUI = !(userWatermarkSettings || textWatermarkSettings || imageWatermarkSettings) && showMenu;
- if (shouldDisplayUI) {
- injector.get(UniverWatermarkMenuController);
- }
-
this._initRenderDependencies();
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 978b83bac2..99d93e2a33 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -632,6 +632,9 @@ importers:
'@univerjs/engine-render':
specifier: workspace:*
version: link:../../packages/engine-render
+ '@univerjs/icons':
+ specifier: ^0.2.5
'@univerjs/mockdata':
specifier: workspace:*
version: link:../../mockdata
@@ -644,9 +647,15 @@ importers:
'@univerjs/ui':
specifier: workspace:*
version: link:../../packages/ui
+ '@univerjs/watermark':
+ specifier: workspace:*
+ version: link:../../packages/watermark
'@vitejs/plugin-react':
specifier: 4.3.3
+ clsx:
+ specifier: ^2.1.1
+ version: 2.1.1
react:
specifier: ^16.9.0 || ^17.0.0 || ^18.0.0
version: 18.3.1