From 8949ec7c7aca6b780dd5a7c9e37a37409208124a Mon Sep 17 00:00:00 2001 From: "andrerpena@gmail.com" Date: Mon, 17 Aug 2020 22:50:27 +0100 Subject: [PATCH 1/2] Remove resize grip --- demo/App.tsx | 4 +-- src/components/ReactMde.tsx | 52 -------------------------------- src/components/grip-svg.tsx | 21 ------------- src/l18n/react-mde.en.ts | 3 +- src/styles/react-mde-editor.scss | 2 +- 5 files changed, 5 insertions(+), 77 deletions(-) delete mode 100644 src/components/grip-svg.tsx diff --git a/demo/App.tsx b/demo/App.tsx index afd17624..05887edd 100644 --- a/demo/App.tsx +++ b/demo/App.tsx @@ -60,9 +60,9 @@ export class App extends React.Component<{}, AppState> { }; render() { - const save: SaveImageHandler = async function*(data: ArrayBuffer) { + const save: SaveImageHandler = async function* (data: ArrayBuffer) { // Promise that waits for "time" milliseconds - const wait = function(time: number) { + const wait = function (time: number) { return new Promise((a, r) => { setTimeout(() => a(), time); }); diff --git a/src/components/ReactMde.tsx b/src/components/ReactMde.tsx index f45177ba..acccc5aa 100644 --- a/src/components/ReactMde.tsx +++ b/src/components/ReactMde.tsx @@ -22,7 +22,6 @@ import { CommandOrchestrator } from "../commands/command-orchestrator"; import { Refs } from "../refs"; import { ButtonHTMLAttributes, TextareaHTMLAttributes } from "react"; import { ComponentSimilarTo } from "../util/type-utils"; -import { GripSvg } from "./grip-svg"; export interface ReactMdeProps { value: string; @@ -76,12 +75,6 @@ export class ReactMde extends React.Component { finalRefs: Refs; commandOrchestrator: CommandOrchestrator; - // resizeYStart will be null when it is not resizing - gripDrag: { - originalDragY: number; - originalHeight: number; - } = null; - static defaultProps: Partial = { commands: getDefaultCommandMap(), toolbarCommands: getDefaultToolbarCommands(), @@ -125,37 +118,6 @@ export class ReactMde extends React.Component { onChange(value); }; - handleGripMouseDown = (event: React.MouseEvent) => { - this.gripDrag = { - originalHeight: this.state.editorHeight, - originalDragY: event.clientY - }; - }; - - handleGripMouseUp = () => { - this.gripDrag = null; - }; - - handleGripMouseMove = (event: MouseEvent) => { - if (this.gripDrag !== null) { - const newHeight = - this.gripDrag.originalHeight + - event.clientY - - this.gripDrag.originalDragY; - if ( - newHeight >= this.props.minEditorHeight && - newHeight <= this.props.maxEditorHeight - ) { - this.setState({ - ...this.state, - editorHeight: - this.gripDrag.originalHeight + - (event.clientY - this.gripDrag.originalDragY) - }); - } - } - }; - handlePaste = async (event: React.ClipboardEvent) => { const { paste } = this.props; if (!paste || !paste.saveImage) { @@ -187,14 +149,6 @@ export class ReactMde extends React.Component { onTabChange(newTab); }; - componentDidMount() { - document.addEventListener<"mousemove">( - "mousemove", - this.handleGripMouseMove - ); - document.addEventListener<"mouseup">("mouseup", this.handleGripMouseUp); - } - handleCommand = async (commandName: string) => { await this.commandOrchestrator.executeCommand(commandName); }; @@ -286,12 +240,6 @@ export class ReactMde extends React.Component { {l18n.pasteDropSelect} )} -
- -
{selectedTab !== "write" && (