From 9090560302508dd29c24397ee00177d22cb200b5 Mon Sep 17 00:00:00 2001 From: ilya-bkv Date: Wed, 22 Mar 2023 15:07:28 +0300 Subject: [PATCH] Bullet and Numeric list --- public/icons/editor-ol.svg | 3 + public/locales/en/translation.json | 3 +- public/locales/ru/translation.json | 3 +- .../Editor/EditorBubbleMenu.module.scss | 12 +++- src/components/Editor/EditorBubbleMenu.tsx | 62 +++++++++++++++++-- 5 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 public/icons/editor-ol.svg diff --git a/public/icons/editor-ol.svg b/public/icons/editor-ol.svg new file mode 100644 index 00000000..cee95e7c --- /dev/null +++ b/public/icons/editor-ol.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index b265d116..d78ce69e 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -237,5 +237,6 @@ "Enter URL address": "Enter URL address", "Invalid url format": "Invalid url format", "Headers": "Headers", - "Quotes": "Quotes" + "Quotes": "Quotes", + "Lists": "Lists" } diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index 5cb1f3f8..1839ee0c 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -255,5 +255,6 @@ "Enter URL address": "Введите адрес ссылки", "Invalid url format": "Неверный формат ссылки", "Headers": "Заголовки", - "Quotes": "Цитаты" + "Quotes": "Цитаты", + "Lists": "Списки" } diff --git a/src/components/Editor/EditorBubbleMenu.module.scss b/src/components/Editor/EditorBubbleMenu.module.scss index 47a11cab..294b1e9c 100644 --- a/src/components/Editor/EditorBubbleMenu.module.scss +++ b/src/components/Editor/EditorBubbleMenu.module.scss @@ -9,6 +9,10 @@ flex-wrap: nowrap; opacity: 0.5; padding: 1rem; + + .triangle { + margin-left: 4px; + } } &:hover, @@ -80,10 +84,14 @@ .actions { display: flex; align-items: center; - justify-content: space-between; + justify-content: flex-start; gap: 12px; flex-wrap: nowrap; - margin-bottom: 16px; + margin-bottom: 8px; + + &:last-child { + margin-bottom: 0; + } .bubbleMenuButton { min-width: 40px; diff --git a/src/components/Editor/EditorBubbleMenu.tsx b/src/components/Editor/EditorBubbleMenu.tsx index 1ba2d472..cdc85bfa 100644 --- a/src/components/Editor/EditorBubbleMenu.tsx +++ b/src/components/Editor/EditorBubbleMenu.tsx @@ -6,6 +6,7 @@ import { clsx } from 'clsx' import { createEditorTransaction } from 'solid-tiptap' import { useLocalize } from '../../context/localize' import validateUrl from '../../utils/validateUrl' +import list from '../Feed/List' type BubbleMenuProps = { editor: Editor @@ -15,6 +16,7 @@ type BubbleMenuProps = { export const EditorBubbleMenu = (props: BubbleMenuProps) => { const { t } = useLocalize() const [textSizeBubbleOpen, setTextSizeBubbleOpen] = createSignal(false) + const [listBubbleOpen, setListBubbleOpen] = createSignal(false) const [linkEditorOpen, setLinkEditorOpen] = createSignal(false) const [url, setUrl] = createSignal('') const [prevUrl, setPrevUrl] = createSignal(null) @@ -46,6 +48,15 @@ export const EditorBubbleMenu = (props: BubbleMenuProps) => { () => props.editor, (editor) => editor && editor.isActive('blockquote') ) + const isOrderedList = createEditorTransaction( + () => props.editor, + (editor) => editor && editor.isActive('isOrderedList') + ) + const isBulletList = createEditorTransaction( + () => props.editor, + (editor) => editor && editor.isActive('isBulletList') + ) + const isLink = createEditorTransaction( () => props.editor, (editor) => { @@ -75,6 +86,15 @@ export const EditorBubbleMenu = (props: BubbleMenuProps) => { } } + const toggleTextSizePopup = () => { + if (listBubbleOpen()) setListBubbleOpen(false) + setTextSizeBubbleOpen((prev) => !prev) + } + const toggleListPopup = () => { + if (textSizeBubbleOpen()) setTextSizeBubbleOpen(false) + setListBubbleOpen((prev) => !prev) + } + return ( <>
@@ -105,10 +125,10 @@ export const EditorBubbleMenu = (props: BubbleMenuProps) => { class={clsx(styles.bubbleMenuButton, { [styles.bubbleMenuButtonActive]: textSizeBubbleOpen() })} - onClick={() => setTextSizeBubbleOpen(!textSizeBubbleOpen())} + onClick={toggleTextSizePopup} > - +
@@ -192,9 +212,41 @@ export const EditorBubbleMenu = (props: BubbleMenuProps) => {
- +
+ + +
+
{t('Lists')}
+
+ + +
+
+
+
)}