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(docs-ui): use source types for doc helpers (#7176)

wpxp1234560593e5e61468
diff --git a/packages/docs-ui/src/services/doc-paragraph-menu.service.ts b/packages/docs-ui/src/services/doc-paragraph-menu.service.ts
index 7c17995a75..8f10d1b190 100644
--- a/packages/docs-ui/src/services/doc-paragraph-menu.service.ts
+++ b/packages/docs-ui/src/services/doc-paragraph-menu.service.ts
@@ -106,13 +106,6 @@ const LIST_ICON_MAP: Partial<Record<PresetListType, string>> = {
[PresetListType.CHECK_LIST_CHECKED]: 'TodoListDoubleIcon',
};
-interface IDocSelectionRangeLike {
- collapsed?: boolean;
- endOffset?: number;
- rangeType?: string;
- startOffset?: number;
-}
-
interface IDocExpandedSelectionState {
hasExpandedTextRange: boolean;
hasRectRange: boolean;
@@ -190,7 +183,7 @@ export class DocParagraphMenuService extends Disposable implements IRenderModule
return true;
}
- private _getExpandedSelectionState(ranges: readonly IDocSelectionRangeLike[]): IDocExpandedSelectionState {
+ private _getExpandedSelectionState(ranges: readonly ITextRangeWithStyle[]): IDocExpandedSelectionState {
return ranges.reduce<IDocExpandedSelectionState>((state, range) => {
if (range.rangeType === DOC_RANGE_TYPE.RECT) {
state.hasRectRange = true;
@@ -216,7 +209,7 @@ export class DocParagraphMenuService extends Disposable implements IRenderModule
});
}
- private _hasExpandedSelectionRanges(ranges: readonly IDocSelectionRangeLike[]) {
+ private _hasExpandedSelectionRanges(ranges: readonly ITextRangeWithStyle[]) {
const state = this._getExpandedSelectionState(ranges);
return state.hasExpandedTextRange || state.hasRectRange;
}
diff --git a/packages/docs-ui/src/views/paragraph-setting/hook/utils.ts b/packages/docs-ui/src/views/paragraph-setting/hook/utils.ts
index 7ed5dfa5d0..19bd17e5fa 100644
--- a/packages/docs-ui/src/views/paragraph-setting/hook/utils.ts
+++ b/packages/docs-ui/src/views/paragraph-setting/hook/utils.ts
@@ -293,7 +293,7 @@ export const useFirstParagraphLineSpacing = (paragraph: IParagraph[]) => {
const glyphNode = skeleton?.findNodeByCharIndex(paragraph[0].startIndex);
const divideNode = glyphNode?.parent;
const lineNode = divideNode?.parent;
- const metrics = getLineSpacingMetrics(lineNode as any);
+ const metrics = getLineSpacingMetrics(lineNode);
const nextStoredLineSpacing = convertLineSpacingForRuleChange(
convertDisplayLineSpacingToStoredValue(lineSpacing, spacingRule),
spacingRule,
diff --git a/packages/docs-ui/src/views/paragraph-setting/line-spacing.ts b/packages/docs-ui/src/views/paragraph-setting/line-spacing.ts
index a414fb66ca..1692f963d3 100644
--- a/packages/docs-ui/src/views/paragraph-setting/line-spacing.ts
+++ b/packages/docs-ui/src/views/paragraph-setting/line-spacing.ts
@@ -15,6 +15,7 @@
*/
import type { LocaleService } from '@univerjs/core';
+import type { IDocumentSkeletonLine } from '@univerjs/engine-render';
import type { LocaleKey } from '../../locale/types';
import { DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING, DEFAULT_STYLES, SpacingRule } from '@univerjs/core';
@@ -23,20 +24,6 @@ interface ILineSpacingMetrics {
renderedLineHeight: number;
}
-interface ILineSpacingLike {
- contentHeight?: number;
- paddingTop?: number;
- paddingBottom?: number;
- divides?: Array<{
- glyphGroup?: Array<{
- bBox?: {
- ba?: number;
- bd?: number;
- };
- }>;
- }>;
-}
-
const AUTO_LINE_SPACING_CONFIG = { min: 1, max: 5, step: 0.1 } as const;
const FIXED_LINE_SPACING_CONFIG = { min: 1, max: 100 } as const;
@@ -69,7 +56,7 @@ export function convertDisplayLineSpacingToStoredValue(lineSpacing: number, spac
return spacingRule === SpacingRule.AUTO ? lineSpacing : round(lineSpacing, 4);
}
-export function getLineSpacingMetrics(lineNode?: ILineSpacingLike | null): ILineSpacingMetrics | null {
+export function getLineSpacingMetrics(lineNode?: IDocumentSkeletonLine): ILineSpacingMetrics | null {
if (!lineNode) {
return null;
}