From 0fd3fb4b5bbb890d95a652b000c5fa7034e4a36b Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Fri, 21 Feb 2020 14:34:18 -0500 Subject: [PATCH] More mobile tweaks (#790) * Disable text selection * Set content-editable=plaintext-only to disable Touch Bar formatting buttons * Enlarge resize handle tap targets for pen/touch * Make the lock button a button in mobile mode * Use icons instead of Unicode characters; add an alternate toolbar for creating multipoint lines * Allow buttons to hide themselves * Fix heuristic for showing shape actions * Refactor icons * Fix label for edit button * Switch edit button icon * Remove lock button on mobile * Add language selector on mobile * Fix showing edit button on mobile * Fix showing edit button on mobile, part 2 * Fix handle touch regions * Fix scroll-back button position * Allow using the text tool on a text object to start editing it * Fix deletion of last point in line --- src/actions/actionDeleteSelected.tsx | 3 +- src/actions/actionFinalize.tsx | 17 +-- src/appState.ts | 1 + src/components/LanguageList.tsx | 6 +- src/components/LockIcon.tsx | 8 +- src/components/ProjectName.tsx | 2 +- src/components/ToolButton.tsx | 5 + src/components/ToolIcon.scss | 28 +++-- src/components/icons.tsx | 123 +++++++++---------- src/element/handlerRectangles.ts | 59 ++++++---- src/element/resizeTest.ts | 8 +- src/element/textWysiwyg.tsx | 2 +- src/element/types.ts | 2 + src/index.tsx | 169 +++++++++++++++------------ src/locales/en.json | 6 +- src/styles.scss | 52 +++++---- src/types.ts | 3 +- 17 files changed, 272 insertions(+), 222 deletions(-) diff --git a/src/actions/actionDeleteSelected.tsx b/src/actions/actionDeleteSelected.tsx index d3c3d3a5..6bc15572 100644 --- a/src/actions/actionDeleteSelected.tsx +++ b/src/actions/actionDeleteSelected.tsx @@ -18,13 +18,14 @@ export const actionDeleteSelected: Action = { contextMenuOrder: 3, commitToHistory: (_, elements) => isSomeElementSelected(elements), keyTest: event => event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE, - PanelComponent: ({ updateData }) => ( + PanelComponent: ({ elements, updateData }) => ( updateData(null)} + visible={isSomeElementSelected(elements)} /> ), }; diff --git a/src/actions/actionFinalize.tsx b/src/actions/actionFinalize.tsx index 44770285..814c3898 100644 --- a/src/actions/actionFinalize.tsx +++ b/src/actions/actionFinalize.tsx @@ -5,7 +5,7 @@ import { isInvisiblySmallElement } from "../element"; import { resetCursor } from "../utils"; import React from "react"; import { ToolButton } from "../components/ToolButton"; -import { save } from "../components/icons"; +import { done } from "../components/icons"; import { t } from "../i18n"; export const actionFinalize: Action = { @@ -16,10 +16,13 @@ export const actionFinalize: Action = { window.document.activeElement.blur(); } if (appState.multiElement) { - appState.multiElement.points = appState.multiElement.points.slice( - 0, - appState.multiElement.points.length - 1, - ); + // pen and mouse have hover + if (appState.lastPointerDownWith !== "touch") { + appState.multiElement.points = appState.multiElement.points.slice( + 0, + appState.multiElement.points.length - 1, + ); + } if (isInvisiblySmallElement(appState.multiElement)) { newElements = newElements.slice(0, -1); } @@ -50,12 +53,12 @@ export const actionFinalize: Action = { PanelComponent: ({ appState, updateData }) => (
updateData(null)} diff --git a/src/appState.ts b/src/appState.ts index 9d4472fd..95f047d1 100644 --- a/src/appState.ts +++ b/src/appState.ts @@ -30,6 +30,7 @@ export function getDefaultAppState(): AppState { selectionElement: null, zoom: 1, openedMenu: null, + lastPointerDownWith: "mouse", }; } diff --git a/src/components/LanguageList.tsx b/src/components/LanguageList.tsx index ca75c5c5..c64fdb9a 100644 --- a/src/components/LanguageList.tsx +++ b/src/components/LanguageList.tsx @@ -5,15 +5,19 @@ export function LanguageList({ onChange, languages, currentLanguage, + floating, }: { languages: { lng: string; label: string }[]; onChange: (value: string) => void; currentLanguage: string; + floating?: boolean; }) { return ( { return (