@univerjs/docs-drawing-ui 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +37 -26
- package/lib/types/controllers/config.schema.d.ts +20 -0
- package/lib/types/controllers/doc-drawing.controller.d.ts +3 -3
- package/lib/types/controllers/menu.schema.d.ts +2 -0
- package/lib/types/plugin.d.ts +5 -2
- package/lib/types/views/menu/image.menu.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +20 -20
package/lib/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
-
import { CommandType, ICommandService, IUniverInstanceService, TextX, JSONX, MemoryCursor, TextXActionType, LocaleService, RxDisposable, UniverInstanceType, toDisposable, FOCUSING_COMMON_DRAWINGS, OnLifecycle, LifecycleStages, Inject, IContextService, useDependency, PositionedObjectLayoutType, BooleanNumber, ObjectRelativeFromH, ObjectRelativeFromV, Tools, WrapTextType, Direction, IUndoRedoService, FOCUSING_UNIVER_EDITOR, Disposable, Injector, fromEventSubject, LifecycleService, UndoCommand, RedoCommand, throttle, COLORS, Plugin, DependentOn } from "@univerjs/core";
|
|
5
|
+
import { CommandType, ICommandService, IUniverInstanceService, TextX, JSONX, MemoryCursor, TextXActionType, LocaleService, RxDisposable, UniverInstanceType, toDisposable, FOCUSING_COMMON_DRAWINGS, OnLifecycle, LifecycleStages, Inject, IContextService, useDependency, PositionedObjectLayoutType, BooleanNumber, ObjectRelativeFromH, ObjectRelativeFromV, Tools, WrapTextType, Direction, IUndoRedoService, FOCUSING_UNIVER_EDITOR, Disposable, Injector, fromEventSubject, LifecycleService, UndoCommand, RedoCommand, throttle, COLORS, Plugin, DependentOn, IConfigService } from "@univerjs/core";
|
|
6
6
|
import { ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, DrawingCommonPanel, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
|
|
7
7
|
import { IDrawingManagerService, DRAWING_IMAGE_ALLOW_IMAGE_LIST, ArrangeTypeEnum, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DrawingTypeEnum, getDrawingShapeKeyByDrawingSearch, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, IImageIoService, UniverDrawingPlugin } from "@univerjs/drawing";
|
|
8
8
|
import { IDocDrawingService, UniverDocsDrawingPlugin } from "@univerjs/docs-drawing";
|
|
@@ -10,7 +10,7 @@ import { ITextSelectionRenderManager, IRenderManagerService, DocumentEditArea, L
|
|
|
10
10
|
import { takeUntil, Observable, BehaviorSubject, filter, debounceTime } from "rxjs";
|
|
11
11
|
import { DocCanvasPopManagerService, docDrawingPositionToTransform } from "@univerjs/docs-ui";
|
|
12
12
|
import { RichTextEditingMutation, getRichTextEditPath, TextSelectionManagerService, DocSkeletonManagerService, getRetainAndDeleteFromReplace, getCustomBlockIdsInSelections, SetDocZoomRatioOperation, getDocObject } from "@univerjs/docs";
|
|
13
|
-
import { ISidebarService, MenuItemType,
|
|
13
|
+
import { ISidebarService, MenuItemType, getMenuHiddenObservable, KeyCode, RibbonStartGroup, ComponentManager, IMenuManagerService, IShortcutService, IMessageService, IEditorService } from "@univerjs/ui";
|
|
14
14
|
import React, { forwardRef, useRef, createElement, useState, useEffect } from "react";
|
|
15
15
|
import clsx from "clsx";
|
|
16
16
|
import { RadioGroup, Radio, InputNumber, Select, Checkbox, MessageType } from "@univerjs/design";
|
|
@@ -145,15 +145,19 @@ let DocDrawingPopupMenuController = (_a = class extends RxDisposable {
|
|
|
145
145
|
const oKey = object.oKey, drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
|
|
146
146
|
if (!drawingParam)
|
|
147
147
|
return;
|
|
148
|
-
const { unitId: unitId2, subUnitId, drawingId } = drawingParam
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
const { unitId: unitId2, subUnitId, drawingId } = drawingParam, popup = this._canvasPopManagerService.attachPopupToObject(
|
|
149
|
+
object,
|
|
150
|
+
{
|
|
151
|
+
componentKey: COMPONENT_IMAGE_POPUP_MENU,
|
|
152
|
+
direction: "horizontal",
|
|
153
|
+
offset: [2, 0],
|
|
154
|
+
extraProps: {
|
|
155
|
+
menuItems: this._getImageMenuItems(unitId2, subUnitId, drawingId)
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
unitId2
|
|
159
|
+
);
|
|
160
|
+
disposePopups.push(this.disposeWithMe(popup)), !this._drawingManagerService.getFocusDrawings().find((drawing) => drawing.unitId === unitId2 && drawing.subUnitId === subUnitId && drawing.drawingId === drawingId) && this._drawingManagerService.focusDrawing([{
|
|
157
161
|
unitId: unitId2,
|
|
158
162
|
subUnitId,
|
|
159
163
|
drawingId
|
|
@@ -335,8 +339,6 @@ function ImageMenuFactory(accessor) {
|
|
|
335
339
|
return {
|
|
336
340
|
id: IMAGE_MENU_ID,
|
|
337
341
|
type: MenuItemType.SUBITEMS,
|
|
338
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
339
|
-
group: MenuGroup.TOOLBAR_LAYOUT,
|
|
340
342
|
icon: ImageUploadIcon,
|
|
341
343
|
tooltip: "docImage.title",
|
|
342
344
|
disabled$: getDisableWhenSelectionInTableObservable(accessor),
|
|
@@ -352,7 +354,6 @@ function UploadFloatImageMenuFactory(_accessor) {
|
|
|
352
354
|
label: {
|
|
353
355
|
name: COMPONENT_DOC_UPLOAD_FILE_MENU
|
|
354
356
|
},
|
|
355
|
-
positions: [IMAGE_MENU_ID],
|
|
356
357
|
hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_DOC)
|
|
357
358
|
};
|
|
358
359
|
}
|
|
@@ -1388,6 +1389,17 @@ const MoveDrawingDownShortcutItem = {
|
|
|
1388
1389
|
preconditions: whenDocDrawingFocused,
|
|
1389
1390
|
binding: KeyCode.DELETE,
|
|
1390
1391
|
mac: KeyCode.BACKSPACE
|
|
1392
|
+
}, menuSchema = {
|
|
1393
|
+
[RibbonStartGroup.LAYOUT]: {
|
|
1394
|
+
[IMAGE_MENU_ID]: {
|
|
1395
|
+
order: 0,
|
|
1396
|
+
menuItemFactory: ImageMenuFactory,
|
|
1397
|
+
[IMAGE_MENU_UPLOAD_FLOAT_ID]: {
|
|
1398
|
+
order: 0,
|
|
1399
|
+
menuItemFactory: UploadFloatImageMenuFactory
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1391
1403
|
};
|
|
1392
1404
|
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1393
1405
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -1395,20 +1407,15 @@ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPrope
|
|
|
1395
1407
|
return kind && result && __defProp$5(target, key, result), result;
|
|
1396
1408
|
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a2;
|
|
1397
1409
|
let DocDrawingUIController = (_a2 = class extends Disposable {
|
|
1398
|
-
constructor(_injector, _componentManager,
|
|
1399
|
-
super(), this._injector = _injector, this._componentManager = _componentManager, this.
|
|
1410
|
+
constructor(_injector, _componentManager, _menuManagerService, _commandService, _shortcutService) {
|
|
1411
|
+
super(), this._injector = _injector, this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
|
|
1400
1412
|
}
|
|
1401
1413
|
_initCustomComponents() {
|
|
1402
1414
|
const componentManager = this._componentManager;
|
|
1403
1415
|
this.disposeWithMe(componentManager.register(ImageUploadIcon, AddImageSingle)), this.disposeWithMe(componentManager.register(COMPONENT_DOC_UPLOAD_FILE_MENU, UploadFileMenu)), this.disposeWithMe(componentManager.register(COMPONENT_DOC_DRAWING_PANEL, DocDrawingPanel));
|
|
1404
1416
|
}
|
|
1405
1417
|
_initMenus() {
|
|
1406
|
-
|
|
1407
|
-
ImageMenuFactory,
|
|
1408
|
-
UploadFloatImageMenuFactory
|
|
1409
|
-
].forEach((factory) => {
|
|
1410
|
-
this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(factory), {}));
|
|
1411
|
-
});
|
|
1418
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
1412
1419
|
}
|
|
1413
1420
|
_initCommands() {
|
|
1414
1421
|
[
|
|
@@ -1451,7 +1458,7 @@ DocDrawingUIController = __decorateClass$5([
|
|
|
1451
1458
|
OnLifecycle(LifecycleStages.Ready, DocDrawingUIController),
|
|
1452
1459
|
__decorateParam$5(0, Inject(Injector)),
|
|
1453
1460
|
__decorateParam$5(1, Inject(ComponentManager)),
|
|
1454
|
-
__decorateParam$5(2,
|
|
1461
|
+
__decorateParam$5(2, IMenuManagerService),
|
|
1455
1462
|
__decorateParam$5(3, ICommandService),
|
|
1456
1463
|
__decorateParam$5(4, IShortcutService)
|
|
1457
1464
|
], DocDrawingUIController);
|
|
@@ -2453,6 +2460,7 @@ DocDrawingTransformerController = __decorateClass$1([
|
|
|
2453
2460
|
__decorateParam$1(3, IRenderManagerService),
|
|
2454
2461
|
__decorateParam$1(4, ITextSelectionRenderManager)
|
|
2455
2462
|
], DocDrawingTransformerController);
|
|
2463
|
+
const PLUGIN_CONFIG_KEY = "docs-drawing-ui.config", defaultPluginConfig = {};
|
|
2456
2464
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
2457
2465
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
2458
2466
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
@@ -2461,8 +2469,10 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
|
|
|
2461
2469
|
const PLUGIN_NAME = "DOCS_DRAWING_UI_PLUGIN";
|
|
2462
2470
|
var _a7;
|
|
2463
2471
|
let UniverDocsDrawingUIPlugin = (_a7 = class extends Plugin {
|
|
2464
|
-
constructor(_config, _injector, _renderManagerSrv) {
|
|
2465
|
-
super(), this._injector = _injector, this._renderManagerSrv = _renderManagerSrv;
|
|
2472
|
+
constructor(_config = defaultPluginConfig, _injector, _renderManagerSrv, _configService) {
|
|
2473
|
+
super(), this._config = _config, this._injector = _injector, this._renderManagerSrv = _renderManagerSrv, this._configService = _configService;
|
|
2474
|
+
const { ...rest } = this._config;
|
|
2475
|
+
this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
|
|
2466
2476
|
}
|
|
2467
2477
|
onStarting() {
|
|
2468
2478
|
[
|
|
@@ -2485,7 +2495,8 @@ __publicField2(UniverDocsDrawingUIPlugin, "pluginName", PLUGIN_NAME);
|
|
|
2485
2495
|
UniverDocsDrawingUIPlugin = __decorateClass([
|
|
2486
2496
|
DependentOn(UniverDrawingUIPlugin, UniverDrawingPlugin, UniverDocsDrawingPlugin),
|
|
2487
2497
|
__decorateParam(1, Inject(Injector)),
|
|
2488
|
-
__decorateParam(2, IRenderManagerService)
|
|
2498
|
+
__decorateParam(2, IRenderManagerService),
|
|
2499
|
+
__decorateParam(3, IConfigService)
|
|
2489
2500
|
], UniverDocsDrawingUIPlugin);
|
|
2490
2501
|
export {
|
|
2491
2502
|
COMPONENT_DOC_UPLOAD_FILE_MENU,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PLUGIN_CONFIG_KEY = "docs-drawing-ui.config";
|
|
17
|
+
export declare const configSymbol: unique symbol;
|
|
18
|
+
export interface IUniverDocsDrawingUIConfig {
|
|
19
|
+
}
|
|
20
|
+
export declare const defaultPluginConfig: IUniverDocsDrawingUIConfig;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Disposable, ICommandService, Injector } from '@univerjs/core';
|
|
2
|
-
import { ComponentManager,
|
|
2
|
+
import { ComponentManager, IMenuManagerService, IShortcutService } from '@univerjs/ui';
|
|
3
3
|
export declare class DocDrawingUIController extends Disposable {
|
|
4
4
|
private readonly _injector;
|
|
5
5
|
private readonly _componentManager;
|
|
6
|
-
private readonly
|
|
6
|
+
private readonly _menuManagerService;
|
|
7
7
|
private readonly _commandService;
|
|
8
8
|
private readonly _shortcutService;
|
|
9
|
-
constructor(_injector: Injector, _componentManager: ComponentManager,
|
|
9
|
+
constructor(_injector: Injector, _componentManager: ComponentManager, _menuManagerService: IMenuManagerService, _commandService: ICommandService, _shortcutService: IShortcutService);
|
|
10
10
|
private _initCustomComponents;
|
|
11
11
|
private _initMenus;
|
|
12
12
|
private _initCommands;
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
1
|
+
import { IConfigService, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
2
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
3
|
+
import { IUniverDocsDrawingUIConfig } from './controllers/config.schema';
|
|
3
4
|
export declare class UniverDocsDrawingUIPlugin extends Plugin {
|
|
5
|
+
private readonly _config;
|
|
4
6
|
protected _injector: Injector;
|
|
5
7
|
private readonly _renderManagerSrv;
|
|
8
|
+
private readonly _configService;
|
|
6
9
|
static type: UniverInstanceType;
|
|
7
10
|
static pluginName: string;
|
|
8
|
-
constructor(_config:
|
|
11
|
+
constructor(_config: Partial<IUniverDocsDrawingUIConfig>, _injector: Injector, _renderManagerSrv: IRenderManagerService, _configService: IConfigService);
|
|
9
12
|
onStarting(): void;
|
|
10
13
|
onReady(): void;
|
|
11
14
|
}
|
|
@@ -2,5 +2,6 @@ import { IMenuItem } from '@univerjs/ui';
|
|
|
2
2
|
import { IAccessor } from '@univerjs/core';
|
|
3
3
|
export declare const ImageUploadIcon = "addition-and-subtraction-single";
|
|
4
4
|
export declare const IMAGE_MENU_ID = "doc.menu.image";
|
|
5
|
+
export declare const IMAGE_MENU_UPLOAD_FLOAT_ID = "doc.menu.image.upload.float";
|
|
5
6
|
export declare function ImageMenuFactory(accessor: IAccessor): IMenuItem;
|
|
6
7
|
export declare function UploadFloatImageMenuFactory(_accessor: IAccessor): IMenuItem;
|