From 1608b5e52a3d00669ff269449df3681fa031db1e Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Thu, 14 Dec 2017 11:52:25 -0800 Subject: [PATCH] remove outmoded code from markdown widget hotkeys --- .../MarkdownControl/VisualEditor/keys.js | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/src/components/EditorWidgets/Markdown/MarkdownControl/VisualEditor/keys.js b/src/components/EditorWidgets/Markdown/MarkdownControl/VisualEditor/keys.js index 39aabae3..e799d5bd 100644 --- a/src/components/EditorWidgets/Markdown/MarkdownControl/VisualEditor/keys.js +++ b/src/components/EditorWidgets/Markdown/MarkdownControl/VisualEditor/keys.js @@ -3,37 +3,6 @@ import { isHotkey } from 'is-hotkey'; export default onKeyDown; -/** - * Minimal re-implementation of Slate's undo/redo functionality, but with focus - * forced back into editor afterward. - */ -function changeHistory(change, type) { - - /** - * Get the history for undo or redo (determined via `type` param). - */ - const { history } = change.value; - if (!history) return; - const historyOfType = history[`${type}s`]; - - /** - * If there is a next history item to apply, and it's valid, apply it. - */ - const next = historyOfType.first(); - const historyOfTypeIsValid = historyOfType.size > 1 - || (next && next.length > 1) - || (next && next[0] && next[0].type !== 'set_selection'; - - if (next && historyOfTypeIsValid) { - change[type](); - } - - /** - * Always ensure focus is set. - */ - return change.focus(); -} - function onKeyDown(event, change) { const createDefaultBlock = () => { return Block.create({ @@ -70,26 +39,9 @@ function onKeyDown(event, change) { } if (isHotkey(`mod+${event.key}`, event)) { - - /** - * Undo and redo work automatically with Slate, but focus is lost in certain - * actions. We override Slate's built in undo/redo here and force focus - * back to the editor each time. - */ - if (event.key === 'y') { - event.preventDefault(); - return changeHistory(change, 'redo'); - } - - if (event.key === 'z') { - event.preventDefault(); - return changeHistory(change, event.isShift ? 'redo' : 'undo'); - } - const marks = { b: 'bold', i: 'italic', - u: 'underline', s: 'strikethrough', '`': 'code', };