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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(bullet): bullet support paragraph setting (#2958)
Gpound.liu0eeae77b9185
diff --git a/packages/core/package.json b/packages/core/package.jsonindex 269ec0f594..f8a366fbe5 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -65,11 +65,14 @@"rxjs": ">=7.0.0"},"dependencies": {+ "@types/lodash.mergewith": "^4.6.9","@univerjs/protocol": "0.1.38","@wendellhu/redi": "0.16.0",+ "lodash.mergewith": "^4.6.2","nanoid": "5.0.7","numeral": "^2.0.6","ot-json1": "^1.0.2"+},"devDependencies": {"@types/numeral": "^2.0.5",diff --git a/packages/core/src/shared/tools.ts b/packages/core/src/shared/tools.tsindex e3b98a0b87..183ffc8f8d 100644--- a/packages/core/src/shared/tools.ts+++ b/packages/core/src/shared/tools.ts@@ -16,6 +16,7 @@import { customAlphabet, nanoid } from 'nanoid';+import mergeWith from 'lodash.mergewith';import { isLegalUrl, normalizeUrl } from '../common/url';import type { Class, IKeyValue } from './types';@@ -672,11 +673,11 @@ export class Tools {}static isValidParameter(name: string): boolean {- /**- *Validates that the name does not contain spaces or disallowed characters- *Assuming the set of disallowed characters includes some special characters,- *you can modify the regex below according to the actual requirements- */+ /**+ *Validates that the name does not contain spaces or disallowed characters+ *Assuming the set of disallowed characters includes some special characters,+ *you can modify the regex below according to the actual requirements+ */const containsInvalidChars = /[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(name);const isValidLength = name.length <= 255;@@ -710,6 +711,20 @@ export class Tools {static clamp(value: number, min: number, max: number) {return Math.max(min, Math.min(max, value));}++ /**+ *+ *+ * @static+ * @param {unknown} object Modify the property while leaving the reference unchanged.+ * @param {unknown} source The source being merged in object.+ * @param {(value: unknown, originValue: unknown, key: string, object: unknown, source: unknown, stack: string[]) => {}} [customizer]+ * @return {*}+ * @memberof Tools+ */+ static mergeWith(object: unknown, source: unknown, customizer?: (value: unknown, originValue: unknown, key: string, object: unknown, source: unknown, stack: string[]) => {}) {+ return mergeWith(object, source, customizer);+ }}export function generateRandomId(n: number = 21, alphabet?: string): string {diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.tsindex 9948ff6aeb..4db6660780 100644--- a/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { INumberUnit, Nullable } from '@univerjs/core';+import type { INumberUnit, IParagraphStyle, Nullable } from '@univerjs/core';import { BooleanNumber, DataStreamTreeTokenType, GridType, ObjectRelativeFromV, PositionedObjectLayoutType, SpacingRule, TableTextWrapType } from '@univerjs/core';import type {IDocumentSkeletonColumn,@@ -56,6 +56,7 @@ import {getPositionVertical,isColumnFull,lineIterator,+ mergeByV,} from '../../tools';import { BreakPointType } from '../../line-breaker/break';import { getNullTableSkeleton, getTableIdAndSliceIndex, getTableSliceId } from '../table';@@ -78,10 +79,7 @@ export function layoutParagraph(const paragraphProperties = bulletSkeleton.paragraphProperties || {};- paragraphConfig.paragraphStyle = {- ...paragraphConfig.paragraphStyle,- ...paragraphProperties,- };+ paragraphConfig.paragraphStyle = mergeByV<IParagraphStyle>(paragraphConfig.paragraphStyle, paragraphProperties, 'max');const { snapToGrid = BooleanNumber.TRUE } = paragraphStyle;@@ -264,13 +262,14 @@ function _divideOperator(}if (glyphGroup.length) {+ // Only Divide in the first paragraph is the beginning of the paragraph_divideOperator(ctx,glyphGroup,pages,sectionBreakConfig,paragraphConfig,- paragraphStart,+ false,breakPointType,defaultSpanLineHeight);@@ -528,7 +527,7 @@ function _lineOperator(}if (skeTablesInParagraph != null && skeTablesInParagraph.length > 0) {- needOpenNewPageByTableLayout = _updateAndPositionTable(lineTop, marginTop, lastPage, section, skeTablesInParagraph);+ needOpenNewPageByTableLayout = _updateAndPositionTable(lineTop, lastPage, section, skeTablesInParagraph);}const newLineTop = calculateLineTopByDrawings(@@ -566,7 +565,7 @@ function _lineOperator(const lineIndex = preLine ? preLine.lineIndex + 1 : 0;const { charSpace, defaultTabStop } = getCharSpaceConfig(sectionBreakConfig, paragraphConfig);const charSpaceApply = getCharSpaceApply(charSpace, defaultTabStop, gridType, snapToGrid);- const { paddingLeft, paddingRight } = __getIndentPadding(+ let { paddingLeft, paddingRight } = __getIndentPadding(indentFirstLine,hanging,indentStart,@@ -575,6 +574,13 @@ function _lineOperator(paragraphStart);+ // 如果宽度不足以容纳边距,这里留 1px 的宽度进行占位.+ if (paddingLeft + paddingRight >= column.width) {+ const leftPercent = paddingLeft / (paddingLeft + paddingRight);+ paddingLeft = column.width * leftPercent - 0.5;+ paddingRight = column.width - paddingLeft - 0.5;+ }+const newLine = createSkeletonLine(paragraphIndex,LineType.PARAGRAPH,@@ -641,7 +647,6 @@ function __updateAndPositionDrawings(function _updateAndPositionTable(lineTop: number,- marginTop: number,page: IDocumentSkeletonPage,section: IDocumentSkeletonSection,skeTablesInParagraph: IParagraphTableCache[]@@ -662,7 +667,7 @@ function _updateAndPositionTable(switch (tableSource.textWrap) {case TableTextWrapType.NONE: {- table.top = lineTop + marginTop;+ table.top = lineTop;break;}case TableTextWrapType.WRAP: {diff --git a/packages/engine-render/src/components/docs/layout/tools.ts b/packages/engine-render/src/components/docs/layout/tools.tsindex efcf347df4..6d40abeebf 100644--- a/packages/engine-render/src/components/docs/layout/tools.ts+++ b/packages/engine-render/src/components/docs/layout/tools.ts@@ -38,6 +38,7 @@ import {PageOrientType,SectionType,SpacingRule,+ Tools,VerticalAlign,WrapStrategy,} from '@univerjs/core';@@ -1063,3 +1064,22 @@ export function resetContext(ctx: ILayoutContext) {ctx.isDirty = false;ctx.skeleton.drawingAnchor?.clear();}++export function mergeByV<T = unknown>(object: unknown, originObject: unknown, type: 'max' | 'min') {+ const mergeIterator = (obj: unknown, originObj: unknown, key: string) => {+ if (key !== 'v') {+ if (typeof originObj === 'object') {+ return Tools.mergeWith(obj, originObj, mergeIterator);+ } else {+ return originObj ?? obj;+ }+ }+ if (typeof originObj === 'number') {+ if (typeof obj === 'number') {+ return type === 'max' ? Math.max(originObj, obj) : Math.min(originObj, obj);+ }+ }+ return originObj ?? obj;+ };+ return Tools.mergeWith(object, originObject, mergeIterator) as T;+}diff --git a/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.tsindex 61865b20f0..8b02784be6 100644--- a/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts+++ b/packages/sheets-numfmt/src/controllers/numfmt.editor.controller.ts@@ -221,6 +221,7 @@ export class NumfmtEditorController extends Disposable {};}const list = self._collectEffectMutation.getEffects();+ self._collectEffectMutation.clean();if (!list.length) {return {redos: [],@@ -244,7 +245,7 @@ export class NumfmtEditorController extends Disposable {}));const redos = [];const undos = [];- if (cells) {+ if (cells.length) {const redo = {id: SetNumfmtMutation.id,params: transformCellsToRange(unitId, subUnitId, cells) as ISetNumfmtMutationParams,@@ -252,7 +253,7 @@ export class NumfmtEditorController extends Disposable {redos.push(redo);undos.push(...factorySetNumfmtUndoMutation(self._injector, redo.params));}- if (removeCells) {+ if (removeCells.length) {const redo = {id: RemoveNumfmtMutation.id,params: {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ea9f706699..b022556685 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -10,7 +10,7 @@ importers:devDependencies:'@antfu/eslint-config':specifier: 2.24.1- version: 2.24.1(@eslint-react/[email protected]([email protected])([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ version: 2.24.1(@eslint-react/[email protected]([email protected])([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))'@commitlint/cli':specifier: ^19.3.0version: 19.3.0(@types/[email protected])([email protected])@@ -715,6 +715,9 @@ importers:packages/core:dependencies:+ '@types/lodash.mergewith':+ specifier: ^4.6.9+ version: 4.6.9'@univerjs/core':specifier: workspace:*version: 'link:'@@ -724,6 +727,9 @@ importers:'@wendellhu/redi':specifier: 0.16.0version: 0.16.0+ lodash.mergewith:+ specifier: ^4.6.2+ version: 4.6.2nanoid:specifier: 5.0.7version: 5.0.7@@ -4134,10 +4140,6 @@ packages:peerDependencies:eslint: ^6.0.0 || ^7.0.0 || >=8.0.0- '@eslint-community/[email protected]':- resolution: {integrity: sha512-Zm2NGpWELsQAD1xsJzGQpYfvICSsFkEpU0jxBjfdC6uNEWXcHnfs9hScFWtXVDVl+rBQJGrl4g1vcKIejpH9dA==}- engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}-'@eslint-community/[email protected]':resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==}engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0}@@ -5186,6 +5188,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-J5dvW98sxmGnamqf+/aLP87PYXyrha9xIgc2ZlHl6OHMFR2Ejdxep50QfU0abO1+CH6+ugx+8wEUN1toImAinA==}+ '@types/[email protected]':+ resolution: {integrity: sha512-fgkoCAOF47K7sxrQ7Mlud2TH023itugZs2bUg8h/KzT+BnZNrR2jAOmaokbLunHNnobXVWOezAeNn/lZqwxkcw==}+'@types/[email protected]':resolution: {integrity: sha512-KOxyNkZpbaggVmqbpr82N2tDVTx05/3/j0f50Es1prxrWB0XYf9p3QNxqcbWb7P1Q9wlvsUSlCFnwlPCIJ46PQ==}@@ -5364,12 +5369,6 @@ packages:peerDependencies:eslint: ^8.56.0- '@typescript-eslint/[email protected]':- resolution: {integrity: sha512-k/oS/A/3QeGLRvOWCg6/9rATJL5rec7/5s1YmdS0ZU6LHveJyGFwBvLhSRBv6i9xaj7etmosp+l+ViN1I9Aj/Q==}- engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}- peerDependencies:- eslint: ^8.57.0 || ^9.0.0-'@typescript-eslint/[email protected]':resolution: {integrity: sha512-CBFR0G0sCt0+fzfnKaciu9IBsKvEKYwN9UZ+eeogK1fYHg4Qxk1yf/wLQkLXlq8wbU2dFlgAesxt8Gi76E8RTA==}engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}@@ -10907,7 +10906,7 @@ snapshots:dependencies:'@babel/runtime': 7.24.7- '@antfu/[email protected](@eslint-react/[email protected]([email protected])([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))':+ '@antfu/[email protected](@eslint-react/[email protected]([email protected])([email protected]))(@vue/[email protected])([email protected]([email protected]))([email protected]([email protected]))([email protected]([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))':dependencies:'@antfu/install-pkg': 0.3.3'@clack/prompts': 0.7.0@@ -10932,7 +10931,7 @@ snapshots:eslint-plugin-toml: 0.11.1([email protected])eslint-plugin-unicorn: 55.0.0([email protected])eslint-plugin-unused-imports: 4.0.1(@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])- eslint-plugin-vitest: 0.5.4(@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected]))+ eslint-plugin-vitest: 0.5.4(@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))eslint-plugin-vue: 9.27.0([email protected])eslint-plugin-yml: 1.14.0([email protected])eslint-processor-vue-blocks: 0.1.2(@vue/[email protected])([email protected])@@ -12114,8 +12113,6 @@ snapshots:eslint: 9.8.0eslint-visitor-keys: 3.4.3- '@eslint-community/[email protected]': {}-'@eslint-community/[email protected]': {}@@ -13142,7 +13139,7 @@ snapshots:dependencies:'@types/eslint': 9.6.0- '@typescript-eslint/utils': 8.0.0([email protected])([email protected])+ '@typescript-eslint/utils': 8.0.1([email protected])([email protected])eslint: 9.8.0transitivePeerDependencies:- supports-color@@ -13152,7 +13149,7 @@ snapshots:dependencies:'@stylistic/eslint-plugin-js': 2.6.1([email protected])'@types/eslint': 9.6.0- '@typescript-eslint/utils': 8.0.0([email protected])([email protected])+ '@typescript-eslint/utils': 8.0.1([email protected])([email protected])eslint: 9.8.0transitivePeerDependencies:- supports-color@@ -13397,6 +13394,10 @@ snapshots:dependencies:'@types/lodash': 4.17.5+ '@types/[email protected]':+ dependencies:+ '@types/lodash': 4.17.5+'@types/[email protected]':dependencies:'@types/lodash': 4.17.5@@ -13489,7 +13490,7 @@ snapshots:'@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])':dependencies:- '@eslint-community/regexpp': 4.10.1+ '@eslint-community/regexpp': 4.11.0'@typescript-eslint/parser': 8.0.0([email protected])([email protected])'@typescript-eslint/scope-manager': 8.0.1'@typescript-eslint/type-utils': 8.0.1([email protected])([email protected])@@ -13607,17 +13608,6 @@ snapshots:- supports-color- typescript- dependencies:- '@eslint-community/eslint-utils': 4.4.0([email protected])- '@typescript-eslint/scope-manager': 8.0.0- '@typescript-eslint/types': 8.0.0- '@typescript-eslint/typescript-estree': 8.0.0([email protected])- eslint: 9.8.0- transitivePeerDependencies:- - supports-color- - typescript-dependencies:'@eslint-community/eslint-utils': 4.4.0([email protected])@@ -13973,6 +13963,10 @@ snapshots:dependencies:acorn: 8.12.0+ dependencies:+ acorn: 8.12.1+@@ -15404,7 +15398,7 @@ snapshots:dependencies:'@eslint-community/eslint-utils': 4.4.0([email protected])- '@eslint-community/regexpp': 4.10.1+ '@eslint-community/regexpp': 4.11.0eslint: 9.8.0eslint-compat-utils: 0.5.1([email protected])@@ -15507,8 +15501,8 @@ snapshots:dependencies:- '@typescript-eslint/types': 8.0.0- '@typescript-eslint/utils': 8.0.0([email protected])([email protected])+ '@typescript-eslint/types': 8.0.1+ '@typescript-eslint/utils': 8.0.1([email protected])([email protected])eslint: 9.8.0minimatch: 10.0.1natural-compare-lite: 1.4.0@@ -15650,7 +15644,7 @@ snapshots:dependencies:'@eslint-community/eslint-utils': 4.4.0([email protected])- '@eslint-community/regexpp': 4.10.1+ '@eslint-community/regexpp': 4.11.0comment-parser: 1.4.1eslint: 9.8.0jsdoc-type-pratt-parser: 4.0.0@@ -15695,7 +15689,7 @@ snapshots:optionalDependencies:'@typescript-eslint/eslint-plugin': 8.0.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])- [email protected](@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])):+ [email protected](@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])):dependencies:'@typescript-eslint/utils': 7.18.0([email protected])([email protected])eslint: 9.8.0@@ -15811,8 +15805,8 @@ snapshots:dependencies:- acorn: 8.12.0- acorn-jsx: 5.3.2([email protected])+ acorn: 8.12.1+ acorn-jsx: 5.3.2([email protected])eslint-visitor-keys: 3.4.3@@ -16910,7 +16904,7 @@ snapshots:dependencies:- acorn: 8.12.0+ acorn: 8.12.1eslint-visitor-keys: 3.4.3espree: 9.6.1semver: 7.6.3@@ -17293,7 +17287,7 @@ snapshots:dependencies:- acorn: 8.12.0+ acorn: 8.12.1pathe: 1.1.2pkg-types: 1.1.1ufo: 1.5.3@@ -18340,7 +18334,7 @@ snapshots:dependencies:- '@eslint-community/regexpp': 4.10.1+ '@eslint-community/regexpp': 4.11.0@@ -18370,7 +18364,7 @@ snapshots:dependencies:- '@eslint-community/regexpp': 4.10.1+ '@eslint-community/regexpp': 4.11.0refa: 0.12.1@@ -18645,7 +18639,7 @@ snapshots:dependencies:- '@eslint-community/regexpp': 4.10.1+ '@eslint-community/regexpp': 4.11.0refa: 0.12.1regexp-ast-analysis: 0.7.1@@ -19803,7 +19797,7 @@ snapshots:dependencies:eslint-visitor-keys: 3.4.3lodash: 4.17.21- yaml: 2.4.5+ yaml: 2.5.0