Editor improvements (#191)

* Add tooltips to floating menu

* Add noWrap in small editor
This commit is contained in:
Ilya Y 2023-08-23 08:37:18 +03:00 committed by GitHub
parent 0f34bd47d9
commit 4e2f4f78cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 19 deletions

View File

@ -3,6 +3,8 @@
"About myself": "About myself", "About myself": "About myself",
"About the project": "About the project", "About the project": "About the project",
"Add a few topics so that the reader knows what your content is about and can find it on pages of topics that interest them. Topics can be swapped, the first topic becomes the title": "Add a few topics so that the reader knows what your content is about and can find it on pages of topics that interest them. Topics can be swapped, the first topic becomes the title", "Add a few topics so that the reader knows what your content is about and can find it on pages of topics that interest them. Topics can be swapped, the first topic becomes the title": "Add a few topics so that the reader knows what your content is about and can find it on pages of topics that interest them. Topics can be swapped, the first topic becomes the title",
"Add a link or click plus to embed media": "Add a link or click plus to embed media",
"Add an embed widget": "Add an embed widget",
"Add another image": "Add another image", "Add another image": "Add another image",
"Add audio": "Add audio", "Add audio": "Add audio",
"Add blockquote": "Add blockquote", "Add blockquote": "Add blockquote",
@ -12,6 +14,7 @@
"Add images": "Add images", "Add images": "Add images",
"Add intro": "Add intro", "Add intro": "Add intro",
"Add link": "Add link", "Add link": "Add link",
"Add rule": "Add rule",
"Add signature": "Add signature", "Add signature": "Add signature",
"Add subtitle": "Add subtitle", "Add subtitle": "Add subtitle",
"Add url": "Add url", "Add url": "Add url",
@ -260,7 +263,6 @@
"Send link again": "Send link again", "Send link again": "Send link again",
"Settings": "Settings", "Settings": "Settings",
"Share": "Share", "Share": "Share",
"Short opening": "Short opening",
"Show": "Show", "Show": "Show",
"Show lyrics": "Show lyrics", "Show lyrics": "Show lyrics",
"Slug": "Slug", "Slug": "Slug",

View File

@ -5,6 +5,8 @@
"About the project": "О проекте", "About the project": "О проекте",
"Accomplices": "Соучастники", "Accomplices": "Соучастники",
"Add a few topics so that the reader knows what your content is about and can find it on pages of topics that interest them. Topics can be swapped, the first topic becomes the title": "Добавьте несколько тем, чтобы читатель знал, о чем ваш материал, и мог найти его на страницах интересных ему тем. Темы можно менять местами, первая тема становится заглавной", "Add a few topics so that the reader knows what your content is about and can find it on pages of topics that interest them. Topics can be swapped, the first topic becomes the title": "Добавьте несколько тем, чтобы читатель знал, о чем ваш материал, и мог найти его на страницах интересных ему тем. Темы можно менять местами, первая тема становится заглавной",
"Add a link or click plus to embed media": "Добавьте ссылку или нажмите плюс для вставки медиа",
"Add an embed widget": "Добавить embed-виджет",
"Add another image": "Добавить другое изображение", "Add another image": "Добавить другое изображение",
"Add audio": "Добавить аудио", "Add audio": "Добавить аудио",
"Add blockquote": "Добавить цитату", "Add blockquote": "Добавить цитату",
@ -14,6 +16,7 @@
"Add images": "Добавить изображения", "Add images": "Добавить изображения",
"Add intro": "Добавить вступление", "Add intro": "Добавить вступление",
"Add link": "Добавить ссылку", "Add link": "Добавить ссылку",
"Add rule": "Добавить разделитель",
"Add signature": "Добавить подпись", "Add signature": "Добавить подпись",
"Add subtitle": "Добавить подзаголовок", "Add subtitle": "Добавить подзаголовок",
"Add to bookmarks": "Добавить в закладки", "Add to bookmarks": "Добавить в закладки",

View File

@ -159,7 +159,7 @@ export const Editor = (props: Props) => {
} }
}), }),
Placeholder.configure({ Placeholder.configure({
placeholder: t('Short opening') placeholder: t('Add a link or click plus to embed media')
}), }),
Focus, Focus,
Gapcursor, Gapcursor,

View File

