mirror of
https://github.com/dream-num/univer.git
synced 2026-09-24 15:32:18 +08:00
feat(docs-ui): disable paragraph-menu on disabled (#4974)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
import type { ICustomBlock, ICustomDecoration, ICustomRange, IDocumentBody, IParagraph, ISectionBreak, ITextRun } from '../../../types/interfaces/i-document-data';
|
||||
import type { IRetainAction } from './action-types';
|
||||
import { UpdateDocsAttributeType } from '../../../shared/command-enum';
|
||||
import { generateRandomId, Tools } from '../../../shared/tools';
|
||||
import { Tools } from '../../../shared/tools';
|
||||
import { normalizeTextRuns } from './apply-utils/common';
|
||||
import { coverTextRuns } from './apply-utils/update-apply';
|
||||
|
||||
@@ -116,9 +116,6 @@ export function getParagraphsSlice(
|
||||
if (startIndex >= startOffset && startIndex < endOffset) {
|
||||
const copy = Tools.deepClone(paragraph);
|
||||
newParagraphs.push(copy);
|
||||
if (copy.paragraphStyle?.headingId) {
|
||||
copy.paragraphStyle.headingId = generateRandomId(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ export class DocQuickInsertMenuController extends Disposable implements IRenderM
|
||||
private _init() {
|
||||
this.disposeWithMe(combineLatest([this._docEventManagerService.hoverParagraphLeftRealTime$, this._docEventManagerService.hoverParagraphRealTime$]).subscribe(([left, paragraph]) => {
|
||||
const p = left ?? paragraph;
|
||||
if (!p) {
|
||||
const isDisabled = this._context.unit.getDisabled();
|
||||
if (!p || isDisabled) {
|
||||
this._hideMenu(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import type { IDisposable, IDocumentBody, IDocumentData } from '@univerjs/core';
|
||||
import type { IDocImage } from '@univerjs/docs-drawing';
|
||||
import type { IRectRangeWithStyle, ITextRangeWithStyle } from '@univerjs/engine-render';
|
||||
|
||||
import { BuildTextUtils, createIdentifier, DataStreamTreeTokenType, Disposable, DOC_RANGE_TYPE, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DrawingTypeEnum, getBodySlice, ICommandService, ILogService, Inject, IUniverInstanceService, normalizeBody, ObjectRelativeFromH, ObjectRelativeFromV, PositionedObjectLayoutType, SliceBodyType, toDisposable, Tools, UniverInstanceType } from '@univerjs/core';
|
||||
import { BuildTextUtils, createIdentifier, DataStreamTreeTokenType, Disposable, DOC_RANGE_TYPE, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DrawingTypeEnum, generateRandomId, getBodySlice, ICommandService, ILogService, Inject, IUniverInstanceService, normalizeBody, ObjectRelativeFromH, ObjectRelativeFromV, PositionedObjectLayoutType, SliceBodyType, toDisposable, Tools, UniverInstanceType } from '@univerjs/core';
|
||||
import { DocSelectionManagerService } from '@univerjs/docs';
|
||||
import { ImageSourceType } from '@univerjs/drawing';
|
||||
import {
|
||||
@@ -246,6 +246,12 @@ export class DocClipboardService extends Disposable implements IDocClipboardServ
|
||||
// copy custom ranges
|
||||
body.customRanges = body.customRanges?.map(BuildTextUtils.customRange.copyCustomRange);
|
||||
|
||||
body.paragraphs?.forEach((copy) => {
|
||||
if (copy.paragraphStyle?.headingId) {
|
||||
copy.paragraphStyle.headingId = generateRandomId(6);
|
||||
}
|
||||
});
|
||||
|
||||
const activeRange = this._docSelectionManagerService.getActiveTextRange();
|
||||
const { segmentId, endOffset: activeEndOffset, style } = activeRange || {};
|
||||
const ranges = this._docSelectionManagerService.getTextRanges();
|
||||
|
||||
@@ -90,7 +90,11 @@ export class DocParagraphMenuService extends Disposable implements IRenderModule
|
||||
private _init() {
|
||||
const handleHoverParagraph = (paragraph: Nullable<IMutiPageParagraphBound>) => {
|
||||
const viewModel = this._docSkeletonManagerService.getViewModel();
|
||||
if (viewModel.getEditArea() === DocumentEditArea.BODY && !this._floatMenuService.floatMenu) {
|
||||
if (
|
||||
viewModel.getEditArea() === DocumentEditArea.BODY &&
|
||||
!this._floatMenuService.floatMenu &&
|
||||
!this._context.unit.getDisabled()
|
||||
) {
|
||||
if (this._paragrahMenu?.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user