Toggle quotes (#210)

Toggle quotes
This commit is contained in:
Ilya Y 2023-09-05 10:59:36 +03:00 committed by GitHub
parent 59e7ba424a
commit 79d9422a9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 25 deletions

View File

@ -566,10 +566,7 @@ a[data-toggle='tooltip'] {
.tooltipContent { .tooltipContent {
max-height: 300px; max-height: 300px;
overflow: auto; overflow: auto;
color: var(--default-color-invert);
& * {
color: var(--default-color-invert);
}
a { a {
text-decoration: underline; text-decoration: underline;

View File

@ -145,7 +145,8 @@ export const FullArticle = (props: Props) => {
tooltip.appendChild(tooltipContent) tooltip.appendChild(tooltipContent)
document.body.appendChild(tooltip) document.body.appendChild(tooltip)
if (element.tagName === 'a') {
if (element.hasAttribute('href')) {
element.setAttribute('href', 'javascript: void(0);') element.setAttribute('href', 'javascript: void(0);')
} }
createPopper(element, tooltip, { createPopper(element, tooltip, {

View File

@ -1,4 +1,4 @@
import { createEffect, createSignal, onCleanup, Show } from 'solid-js' import { createEffect, createSignal, onCleanup } from 'solid-js'
import { createTiptapEditor, useEditorHTML } from 'solid-tiptap' import { createTiptapEditor, useEditorHTML } from 'solid-tiptap'
import uniqolor from 'uniqolor' import uniqolor from 'uniqolor'
import * as Y from 'yjs' import * as Y from 'yjs'
@ -41,10 +41,6 @@ import Article from './extensions/Article'
import { TextBubbleMenu } from './TextBubbleMenu' import { TextBubbleMenu } from './TextBubbleMenu'
import { FigureBubbleMenu, BlockquoteBubbleMenu, IncutBubbleMenu } from './BubbleMenu' import { FigureBubbleMenu, BlockquoteBubbleMenu, IncutBubbleMenu } from './BubbleMenu'
import { EditorFloatingMenu } from './EditorFloatingMenu' import { EditorFloatingMenu } from './EditorFloatingMenu'
import { TableOfContents } from '../TableOfContents'
import { isDesktop } from '../../utils/media-query'
import './Prosemirror.scss' import './Prosemirror.scss'
import { Image } from '@tiptap/extension-image' import { Image } from '@tiptap/extension-image'
import { Footnote } from './extensions/Footnote' import { Footnote } from './extensions/Footnote'

View File

@ -97,6 +97,21 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => {
setFootnoteEditorOpen(true) setFootnoteEditorOpen(true)
} }
const handleSetPunchline = () => {
if (isPunchLine()) {
props.editor.chain().focus().toggleBlockquote('punchline').run()
}
props.editor.chain().focus().toggleBlockquote('quote').run()
toggleTextSizePopup()
}
const handleSetQuote = () => {
if (isQuote()) {
props.editor.chain().focus().toggleBlockquote('quote').run()
}
props.editor.chain().focus().toggleBlockquote('punchline').run()
toggleTextSizePopup()
}
onMount(() => { onMount(() => {
window.addEventListener('keydown', handleKeyDown) window.addEventListener('keydown', handleKeyDown)
}) })
@ -207,11 +222,7 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => {
class={clsx(styles.bubbleMenuButton, { class={clsx(styles.bubbleMenuButton, {
[styles.bubbleMenuButtonActive]: isQuote() [styles.bubbleMenuButtonActive]: isQuote()
})} })}
onClick={() => { onClick={handleSetPunchline}
if (isPunchLine()) return
props.editor.chain().focus().toggleBlockquote('quote').run()
toggleTextSizePopup()
}}
> >
<Icon name="editor-blockquote" /> <Icon name="editor-blockquote" />
</button> </button>
@ -225,11 +236,7 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => {
class={clsx(styles.bubbleMenuButton, { class={clsx(styles.bubbleMenuButton, {
[styles.bubbleMenuButtonActive]: isPunchLine() [styles.bubbleMenuButtonActive]: isPunchLine()
})} })}
onClick={() => { onClick={handleSetQuote}
if (isQuote()) return
props.editor.chain().focus().toggleBlockquote('punchline').run()
toggleTextSizePopup()
}}
> >
<Icon name="editor-quote" /> <Icon name="editor-quote" />
</button> </button>

View File

@ -3,7 +3,6 @@ import type { Author, Shout, Topic } from '../../../graphql/types.gen'
import { Row1 } from '../../Feed/Row1' import { Row1 } from '../../Feed/Row1'
import { Row2 } from '../../Feed/Row2' import { Row2 } from '../../Feed/Row2'
import { Row3 } from '../../Feed/Row3' import { Row3 } from '../../Feed/Row3'
import { useAuthorsStore } from '../../../stores/zine/authors' import { useAuthorsStore } from '../../../stores/zine/authors'
import { loadShouts, useArticlesStore } from '../../../stores/zine/articles' import { loadShouts, useArticlesStore } from '../../../stores/zine/articles'
import { useRouter } from '../../../stores/router' import { useRouter } from '../../../stores/router'
@ -17,8 +16,6 @@ import { apiClient } from '../../../utils/apiClient'
import { Comment } from '../../Article/Comment' import { Comment } from '../../Article/Comment'
import { useLocalize } from '../../../context/localize' import { useLocalize } from '../../../context/localize'
import { AuthorRatingControl } from '../../Author/AuthorRatingControl' import { AuthorRatingControl } from '../../Author/AuthorRatingControl'
import { TopicCard } from '../../Topic/Card'
import { Loading } from '../../_shared/Loading'
import { hideModal } from '../../../stores/ui' import { hideModal } from '../../../stores/ui'
type AuthorProps = { type AuthorProps = {

View File

@ -1,4 +1,4 @@
import type { Author, Shout, ShoutInput, Topic, LoadShoutsOptions } from '../../graphql/types.gen' import type { Author, Shout, ShoutInput, LoadShoutsOptions } from '../../graphql/types.gen'
import { apiClient } from '../../utils/apiClient' import { apiClient } from '../../utils/apiClient'
import { addAuthorsByTopic } from './authors' import { addAuthorsByTopic } from './authors'
import { byStat } from '../../utils/sortby' import { byStat } from '../../utils/sortby'

View File

@ -1,6 +1,6 @@
import { apiClient } from '../../utils/apiClient' import { apiClient } from '../../utils/apiClient'
import type { Author } from '../../graphql/types.gen' import type { Author } from '../../graphql/types.gen'
import { createEffect, createSignal } from 'solid-js' import { createSignal } from 'solid-js'
import { createLazyMemo } from '@solid-primitives/memo' import { createLazyMemo } from '@solid-primitives/memo'
import { byStat } from '../../utils/sortby' import { byStat } from '../../utils/sortby'