From 4d8df6e951a7ea2cb388a1c0d318003e513fbb67 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 1 Jan 2018 11:58:23 -0800 Subject: [PATCH 1/2] Only show inline toolbar on mouseup if pointer selected --- .../Editor/components/Toolbar/Toolbar.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/components/Editor/components/Toolbar/Toolbar.js b/app/components/Editor/components/Toolbar/Toolbar.js index 5721ed8f9..f3123adbf 100644 --- a/app/components/Editor/components/Toolbar/Toolbar.js +++ b/app/components/Editor/components/Toolbar/Toolbar.js @@ -29,6 +29,7 @@ export default class Toolbar extends Component { @observable link: ?Node; @observable top: string = ''; @observable left: string = ''; + @observable mouseDown: boolean = false; props: { editor: Editor, @@ -39,6 +40,13 @@ export default class Toolbar extends Component { componentDidMount = () => { this.update(); + window.addEventListener('mousedown', this.handleMouseDown); + window.addEventListener('mouseup', this.handleMouseUp); + }; + + componentWillUnmount = () => { + window.removeEventListener('mousedown', this.handleMouseDown); + window.removeEventListener('mouseup', this.handleMouseUp); }; componentDidUpdate = () => { @@ -49,6 +57,15 @@ export default class Toolbar extends Component { this.link = undefined; }; + handleMouseDown = (e: SyntheticMouseEvent) => { + this.mouseDown = true; + }; + + handleMouseUp = (e: SyntheticMouseEvent) => { + this.mouseDown = false; + this.update(); + }; + showLinkToolbar = (ev: SyntheticEvent) => { ev.preventDefault(); ev.stopPropagation(); @@ -78,6 +95,9 @@ export default class Toolbar extends Component { // don't display toolbar for code blocks, code-lines inline code. if (value.startBlock.type.match(/code/)) return; + // don't show until user has released pointing device button + if (this.mouseDown) return; + this.active = true; this.link = this.link || link; From 1e38e70987dced28f6022dc821c1bad2de4d77e8 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 1 Jan 2018 11:58:35 -0800 Subject: [PATCH 2/2] Delay toolbar visibility a bit --- app/components/Editor/components/Toolbar/Toolbar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/components/Editor/components/Toolbar/Toolbar.js b/app/components/Editor/components/Toolbar/Toolbar.js index f3123adbf..27dd66518 100644 --- a/app/components/Editor/components/Toolbar/Toolbar.js +++ b/app/components/Editor/components/Toolbar/Toolbar.js @@ -167,6 +167,7 @@ const Menu = styled.div` transform: scale(0.95); transition: opacity 150ms cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 150ms cubic-bezier(0.175, 0.885, 0.32, 1.275); + transition-delay: 250ms; line-height: 0; height: 40px; min-width: 260px;