From 06d12894794e07814a696856b345e1b23625e018 Mon Sep 17 00:00:00 2001 From: winetree94 Date: Thu, 21 Dec 2023 17:53:08 +0900 Subject: [PATCH] e --- packages/core/src/commands/index.ts | 2 +- .../commands/{toggle-mark.ts => toggle-mark-with-attrs.ts} | 7 ++++++- packages/font-family/src/commands/toggle-font-family.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) rename packages/core/src/commands/{toggle-mark.ts => toggle-mark-with-attrs.ts} (94%) diff --git a/packages/core/src/commands/index.ts b/packages/core/src/commands/index.ts index e96bc7c4..7873cd88 100644 --- a/packages/core/src/commands/index.ts +++ b/packages/core/src/commands/index.ts @@ -1,4 +1,4 @@ export * from './transform-range-to-block'; export * from './set-text-align'; export * from './clear-marks'; -export * from './toggle-mark'; +export * from './toggle-mark-with-attrs'; diff --git a/packages/core/src/commands/toggle-mark.ts b/packages/core/src/commands/toggle-mark-with-attrs.ts similarity index 94% rename from packages/core/src/commands/toggle-mark.ts rename to packages/core/src/commands/toggle-mark-with-attrs.ts index e45bf8d8..577a8447 100644 --- a/packages/core/src/commands/toggle-mark.ts +++ b/packages/core/src/commands/toggle-mark-with-attrs.ts @@ -52,10 +52,14 @@ export const toggleMarkWithAttrs = ( if (missing) { return false; } + console.log(node); missing = !( markType.isInSet(node.marks) && - attrsComparator(attrs, node.attrs) + attrsComparator( + attrs, + node.marks.find((m) => m.type === markType)?.attrs || null, + ) ) && !!parent && parent.type.allowsMarkType(markType) && @@ -70,6 +74,7 @@ export const toggleMarkWithAttrs = ( ); return undefined; }); + console.log(missing); return !missing; }); } diff --git a/packages/font-family/src/commands/toggle-font-family.ts b/packages/font-family/src/commands/toggle-font-family.ts index aadd8ed6..c4db8773 100644 --- a/packages/font-family/src/commands/toggle-font-family.ts +++ b/packages/font-family/src/commands/toggle-font-family.ts @@ -10,6 +10,7 @@ export const toggleFontFamily = ( return toggleMarkWithAttrs(markType, attr, { removeWhenPresent: false, attrComparator(a, b) { + console.log(a, b); return ( (a as null | EdimFontFamilyAttrs)?.['fontFamily'] === (b as null | EdimFontFamilyAttrs)?.['fontFamily']