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

This commit is contained in:
siam
2025-04-01 15:05:13 +08:00
committed by GitHub
parent cb802d5313
commit 44596347ed
2 changed files with 21 additions and 14 deletions
@@ -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) {
@@ -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 });
}