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
fix: inline format error (#1365)
Ran Luoa3f1e9bb1b27
diff --git a/packages/docs/src/commands/commands/inline-format.command.ts b/packages/docs/src/commands/commands/inline-format.command.tsindex 2c7f0643ff..3eec1b4fb2 100644--- a/packages/docs/src/commands/commands/inline-format.command.ts+++ b/packages/docs/src/commands/commands/inline-format.command.ts@@ -258,52 +258,45 @@ function getReverseFormatValueInSelection(} else if (ed <= startOffset!) {ti++;} else {- if (ts?.[key] == null) {- if (/bl|it/.test(key)) {- return BooleanNumber.TRUE;- }+ if (/bl|it/.test(key)) {+ return ts?.[key] === BooleanNumber.TRUE ? BooleanNumber.FALSE : BooleanNumber.TRUE;+ }- if (/ul|st/.test(key)) {- return {+ if (/ul|st/.test(key)) {+ return isTextDecoration(ts?.[key]) && (ts?.[key] as ITextDecoration).s === BooleanNumber.TRUE+ ? {+ s: BooleanNumber.FALSE,+ }+ : {s: BooleanNumber.TRUE,};- }+ }- if (/va/.test(key)) {- return preCommandId === SetInlineFormatSubscriptCommand.id- ? BaselineOffset.SUBSCRIPT+ if (/va/.test(key)) {+ if (preCommandId === SetInlineFormatSubscriptCommand.id) {+ return ts?.[key] === BaselineOffset.SUBSCRIPT+ ? BaselineOffset.NORMAL+ : BaselineOffset.SUBSCRIPT;+ } else {+ return ts?.[key] === BaselineOffset.SUPERSCRIPT+ ? BaselineOffset.NORMAL: BaselineOffset.SUPERSCRIPT;}}- // Add second ?. in just use fix TS checker.- if (isTextDecoration(ts?.[key]) && (ts?.[key] as ITextDecoration).s === BooleanNumber.FALSE) {- return {- s: BooleanNumber.TRUE,- };- }-- if (preCommandId === SetInlineFormatSubscriptCommand.id && ts?.[key] !== BaselineOffset.SUBSCRIPT) {- return BaselineOffset.SUBSCRIPT;- }-- if (preCommandId === SetInlineFormatSuperscriptCommand.id && ts?.[key] !== BaselineOffset.SUPERSCRIPT) {- return BaselineOffset.SUPERSCRIPT;- }-- if (ts?.[key] === BooleanNumber.FALSE) {- return BooleanNumber.TRUE;- }-ti++;}}- return /bl|it/.test(key)- ? BooleanNumber.FALSE- : /ul|st/.test(key)- ? {- s: BooleanNumber.FALSE,- }- : BaselineOffset.NORMAL;+ if (/bl|it/.test(key)) {+ return BooleanNumber.TRUE;+ } else if (/ul|st/.test(key)) {+ return {+ s: BooleanNumber.TRUE,+ };+ } else {+ return preCommandId === SetInlineFormatSubscriptCommand.id+ ? BaselineOffset.SUBSCRIPT+ : BaselineOffset.SUPERSCRIPT;+ }}diff --git a/packages/docs/src/commands/mutations/core-editing.mutation.ts b/packages/docs/src/commands/mutations/core-editing.mutation.tsindex 4fb68aa3f4..0cc15aaeab 100644--- a/packages/docs/src/commands/mutations/core-editing.mutation.ts+++ b/packages/docs/src/commands/mutations/core-editing.mutation.ts@@ -90,7 +90,7 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,segmentViewModel.reset(segmentDocumentDataModel);// Step 3: Update cursor & selection.- // make sure update cursor & selection after doc skeleton is calculated.+ // Make sure update cursor & selection after doc skeleton is calculated.if (!noNeedSetTextRange && textRanges) {queueMicrotask(() => {textSelectionManagerService.replaceTextRanges(textRanges);@@ -113,7 +113,7 @@ export const RichTextEditingMutation: IMutation<IRichTextEditingMutationParams,},};- // Handle ime input.+ // Handle IME input.if (isCompositionEnd) {const historyParams = imeInputManagerService.fetchComposedUndoRedoMutationParams();