@ -1,5 +1,7 @@
import styles from './Menu.module.scss' import styles from './Menu.module.scss'
import { Icon } from '../../../_shared/Icon' import { Icon } from '../../../_shared/Icon'
import { Popover } from '../../../_shared/Popover'
import { useLocalize } from '../../../../context/localize'
export type MenuItem = 'image' | 'embed' | 'horizontal-rule' export type MenuItem = 'image' | 'embed' | 'horizontal-rule'
@ -8,21 +10,34 @@ type Props = {
} }
export const Menu = (props: Props) => { export const Menu = (props: Props) => {
const { t } = useLocalize()
const setSelectedMenuItem = (value: MenuItem) => { const setSelectedMenuItem = (value: MenuItem) => {
props.selectedItem(value) props.selectedItem(value)
} }
return ( return (
<div class={styles.Menu}> <div class={styles.Menu}>
<button type="button" onClick={() => setSelectedMenuItem('image')}> <Popover content={t('Add image')}>
<Icon class={styles.icon} name="editor-image" /> {(triggerRef: (el) => void) => (
</button> <button ref={triggerRef} type="button" onClick={() => setSelectedMenuItem('image')}>
<button type="button" onClick={() => setSelectedMenuItem('embed')}> <Icon class={styles.icon} name="editor-image" />
<Icon class={styles.icon} name="editor-embed" /> </button>
</button> )}
<button type="button" onClick={() => setSelectedMenuItem('horizontal-rule')}> </Popover>
<Icon class={styles.icon} name="editor-horizontal-rule" /> <Popover content={t('Add an embed widget')}>
</button> {(triggerRef: (el) => void) => (
<button ref={triggerRef} type="button" onClick={() => setSelectedMenuItem('embed')}>
<Icon class={styles.icon} name="editor-embed" />
</button>
)}
</Popover>
<Popover content={t('Add rule')}>
{(triggerRef: (el) => void) => (
<button ref={triggerRef} type="button" onClick={() => setSelectedMenuItem('horizontal-rule')}>
<Icon class={styles.icon} name="editor-horizontal-rule" />
</button>
)}
</Popover>
</div> </div>
) )
} }

View File

@ -9,14 +9,10 @@
float: left; float: left;
height: 0; height: 0;
pointer-events: none; pointer-events: none;
font-weight: 500;
font-size: 20px;
line-height: 30px;
opacity: 0.3; opacity: 0.3;
} }
// Keeping the cursor active when moving outside the editable area // Keeping the cursor active when moving outside the editable area
.articleEditor p, .articleEditor p,
.articleEditor ul, .articleEditor ul,
.articleEditor h4, .articleEditor h4,
@ -25,16 +21,17 @@
flex: 0 0 auto; flex: 0 0 auto;
@media (width >= 768px) { @media (width >= 768px) {
padding-left: calc(21.9% + 3px); padding-left: calc(21.9%);
max-width: 72.7%; max-width: 72.7%;
} }
@media (width >= 1200px) { @media (width >= 1200px) {
padding-left: calc(21.5% + 3px); padding-left: calc(21.5% + 1px);
max-width: 64.9%; max-width: 64.9%;
} }
} }
.articleEditor hr,
.articleEditor blockquote, .articleEditor blockquote,
.articleEditor figure, .articleEditor figure,
.articleEditor article[data-type='incut'] { .articleEditor article[data-type='incut'] {

View File

@ -86,4 +86,8 @@
height: 0; height: 0;
color: transparent; color: transparent;
} }
.noWrap {
white-space: nowrap;
}
} }

View File

@ -252,7 +252,7 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => {
</Popover> </Popover>
<div class={styles.delimiter} /> <div class={styles.delimiter} />
</Show> </Show>
<Popover content={t('Add url')}> <Popover content={<div class={styles.noWrap}>{t('Add url')}</div>}>
{(triggerRef: (el) => void) => ( {(triggerRef: (el) => void) => (
<button <button
ref={triggerRef} ref={triggerRef}

View File

@ -4,7 +4,7 @@ import styles from './Popover.module.scss'
type Props = { type Props = {
children: (setTooltipEl: (el: HTMLElement | null) => void) => JSX.Element children: (setTooltipEl: (el: HTMLElement | null) => void) => JSX.Element
content: string content: string | JSX.Element
disabled?: boolean disabled?: boolean
} }