From a0b595c00111404e9a4fb6b9a926ef22c6e2979b Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sun, 11 Sep 2022 13:27:44 -0400
Subject: fixed fontFamily menu for ink strokes

---
 .../views/nodes/formattedText/RichTextMenu.tsx     | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

(limited to 'src/client/views/nodes/formattedText/RichTextMenu.tsx')

diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx
index 9faaa0f3a..6c6d26af5 100644
--- a/src/client/views/nodes/formattedText/RichTextMenu.tsx
+++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx
@@ -183,13 +183,11 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
 
     // finds font sizes and families in selection
     getActiveFontStylesOnSelection() {
-        if (!this.view) return { activeFamilies: [], activeSizes: [], activeColors: [], activeHighlights: [] };
-
-        const activeFamilies: string[] = [];
-        const activeSizes: string[] = [];
-        const activeColors: string[] = [];
-        const activeHighlights: string[] = [];
-        if (this.TextView?.props.isSelected(true)) {
+        const activeFamilies = new Set<string>();
+        const activeSizes = new Set<string>();
+        const activeColors = new Set<string>();
+        const activeHighlights = new Set<string>();
+        if (this.view && this.TextView?.props.isSelected(true)) {
             const state = this.view.state;
             const pos = this.view.state.selection.$from;
             const marks: Mark[] = [...(state.storedMarks ?? [])];
@@ -203,13 +201,13 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
                 });
             }
             marks.forEach(m => {
-                m.type === state.schema.marks.pFontFamily && activeFamilies.push(m.attrs.family);
-                m.type === state.schema.marks.pFontColor && activeColors.push(m.attrs.color);
-                m.type === state.schema.marks.pFontSize && activeSizes.push(m.attrs.fontSize);
-                m.type === state.schema.marks.marker && activeHighlights.push(String(m.attrs.highlight));
+                m.type === state.schema.marks.pFontFamily && activeFamilies.add(m.attrs.family);
+                m.type === state.schema.marks.pFontColor && activeColors.add(m.attrs.color);
+                m.type === state.schema.marks.pFontSize && activeSizes.add(m.attrs.fontSize);
+                m.type === state.schema.marks.marker && activeHighlights.add(String(m.attrs.highlight));
             });
         }
-        return { activeFamilies, activeSizes, activeColors, activeHighlights };
+        return { activeFamilies: Array.from(activeFamilies), activeSizes: Array.from(activeSizes), activeColors: Array.from(activeColors), activeHighlights: Array.from(activeHighlights) };
     }
 
     getMarksInSelection(state: EditorState) {
-- 
cgit v1.2.3-70-g09d2

