Skip to content

Commit

Permalink
fix: default text style in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocs committed Oct 31, 2024
1 parent f229390 commit b21a430
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/docs-ui/src/commands/commands/break-line.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
* limitations under the License.
*/

import type { DocumentDataModel, ICommand, IParagraph } from '@univerjs/core';
import type { DocumentDataModel, ICommand, IDocumentBody, IParagraph } from '@univerjs/core';
import { BuildTextUtils, CommandType, DataStreamTreeTokenType, ICommandService, IUniverInstanceService, PresetListType, Tools, UniverInstanceType } from '@univerjs/core';
import { DocSelectionManagerService } from '@univerjs/docs';
import { getTextRunAtPosition } from '../../basics/paragraph';
import { DocMenuStyleService } from '../../services/doc-menu-style.service';
import { InsertCommand } from './core-editing.command';
import { ToggleCheckListCommand } from './list.command';

Expand Down Expand Up @@ -55,10 +57,12 @@ export const BreakLineCommand: ICommand = {

type: CommandType.COMMAND,

// eslint-disable-next-line max-lines-per-function
handler: async (accessor) => {
const docSelectionManagerService = accessor.get(DocSelectionManagerService);
const univerInstanceService = accessor.get(IUniverInstanceService);
const commandService = accessor.get(ICommandService);
const docMenuStyleService = accessor.get(DocMenuStyleService);

const activeTextRange = docSelectionManagerService.getActiveTextRange();
const rectRanges = docSelectionManagerService.getRectRanges();
Expand Down Expand Up @@ -97,9 +101,20 @@ export const BreakLineCommand: ICommand = {

const prevParagraphIndex = prevParagraph.startIndex;

const insertBody = {
const defaultTextStyle = docMenuStyleService.getDefaultStyle();
const styleCache = docMenuStyleService.getStyleCache();
const curTextRun = getTextRunAtPosition(body.textRuns ?? [], endOffset, defaultTextStyle, styleCache);

const insertBody: IDocumentBody = {
dataStream: DataStreamTreeTokenType.PARAGRAPH,
paragraphs: generateParagraphs(DataStreamTreeTokenType.PARAGRAPH, prevParagraph),
textRuns: [{
st: 0,
ed: 1,
ts: {
...curTextRun.ts,
},
}],
};

const deleteRange = {
Expand Down

0 comments on commit b21a430

Please sign in to comment.