From f92f51236f10fca1d21b787a46dffbf6e565876a Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Mon, 16 Dec 2019 18:20:45 -0500
Subject: fixed setMark() made DocumentDocument default to being a previewer of
 selections

---
 src/client/util/TooltipTextMenu.tsx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'src/client/util/TooltipTextMenu.tsx')

diff --git a/src/client/util/TooltipTextMenu.tsx b/src/client/util/TooltipTextMenu.tsx
index 483ab40a7..fbdb9e377 100644
--- a/src/client/util/TooltipTextMenu.tsx
+++ b/src/client/util/TooltipTextMenu.tsx
@@ -709,7 +709,6 @@ export class TooltipTextMenu {
             return false;
         }
         this.setMark(colorMark, state, dispatch);
-        toggleMark(colorMark.type, { color: color })(state, dispatch);
     }
 
     createColorDropdown() {
@@ -927,7 +926,12 @@ export class TooltipTextMenu {
                 const tr = updateBullets(state.tr.setNodeMarkup(state.selection.from, node.type, attrs), state.schema);
                 dispatch(tr.setSelection(new NodeSelection(tr.doc.resolve(state.selection.from))));
             } else {
-                toggleMark(mark.type, mark.attrs)(state, dispatch);
+                toggleMark(mark.type, mark.attrs)(state, (tx: any) => {
+                    const { from, $from, to, empty } = tx.selection;
+                    if (!tx.doc.rangeHasMark(from, to, mark.type)) {
+                        toggleMark(mark.type, mark.attrs)({ tr: tx, doc: tx.doc, selection: tx.selection, storedMarks: tx.storedMarks }, dispatch);
+                    } else dispatch(tx);
+                });
             }
         }
     }
-- 
cgit v1.2.3-70-g09d2

