Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Full toolbar is now shown in Super notes on non-mobile screens instead of floating formatting toolbar. It can be focused or toggled using Ctrl/Cmd+Shift+K #2576

Merged
merged 6 commits into from Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/icons/src/Icons/ic-indent.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/icons/src/Icons/ic-outdent.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 12 additions & 8 deletions packages/icons/src/Icons/index.ts
Expand Up @@ -104,6 +104,7 @@ import HistoryLockedIllustration from './il-history-locked.svg'
import IconsSpriteStylekit from './icons-sprite-stylekit.svg'
import IlNotesIcon from './il-notes.svg'
import ImageIcon from './ic-image.svg'
import IndentIcon from './ic-indent.svg'
import InfoIcon from './ic-info.svg'
import ItalicIcon from './ic-italic.svg'
import KeyboardCloseIcon from './ic-keyboard-close.svg'
Expand Down Expand Up @@ -137,6 +138,7 @@ import NoPreviewIllustration from './il-no-preview.svg'
import NotesFilledIcon from './ic-notes-filled.svg'
import NotesIcon from './ic-notes.svg'
import OpenInIcon from './ic-open-in.svg'
import OutdentIcon from './ic-outdent.svg'
import PasswordIcon from './ic-textbox-password.svg'
import PencilFilledIcon from './ic-pencil-filled.svg'
import PencilIcon from './ic-pencil.svg'
Expand Down Expand Up @@ -188,8 +190,8 @@ import SubtractIcon from './ic-subtract.svg'
import SuperscriptIcon from './ic-superscript.svg'
import SyncIcon from './ic-sync.svg'
import TasksIcon from './ic-tasks.svg'
import TextIcon from './ic-text.svg'
import TextCircleIcon from './ic-text-circle.svg'
import TextIcon from './ic-text.svg'
import TextParagraphLongIcon from './ic-text-paragraph-long.svg'
import ThemesFilledIcon from './ic-themes-filled.svg'
import ThemesIcon from './ic-themes.svg'
Expand Down Expand Up @@ -221,6 +223,7 @@ export {
AddBoldIcon,
AddIcon,
AddTextIcon,
AegisIcon,
ArchiveIcon,
ArrowDownCheckmarkIcon,
ArrowDownIcon,
Expand Down Expand Up @@ -274,6 +277,7 @@ export {
EmailFilledIcon,
EmailIcon,
EnterIcon,
EvernoteIcon,
EyeFilledIcon,
EyeIcon,
EyeOffFilledIcon,
Expand Down Expand Up @@ -304,6 +308,7 @@ export {
FullscreenExitIcon,
FullscreenIcon,
GiftOutlineIcon,
GoogleKeepIcon,
GroupIcon,
HashtagFilledIcon,
HashtagIcon,
Expand All @@ -316,6 +321,7 @@ export {
IconsSpriteStylekit,
IlNotesIcon,
ImageIcon,
IndentIcon,
InfoIcon,
ItalicIcon,
KeyboardCloseIcon,
Expand Down Expand Up @@ -349,6 +355,7 @@ export {
NotesFilledIcon,
NotesIcon,
OpenInIcon,
OutdentIcon,
PasswordIcon,
PencilFilledIcon,
PencilIcon,
Expand All @@ -364,6 +371,8 @@ export {
ProtectedIllustration,
RedoIcon,
ReorderIcon,
ReplaceAllIcon,
ReplaceIcon,
RestoreIcon,
RichTextIcon,
SafeIcon,
Expand All @@ -382,6 +391,7 @@ export {
ShortcutButtonIcon,
SignInIcon,
SignOutIcon,
SimplenoteIcon,
SNLogoAltIcon,
SNLogoFull,
SNLogoIcon,
Expand All @@ -397,8 +407,8 @@ export {
SuperscriptIcon,
SyncIcon,
TasksIcon,
TextIcon,
TextCircleIcon,
TextIcon,
TextParagraphLongIcon,
ThemesFilledIcon,
ThemesIcon,
Expand All @@ -420,10 +430,4 @@ export {
ViewIcon,
WarningIcon,
WindowIcon,
EvernoteIcon,
GoogleKeepIcon,
SimplenoteIcon,
AegisIcon,
ReplaceIcon,
ReplaceAllIcon,
}
1 change: 0 additions & 1 deletion packages/icons/src/Lexical/indent.svg

This file was deleted.

1 change: 0 additions & 1 deletion packages/icons/src/Lexical/outdent.svg

This file was deleted.

1 change: 1 addition & 0 deletions packages/ui-services/src/Keyboard/KeyboardCommands.ts
Expand Up @@ -27,6 +27,7 @@ export const STAR_NOTE_COMMAND = createKeyboardCommand('STAR_NOTE_COMMAND')
export const PIN_NOTE_COMMAND = createKeyboardCommand('PIN_NOTE_COMMAND')

export const SUPER_TOGGLE_SEARCH = createKeyboardCommand('SUPER_TOGGLE_SEARCH')
export const SUPER_TOGGLE_TOOLBAR = createKeyboardCommand('SUPER_TOGGLE_TOOLBAR')
export const SUPER_SEARCH_TOGGLE_CASE_SENSITIVE = createKeyboardCommand('SUPER_SEARCH_TOGGLE_CASE_SENSITIVE')
export const SUPER_SEARCH_TOGGLE_REPLACE_MODE = createKeyboardCommand('SUPER_SEARCH_TOGGLE_REPLACE_MODE')
export const SUPER_SEARCH_NEXT_RESULT = createKeyboardCommand('SUPER_SEARCH_NEXT_RESULT')
Expand Down
6 changes: 6 additions & 0 deletions packages/ui-services/src/Keyboard/getKeyboardShortcuts.ts
Expand Up @@ -30,6 +30,7 @@ import {
SUPER_SEARCH_PREVIOUS_RESULT,
SUPER_SEARCH_TOGGLE_REPLACE_MODE,
CHANGE_EDITOR_WIDTH_COMMAND,
SUPER_TOGGLE_TOOLBAR,
} from './KeyboardCommands'
import { KeyboardKey } from './KeyboardKey'
import { KeyboardModifier } from './KeyboardModifier'
Expand Down Expand Up @@ -147,6 +148,11 @@ export function getKeyboardShortcuts(platform: Platform, _environment: Environme
modifiers: [primaryModifier, KeyboardModifier.Shift],
preventDefault: true,
},
{
command: SUPER_TOGGLE_TOOLBAR,
key: 'k',
modifiers: [primaryModifier, KeyboardModifier.Shift],
},
{
command: SUPER_TOGGLE_SEARCH,
key: 'f',
Expand Down
Expand Up @@ -42,8 +42,8 @@ export const IconNameToSvgMapping = {
'fullscreen-exit': icons.FullscreenExitIcon,
'hashtag-off': icons.HashtagOffIcon,
'keyboard-close': icons.KeyboardCloseIcon,
'link-off': icons.LinkOffIcon,
'line-width': icons.LineWidthIcon,
'link-off': icons.LinkOffIcon,
'list-bulleted': icons.ListBulleted,
'list-numbered': icons.ListNumbered,
'lock-filled': icons.LockFilledIcon,
Expand Down Expand Up @@ -99,17 +99,19 @@ export const IconNameToSvgMapping = {
hashtag: icons.HashtagIcon,
help: icons.HelpIcon,
history: icons.HistoryIcon,
image: icons.ImageIcon,
indent: icons.IndentIcon,
info: icons.InfoIcon,
italic: icons.ItalicIcon,
keyboard: icons.KeyboardIcon,
link: icons.LinkIcon,
listed: icons.ListedIcon,
lock: icons.LockIcon,
image: icons.ImageIcon,
markdown: icons.MarkdownIcon,
merge: icons.MergeIcon,
more: icons.MoreIcon,
notes: icons.NotesIcon,
outdent: icons.OutdentIcon,
paragraph: icons.TextParagraphLongIcon,
password: icons.PasswordIcon,
pencil: icons.PencilIcon,
Expand Down
Expand Up @@ -19,7 +19,6 @@ import AutoEmbedPlugin from './Plugins/AutoEmbedPlugin'
import CollapsiblePlugin from './Plugins/CollapsiblePlugin'
import DraggableBlockPlugin from './Plugins/DraggableBlockPlugin'
import CodeHighlightPlugin from './Plugins/CodeHighlightPlugin'
import FloatingTextFormatToolbarPlugin from './Plugins/ToolbarPlugins/FloatingTextFormatToolbarPlugin'
import { TabIndentationPlugin } from './Plugins/TabIndentationPlugin'
import { handleEditorChange } from './Utils'
import { SuperEditorContentId } from './Constants'
Expand Down Expand Up @@ -110,7 +109,6 @@ export const BlocksEditor: FunctionComponent<BlocksEditorProps> = ({
<RemoveBrokenTablesPlugin />
{!readonly && floatingAnchorElem && (
<>
<FloatingTextFormatToolbarPlugin anchorElem={floatingAnchorElem} />
<DraggableBlockPlugin anchorElem={floatingAnchorElem} />
<TableActionMenuPlugin anchorElem={floatingAnchorElem} cellMerge />
</>
Expand Down
Expand Up @@ -4,13 +4,13 @@ export function GetIndentOutdentBlocks(editor: LexicalEditor) {
return [
{
name: 'Indent',
iconName: 'arrow-right',
iconName: 'indent',
keywords: ['indent'],
onSelect: () => editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined),
},
{
name: 'Outdent',
iconName: 'arrow-left',
iconName: 'outdent',
keywords: ['outdent'],
onSelect: () => editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined),
},
Expand Down
@@ -1,12 +1,11 @@
import Icon from '@/Components/Icon/Icon'
import { CloseIcon, CheckIcon, PencilFilledIcon, TrashFilledIcon } from '@standardnotes/icons'
import { KeyboardKey } from '@standardnotes/ui-services'
import { IconComponent } from '../../Lexical/Theme/IconComponent'
import { sanitizeUrl } from '../../Lexical/Utils/sanitizeUrl'
import { TOGGLE_LINK_COMMAND } from '@lexical/link'
import { useCallback, useState, useRef, useEffect } from 'react'
import { GridSelection, LexicalEditor, NodeSelection, RangeSelection } from 'lexical'
import { classNames } from '@standardnotes/snjs'
import StyledTooltip from '@/Components/StyledTooltip/StyledTooltip'

type Props = {
linkUrl: string
Expand Down Expand Up @@ -65,29 +64,27 @@ const LinkEditor = ({ linkUrl, isEditMode, setEditMode, editor, lastSelection, i
}}
className="flex-grow rounded-sm bg-contrast p-1 text-text sm:min-w-[40ch]"
/>
<button
className="flex rounded-lg p-3 hover:bg-contrast hover:text-text disabled:cursor-not-allowed"
onClick={() => {
setEditMode(false)
editor.focus()
}}
aria-label="Cancel editing link"
onMouseDown={(event) => event.preventDefault()}
>
<IconComponent size={15}>
<CloseIcon />
</IconComponent>
</button>
<button
className="flex rounded-lg p-3 hover:bg-contrast hover:text-text disabled:cursor-not-allowed"
onClick={handleLinkSubmission}
aria-label="Save link"
onMouseDown={(event) => event.preventDefault()}
>
<IconComponent size={15}>
<CheckIcon />
</IconComponent>
</button>
<StyledTooltip showOnMobile showOnHover label="Cancel editing">
<button
className="flex select-none items-center justify-center rounded p-2 enabled:hover:bg-default disabled:opacity-50 md:border md:border-transparent enabled:hover:md:translucent-ui:border-[--popover-border-color]"
onClick={() => {
setEditMode(false)
editor.focus()
}}
onMouseDown={(event) => event.preventDefault()}
>
<Icon type="close" size="medium" />
</button>
</StyledTooltip>
<StyledTooltip showOnMobile showOnHover label="Save link">
<button
className="flex select-none items-center justify-center rounded p-2 enabled:hover:bg-default disabled:opacity-50 md:border md:border-transparent enabled:hover:md:translucent-ui:border-[--popover-border-color]"
onClick={handleLinkSubmission}
onMouseDown={(event) => event.preventDefault()}
>
<Icon type="check" size="medium" />
</button>
</StyledTooltip>
</div>
) : (
<div className="flex items-center gap-1">
Expand All @@ -105,31 +102,29 @@ const LinkEditor = ({ linkUrl, isEditMode, setEditMode, editor, lastSelection, i
</a>
{!isAutoLink && (
<>
<button
className="flex rounded-lg p-3 hover:bg-contrast hover:text-text disabled:cursor-not-allowed"
onClick={() => {
setEditedLinkUrl(linkUrl)
setEditMode(true)
}}
aria-label="Edit link"
onMouseDown={(event) => event.preventDefault()}
>
<IconComponent size={15}>
<PencilFilledIcon />
</IconComponent>
</button>
<button
className="flex rounded-lg p-3 hover:bg-contrast hover:text-text disabled:cursor-not-allowed"
onClick={() => {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)
}}
aria-label="Remove link"
onMouseDown={(event) => event.preventDefault()}
>
<IconComponent size={15}>
<TrashFilledIcon />
</IconComponent>
</button>
<StyledTooltip showOnMobile showOnHover label="Edit link">
<button
className="flex select-none items-center justify-center rounded p-2 enabled:hover:bg-default disabled:opacity-50 md:border md:border-transparent enabled:hover:md:translucent-ui:border-[--popover-border-color]"
onClick={() => {
setEditedLinkUrl(linkUrl)
setEditMode(true)
}}
onMouseDown={(event) => event.preventDefault()}
>
<Icon type="pencil-filled" size="medium" />
</button>
</StyledTooltip>
<StyledTooltip showOnMobile showOnHover label="Remove link">
<button
className="flex select-none items-center justify-center rounded p-2 enabled:hover:bg-default disabled:opacity-50 md:border md:border-transparent enabled:hover:md:translucent-ui:border-[--popover-border-color]"
onClick={() => {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)
}}
onMouseDown={(event) => event.preventDefault()}
>
<Icon type="trash-filled" size="medium" />
</button>
</StyledTooltip>
</>
)}
</div>
Expand Down