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.

fix: menu popup priority greater than placeholder (#4916)

siam44596347ed18
diff --git a/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-trigger.controller.ts b/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-trigger.controller.ts
index bfd999bcae..8950af3abf 100644
--- a/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-trigger.controller.ts
+++ b/packages/docs-quick-insert-ui/src/controllers/doc-quick-insert-trigger.controller.ts
@@ -14,9 +14,10 @@
* limitations under the License.
*/
+import type { DocumentDataModel } from '@univerjs/core';
import type { IRichTextEditingMutationParams } from '@univerjs/docs';
import type { IDeleteCommandParams, IIMEInputCommandParams, IInsertCommandParams, IMoveCursorOperationParams } from '@univerjs/docs-ui';
-import { DeleteDirection, Direction, Disposable, ICommandService, Inject } from '@univerjs/core';
+import { DeleteDirection, Direction, Disposable, ICommandService, Inject, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { DocSelectionManagerService, RichTextEditingMutation } from '@univerjs/docs';
import { DeleteCommand, DeleteLeftCommand, IMEInputCommand, InsertCommand, MoveCursorOperation } from '@univerjs/docs-ui';
import { IShortcutService, KeyCode } from '@univerjs/ui';
@@ -29,7 +30,8 @@ export class DocQuickInsertTriggerController extends Disposable {
@ICommandService private readonly _commandService: ICommandService,
@Inject(DocSelectionManagerService) private readonly _textSelectionManagerService: DocSelectionManagerService,
@Inject(DocQuickInsertPopupService) private readonly _docQuickInsertPopupService: DocQuickInsertPopupService,
- @Inject(IShortcutService) private readonly _shortcutService: IShortcutService
+ @Inject(IShortcutService) private readonly _shortcutService: IShortcutService,
+ @Inject(IUniverInstanceService) private readonly _univerInstanceService: IUniverInstanceService
) {
super();
@@ -50,6 +52,11 @@ export class DocQuickInsertTriggerController extends Disposable {
// eslint-disable-next-line complexity, max-lines-per-function
this._commandService.onCommandExecuted((commandInfo) => {
const { _docQuickInsertPopupService, _textSelectionManagerService, _commandService } = this;
+ const documentDataModel = this._univerInstanceService.getCurrentUnitOfType<DocumentDataModel>(UniverInstanceType.UNIVER_DOC);
+ if (documentDataModel?.getDisabled()) {
+ return;
+ }
+
if (commandInfo.id === InsertCommand.id) {
const params = commandInfo.params as IInsertCommandParams;
if (_docQuickInsertPopupService.editPopup) {
diff --git a/packages/docs-quick-insert-ui/src/services/doc-quick-insert-popup.service.ts b/packages/docs-quick-insert-ui/src/services/doc-quick-insert-popup.service.ts
index d24dca6208..c507f49711 100644
--- a/packages/docs-quick-insert-ui/src/services/doc-quick-insert-popup.service.ts
+++ b/packages/docs-quick-insert-ui/src/services/doc-quick-insert-popup.service.ts
@@ -193,18 +193,6 @@ export class DocQuickInsertPopupService extends Disposable {
this.closePopup();
- const disposable = this._docCanvasPopupManagerService.attachPopupToRange(
- { startOffset: index, endOffset: index, collapsed: true },
- {
- componentKey: QuickInsertPopup.componentKey,
- onClickOutside: () => {
- this.closePopup();
- },
- direction: 'bottom',
- },
- unitId
- );
-
this._inputPlaceholderRenderRoot = this._createInputPlaceholderRenderRoot(() => {
const docSkeletonManagerService = this._renderManagerService.getRenderById(unitId)?.with(DocSkeletonManagerService);
const activeRange = this._docSelectionManagerService.getActiveTextRange();
@@ -236,6 +224,18 @@ export class DocQuickInsertPopupService extends Disposable {
});
this._inputPlaceholderRenderRoot.mount();
+ const disposable = this._docCanvasPopupManagerService.attachPopupToRange(
+ { startOffset: index, endOffset: index, collapsed: true },
+ {
+ componentKey: QuickInsertPopup.componentKey,
+ onClickOutside: () => {
+ this.closePopup();
+ },
+ direction: 'bottom',
+ },
+ unitId
+ );
+
this._editPopup$.next({ disposable, popup, anchor: index, unitId });
}