From ac58c8da5dc8ee5346bccd6da1f6883a7ce0d3d7 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 2 Apr 2024 14:49:15 -0400
Subject: fixed highlight list type button

---
 .../views/nodes/formattedText/RichTextMenu.tsx     | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 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 9c282a1d2..4bd4ca72b 100644
--- a/src/client/views/nodes/formattedText/RichTextMenu.tsx
+++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx
@@ -51,7 +51,7 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
 
     @observable private _activeFontSize: string = '13px';
     @observable private _activeFontFamily: string = '';
-    @observable private activeListType: string = '';
+    @observable private _activeListType: string = '';
     @observable private _activeAlignment: string = 'left';
 
     @observable private brushMarks: Set<Mark> = new Set();
@@ -103,6 +103,9 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
     @computed get fontSize() {
         return this._activeFontSize;
     }
+    @computed get listStyle() {
+        return this._activeListType;
+    }
     @computed get textAlign() {
         return this._activeAlignment;
     }
@@ -143,7 +146,7 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
         const refDoc = SelectionManager.Views.lastElement()?.layoutDoc ?? Doc.UserDoc();
         const refField = (pfx => (pfx ? pfx + '_' : ''))(SelectionManager.Views.lastElement()?.LayoutFieldKey);
 
-        this.activeListType = this.getActiveListStyle();
+        this._activeListType = this.getActiveListStyle();
         this._activeAlignment = this.getActiveAlignment();
         this._activeFontFamily = !activeFamilies.length ? StrCast(this.TextView?.Document._text_fontFamily, StrCast(refDoc[refField + 'fontFamily'], 'Arial')) : activeFamilies.length === 1 ? String(activeFamilies[0]) : 'various';
         this._activeFontSize = !activeSizes.length ? StrCast(this.TextView?.Document.fontSize, StrCast(refDoc[refField + 'fontSize'], '10px')) : activeSizes[0];
@@ -199,16 +202,15 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
 
     // finds font sizes and families in selection
     getActiveListStyle() {
-        if (this.view && this.TextView?._props.rootSelected?.()) {
-            const path = (this.view.state.selection.$from as any).path;
-            for (let i = 0; i < path.length; i += 3) {
-                if (path[i].type === this.view.state.schema.nodes.ordered_list) {
-                    return path[i].attrs.mapStyle;
+        const state = this.view?.state;
+        if (state) {
+            const pos = state.selection.$anchor;
+            for (let i = 0; i < pos.depth; i++) {
+                const node = pos.node(i);
+                if (node.type === schema.nodes.ordered_list) {
+                    return node.attrs.mapStyle;
                 }
             }
-            if (this.view.state.selection.$from.nodeAfter?.type === this.view.state.schema.nodes.ordered_list) {
-                return this.view.state.selection.$from.nodeAfter?.attrs.mapStyle;
-            }
         }
         return '';
     }
-- 
cgit v1.2.3-70-g09d2

