editor-showup+fixes
This commit is contained in:
parent
b3b8e51d2d
commit
d7a5a188ff
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -25,9 +25,9 @@ bun.lockb
|
||||||
/plawright-report/
|
/plawright-report/
|
||||||
target
|
target
|
||||||
.github/dependabot.yml
|
.github/dependabot.yml
|
||||||
|
|
||||||
.output
|
.output
|
||||||
.vinxi
|
.vinxi
|
||||||
*.pem
|
*.pem
|
||||||
edge.*
|
edge.*
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
storybook-static
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { Page } from '@playwright/test'
|
||||||
import type { TestRunnerConfig } from '@storybook/test-runner'
|
import type { TestRunnerConfig } from '@storybook/test-runner'
|
||||||
import { checkA11y, injectAxe } from 'axe-playwright'
|
import { checkA11y, injectAxe } from 'axe-playwright'
|
||||||
|
|
||||||
|
@ -5,11 +6,11 @@ import { checkA11y, injectAxe } from 'axe-playwright'
|
||||||
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental
|
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental
|
||||||
* to learn more about the test-runner hooks API.
|
* to learn more about the test-runner hooks API.
|
||||||
*/
|
*/
|
||||||
const a11yConfig: TestRunnerConfig = {
|
const a11yConfig = {
|
||||||
async preRender(page) {
|
async preRender(page: Page) {
|
||||||
await injectAxe(page)
|
await injectAxe(page)
|
||||||
},
|
},
|
||||||
async postRender(page) {
|
async postRender(page: Page) {
|
||||||
await checkA11y(page, '#storybook-root', {
|
await checkA11y(page, '#storybook-root', {
|
||||||
detailedReport: true,
|
detailedReport: true,
|
||||||
detailedReportOptions: {
|
detailedReportOptions: {
|
||||||
|
@ -17,6 +18,6 @@ const a11yConfig: TestRunnerConfig = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
} as TestRunnerConfig
|
||||||
|
|
||||||
module.exports = a11yConfig
|
module.exports = a11yConfig
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
.vercel/
|
node_modules
|
||||||
dist/
|
dist/
|
||||||
|
storybook-static
|
||||||
|
.output
|
||||||
|
.vinxi
|
||||||
|
.vercel
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
import { SolidStartInlineConfig, defineConfig } from '@solidjs/start/config'
|
import { SolidStartInlineConfig, defineConfig } from '@solidjs/start/config'
|
||||||
import dotenv from 'dotenv'
|
import viteConfig, { isDev } from './vite.config'
|
||||||
import viteConfig from './vite.config'
|
|
||||||
|
|
||||||
// Load environment variables from .env file
|
|
||||||
dotenv.config()
|
|
||||||
|
|
||||||
const isVercel = Boolean(process.env.VERCEL)
|
const isVercel = Boolean(process.env.VERCEL)
|
||||||
const isNetlify = Boolean(process.env.NETLIFY)
|
const isNetlify = Boolean(process.env.NETLIFY)
|
||||||
const isBun = Boolean(process.env.BUN)
|
const isBun = Boolean(process.env.BUN)
|
||||||
|
|
||||||
export const runtime = isNetlify ? 'netlify' : isVercel ? 'vercel_edge' : isBun ? 'bun' : 'node'
|
const preset = isNetlify ? 'netlify' : isVercel ? 'vercel_edge' : isBun ? 'bun' : 'node'
|
||||||
console.info(`[app.config] solid-start build for {> ${runtime} <}`)
|
console.info(`[app.config] solid-start preset {> ${preset} <}`)
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
nitro: {
|
nitro: {
|
||||||
|
@ -18,10 +14,10 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
ssr: true,
|
ssr: true,
|
||||||
server: {
|
server: {
|
||||||
preset: runtime,
|
preset,
|
||||||
port: 3000,
|
port: 3000,
|
||||||
https: true
|
https: true
|
||||||
},
|
},
|
||||||
devOverlay: true,
|
devOverlay: isDev,
|
||||||
vite: viteConfig
|
vite: viteConfig
|
||||||
} as SolidStartInlineConfig)
|
} as SolidStartInlineConfig)
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
"@tiptap/starter-kit": "^2.7.2",
|
"@tiptap/starter-kit": "^2.7.2",
|
||||||
"@types/cookie": "^0.6.0",
|
"@types/cookie": "^0.6.0",
|
||||||
"@types/cookie-signature": "^1.1.2",
|
"@types/cookie-signature": "^1.1.2",
|
||||||
"@types/node": "^22.6.0",
|
"@types/node": "^22.6.1",
|
||||||
"@types/throttle-debounce": "^5.0.2",
|
"@types/throttle-debounce": "^5.0.2",
|
||||||
"@urql/core": "^5.0.6",
|
"@urql/core": "^5.0.6",
|
||||||
"axe-playwright": "^2.0.2",
|
"axe-playwright": "^2.0.2",
|
||||||
|
|
|
@ -4,14 +4,7 @@ import { BubbleMenu } from '@tiptap/extension-bubble-menu'
|
||||||
import { CharacterCount } from '@tiptap/extension-character-count'
|
import { CharacterCount } from '@tiptap/extension-character-count'
|
||||||
import { Collaboration } from '@tiptap/extension-collaboration'
|
import { Collaboration } from '@tiptap/extension-collaboration'
|
||||||
import { CollaborationCursor } from '@tiptap/extension-collaboration-cursor'
|
import { CollaborationCursor } from '@tiptap/extension-collaboration-cursor'
|
||||||
import { Dropcursor } from '@tiptap/extension-dropcursor'
|
|
||||||
import { FloatingMenu } from '@tiptap/extension-floating-menu'
|
import { FloatingMenu } from '@tiptap/extension-floating-menu'
|
||||||
import Focus from '@tiptap/extension-focus'
|
|
||||||
import { Gapcursor } from '@tiptap/extension-gapcursor'
|
|
||||||
import { HardBreak } from '@tiptap/extension-hard-break'
|
|
||||||
import { Highlight } from '@tiptap/extension-highlight'
|
|
||||||
import { HorizontalRule } from '@tiptap/extension-horizontal-rule'
|
|
||||||
import { Image } from '@tiptap/extension-image'
|
|
||||||
import { Placeholder } from '@tiptap/extension-placeholder'
|
import { Placeholder } from '@tiptap/extension-placeholder'
|
||||||
import { Show, createEffect, createMemo, createSignal, on, onCleanup } from 'solid-js'
|
import { Show, createEffect, createMemo, createSignal, on, onCleanup } from 'solid-js'
|
||||||
import uniqolor from 'uniqolor'
|
import uniqolor from 'uniqolor'
|
||||||
|
@ -21,23 +14,14 @@ import { useLocalize } from '~/context/localize'
|
||||||
import { useSession } from '~/context/session'
|
import { useSession } from '~/context/session'
|
||||||
import { useSnackbar } from '~/context/ui'
|
import { useSnackbar } from '~/context/ui'
|
||||||
import { Author } from '~/graphql/schema/core.gen'
|
import { Author } from '~/graphql/schema/core.gen'
|
||||||
|
import { base, custom, extended } from '~/lib/editorExtensions'
|
||||||
import { handleImageUpload } from '~/lib/handleImageUpload'
|
import { handleImageUpload } from '~/lib/handleImageUpload'
|
||||||
import { BlockquoteBubbleMenu, FigureBubbleMenu, IncutBubbleMenu } from './BubbleMenu'
|
import { BlockquoteBubbleMenu, FigureBubbleMenu, IncutBubbleMenu } from './BubbleMenu'
|
||||||
import { EditorFloatingMenu } from './EditorFloatingMenu'
|
import { EditorFloatingMenu } from './EditorFloatingMenu'
|
||||||
import { TextBubbleMenu } from './TextBubbleMenu'
|
import { TextBubbleMenu } from './TextBubbleMenu'
|
||||||
import { ArticleNode } from './extensions/Article'
|
|
||||||
import { CustomBlockquote } from './extensions/CustomBlockquote'
|
|
||||||
import { Figcaption } from './extensions/Figcaption'
|
|
||||||
import { Figure } from './extensions/Figure'
|
|
||||||
import { Footnote } from './extensions/Footnote'
|
|
||||||
import { Iframe } from './extensions/Iframe'
|
|
||||||
import { Span } from './extensions/Span'
|
|
||||||
import { ToggleTextWrap } from './extensions/ToggleTextWrap'
|
|
||||||
import { TrailingNode } from './extensions/TrailingNode'
|
|
||||||
import { renderUploadedImage } from './renderUploadedImage'
|
import { renderUploadedImage } from './renderUploadedImage'
|
||||||
|
|
||||||
import './Prosemirror.scss'
|
import './Prosemirror.scss'
|
||||||
import { base } from '~/lib/editorOptions'
|
|
||||||
|
|
||||||
export type EditorComponentProps = {
|
export type EditorComponentProps = {
|
||||||
shoutId: number
|
shoutId: number
|
||||||
|
@ -118,26 +102,11 @@ export const EditorComponent = (props: EditorComponentProps) => {
|
||||||
},
|
},
|
||||||
extensions: [
|
extensions: [
|
||||||
...base,
|
...base,
|
||||||
|
...custom,
|
||||||
|
...extended,
|
||||||
|
|
||||||
HorizontalRule.configure({ HTMLAttributes: { class: 'horizontalRule' } }),
|
|
||||||
Dropcursor,
|
|
||||||
CustomBlockquote,
|
|
||||||
Span,
|
|
||||||
ToggleTextWrap,
|
|
||||||
Placeholder.configure({ placeholder: t('Add a link or click plus to embed media') }),
|
Placeholder.configure({ placeholder: t('Add a link or click plus to embed media') }),
|
||||||
Focus,
|
|
||||||
Gapcursor,
|
|
||||||
HardBreak,
|
|
||||||
Highlight.configure({ multicolor: true, HTMLAttributes: { class: 'highlight' } }),
|
|
||||||
Image,
|
|
||||||
Iframe,
|
|
||||||
Figure,
|
|
||||||
Figcaption,
|
|
||||||
Footnote,
|
|
||||||
ToggleTextWrap,
|
|
||||||
CharacterCount.configure(), // https://github.com/ueberdosis/tiptap/issues/2589#issuecomment-1093084689
|
CharacterCount.configure(), // https://github.com/ueberdosis/tiptap/issues/2589#issuecomment-1093084689
|
||||||
TrailingNode,
|
|
||||||
ArticleNode,
|
|
||||||
|
|
||||||
// menus
|
// menus
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { Icon } from '~/components/_shared/Icon/Icon'
|
||||||
import { Popover } from '~/components/_shared/Popover/Popover'
|
import { Popover } from '~/components/_shared/Popover/Popover'
|
||||||
import { useLocalize } from '~/context/localize'
|
import { useLocalize } from '~/context/localize'
|
||||||
import { useUI } from '~/context/ui'
|
import { useUI } from '~/context/ui'
|
||||||
import { base } from '~/lib/editorOptions'
|
import { base } from '~/lib/editorExtensions'
|
||||||
import { InsertLinkForm } from '../InsertLinkForm/InsertLinkForm'
|
import { InsertLinkForm } from '../InsertLinkForm/InsertLinkForm'
|
||||||
|
|
||||||
import styles from '../SimplifiedEditor.module.scss'
|
import styles from '../SimplifiedEditor.module.scss'
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Portal } from 'solid-js/web'
|
||||||
import { createEditorTransaction, useEditorHTML, useEditorIsEmpty, useEditorIsFocused } from 'solid-tiptap'
|
import { createEditorTransaction, useEditorHTML, useEditorIsEmpty, useEditorIsFocused } from 'solid-tiptap'
|
||||||
import { useEditorContext } from '~/context/editor'
|
import { useEditorContext } from '~/context/editor'
|
||||||
import { useUI } from '~/context/ui'
|
import { useUI } from '~/context/ui'
|
||||||
import { base, custom } from '~/lib/editorOptions'
|
import { base, custom } from '~/lib/editorExtensions'
|
||||||
import { useEscKeyDownHandler } from '~/lib/useEscKeyDownHandler'
|
import { useEscKeyDownHandler } from '~/lib/useEscKeyDownHandler'
|
||||||
import { UploadedFile } from '~/types/upload'
|
import { UploadedFile } from '~/types/upload'
|
||||||
import { Modal } from '../_shared/Modal/Modal'
|
import { Modal } from '../_shared/Modal/Modal'
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import deepEqual from 'fast-deep-equal'
|
import deepEqual from 'fast-deep-equal'
|
||||||
import {
|
import {
|
||||||
Accessor,
|
|
||||||
Show,
|
Show,
|
||||||
createEffect,
|
createEffect,
|
||||||
createMemo,
|
createMemo,
|
||||||
|
@ -65,10 +64,7 @@ const handleScrollTopButtonClick = (ev: MouseEvent | TouchEvent) => {
|
||||||
|
|
||||||
export const EditView = (props: Props) => {
|
export const EditView = (props: Props) => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const [isScrolled, setIsScrolled] = createSignal(false)
|
|
||||||
const { session } = useSession()
|
const { session } = useSession()
|
||||||
const client = createMemo(() => graphqlClientCreate(coreApiUrl, session()?.access_token))
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
form,
|
form,
|
||||||
formErrors,
|
formErrors,
|
||||||
|
@ -78,14 +74,20 @@ export const EditView = (props: Props) => {
|
||||||
saveDraftToLocalStorage,
|
saveDraftToLocalStorage,
|
||||||
getDraftFromLocalStorage
|
getDraftFromLocalStorage
|
||||||
} = useEditorContext()
|
} = useEditorContext()
|
||||||
const [shoutTopics, setShoutTopics] = createSignal<Topic[]>([])
|
|
||||||
const [draft, setDraft] = createSignal()
|
const [subtitleInput, setSubtitleInput] = createSignal<HTMLTextAreaElement | undefined>()
|
||||||
let subtitleInput: HTMLTextAreaElement | null
|
|
||||||
const [prevForm, setPrevForm] = createStore<ShoutForm>(clone(form))
|
const [prevForm, setPrevForm] = createStore<ShoutForm>(clone(form))
|
||||||
const [saving, setSaving] = createSignal(false)
|
const [saving, setSaving] = createSignal(false)
|
||||||
const [isSubtitleVisible, setIsSubtitleVisible] = createSignal(Boolean(form.subtitle))
|
const [isSubtitleVisible, setIsSubtitleVisible] = createSignal(Boolean(form.subtitle))
|
||||||
const [isLeadVisible, setIsLeadVisible] = createSignal(Boolean(form.lead))
|
const [isLeadVisible, setIsLeadVisible] = createSignal(Boolean(form.lead))
|
||||||
const mediaItems: Accessor<MediaItem[]> = createMemo(() => JSON.parse(form.media || '[]'))
|
const [isScrolled, setIsScrolled] = createSignal(false)
|
||||||
|
const [shoutTopics, setShoutTopics] = createSignal<Topic[]>([])
|
||||||
|
const [draft, setDraft] = createSignal<Shout>()
|
||||||
|
const [mediaItems, setMediaItems] = createSignal<MediaItem[]>([])
|
||||||
|
|
||||||
|
const client = createMemo(() => graphqlClientCreate(coreApiUrl, session()?.access_token))
|
||||||
|
|
||||||
|
createEffect(() => setMediaItems(JSON.parse(form.media || '[]')))
|
||||||
|
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
|
@ -97,7 +99,7 @@ export const EditView = (props: Props) => {
|
||||||
const stored = getDraftFromLocalStorage(shout.id)
|
const stored = getDraftFromLocalStorage(shout.id)
|
||||||
if (stored) {
|
if (stored) {
|
||||||
// console.info(`[EditView] got stored shout: ${stored}`)
|
// console.info(`[EditView] got stored shout: ${stored}`)
|
||||||
setDraft(stored)
|
setDraft((old) => ({...old, ...stored} as Shout))
|
||||||
} else {
|
} else {
|
||||||
if (!shout.slug) {
|
if (!shout.slug) {
|
||||||
console.warn(`[EditView] shout has no slug! ${shout}`)
|
console.warn(`[EditView] shout has no slug! ${shout}`)
|
||||||
|
@ -131,7 +133,7 @@ export const EditView = (props: Props) => {
|
||||||
(d) => {
|
(d) => {
|
||||||
if (d) {
|
if (d) {
|
||||||
const draftForm = Object.keys(d) ? d : { shoutId: props.shout.id }
|
const draftForm = Object.keys(d) ? d : { shoutId: props.shout.id }
|
||||||
setForm(draftForm)
|
setForm(draftForm as ShoutForm)
|
||||||
console.debug('draft from localstorage: ', draftForm)
|
console.debug('draft from localstorage: ', draftForm)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -267,7 +269,7 @@ export const EditView = (props: Props) => {
|
||||||
|
|
||||||
const showSubtitleInput = () => {
|
const showSubtitleInput = () => {
|
||||||
setIsSubtitleVisible(true)
|
setIsSubtitleVisible(true)
|
||||||
subtitleInput?.focus()
|
subtitleInput()?.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
const showLeadInput = () => {
|
const showLeadInput = () => {
|
||||||
|
@ -359,7 +361,7 @@ export const EditView = (props: Props) => {
|
||||||
<Show when={props.shout.layout !== 'audio'}>
|
<Show when={props.shout.layout !== 'audio'}>
|
||||||
<Show when={isSubtitleVisible()}>
|
<Show when={isSubtitleVisible()}>
|
||||||
<GrowingTextarea
|
<GrowingTextarea
|
||||||
textAreaRef={(el) => (subtitleInput = el)}
|
textAreaRef={setSubtitleInput}
|
||||||
allowEnterKey={false}
|
allowEnterKey={false}
|
||||||
value={(value) => handleInputChange('subtitle', value || '')}
|
value={(value) => handleInputChange('subtitle', value || '')}
|
||||||
class={styles.subtitleInput}
|
class={styles.subtitleInput}
|
||||||
|
@ -455,7 +457,7 @@ export const EditView = (props: Props) => {
|
||||||
</Show>
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Show when={form?.shoutId} fallback={<Loading />}>
|
<Show when={draft()?.id} fallback={<Loading />}>
|
||||||
<EditorComponent
|
<EditorComponent
|
||||||
shoutId={form.shoutId}
|
shoutId={form.shoutId}
|
||||||
initialContent={form.body}
|
initialContent={form.body}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export const notChar = /[^\dA-Za-zА-Яа-я]/
|
export const notChar = /[^\dA-Za-zА-Яа-я]/g
|
||||||
export const allChar = /[\dA-Za-zА-Яа-я]/
|
export const allChar = /[\dA-Za-zА-Яа-я]/
|
||||||
export const notLatin = /[^A-Za-z]/
|
export const notLatin = /[^A-Za-z]/
|
||||||
export const notRus = /[^ËА-Яа-яё]/
|
export const notRus = /[^ËА-Яа-яё]/
|
||||||
|
|
|
@ -3,10 +3,22 @@ import { capitalize } from '~/utils/capitalize'
|
||||||
import { cyrillicRegex, findFirstReadableCharIndex, notChar, notLatin, notRus } from './chars'
|
import { cyrillicRegex, findFirstReadableCharIndex, notChar, notLatin, notRus } from './chars'
|
||||||
import { translit } from './translit'
|
import { translit } from './translit'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a string contains Cyrillic characters.
|
||||||
|
* @param s - The string to check.
|
||||||
|
* @returns `true` if the string contains Cyrillic characters, otherwise `false`.
|
||||||
|
*/
|
||||||
export const isCyrillic = (s: string): boolean => {
|
export const isCyrillic = (s: string): boolean => {
|
||||||
return cyrillicRegex.test(s)
|
return cyrillicRegex.test(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translates the author's name based on the provided language. For English (`lng === 'en'`), it transliterates
|
||||||
|
* and capitalizes Cyrillic names, handling special cases for characters like 'ё' and 'ь'.
|
||||||
|
* @param author - The author object containing the name to translate.
|
||||||
|
* @param lng - The target language for translation ('en' or 'ru').
|
||||||
|
* @returns The translated author name, or the original if no translation is needed.
|
||||||
|
*/
|
||||||
export const translateAuthor = (author: Author, lng: string) =>
|
export const translateAuthor = (author: Author, lng: string) =>
|
||||||
lng === 'en' && isCyrillic(author?.name || '')
|
lng === 'en' && isCyrillic(author?.name || '')
|
||||||
? capitalize(
|
? capitalize(
|
||||||
|
@ -15,6 +27,15 @@ export const translateAuthor = (author: Author, lng: string) =>
|
||||||
)
|
)
|
||||||
: author.name
|
: author.name
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reduces a list of authors into groups based on the first readable letter of their last name.
|
||||||
|
* The grouping depends on the language ('ru' for Russian and 'en' for English).
|
||||||
|
* Non-Cyrillic or non-Latin characters are grouped under `@`.
|
||||||
|
* @param acc - The accumulator object for grouping authors by the first readable letter.
|
||||||
|
* @param author - The author object containing the name.
|
||||||
|
* @param lng - The language code ('en' or 'ru') used for transliteration and sorting.
|
||||||
|
* @returns The accumulator object with authors grouped by the first readable letter of their last name.
|
||||||
|
*/
|
||||||
export const authorLetterReduce = (acc: { [x: string]: Author[] }, author: Author, lng: string) => {
|
export const authorLetterReduce = (acc: { [x: string]: Author[] }, author: Author, lng: string) => {
|
||||||
let letter = ''
|
let letter = ''
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
import { EditorOptions } from '@tiptap/core'
|
import { EditorOptions } from '@tiptap/core'
|
||||||
|
import Dropcursor from '@tiptap/extension-dropcursor'
|
||||||
|
import Focus from '@tiptap/extension-focus'
|
||||||
|
import Gapcursor from '@tiptap/extension-gapcursor'
|
||||||
|
import HardBreak from '@tiptap/extension-hard-break'
|
||||||
import Highlight from '@tiptap/extension-highlight'
|
import Highlight from '@tiptap/extension-highlight'
|
||||||
|
import HorizontalRule from '@tiptap/extension-horizontal-rule'
|
||||||
import Image from '@tiptap/extension-image'
|
import Image from '@tiptap/extension-image'
|
||||||
import Link from '@tiptap/extension-link'
|
import Link from '@tiptap/extension-link'
|
||||||
import Underline from '@tiptap/extension-underline'
|
import Underline from '@tiptap/extension-underline'
|
||||||
import StarterKit from '@tiptap/starter-kit'
|
import StarterKit from '@tiptap/starter-kit'
|
||||||
|
import ArticleNode from '~/components/Editor/extensions/Article'
|
||||||
import { CustomBlockquote } from '~/components/Editor/extensions/CustomBlockquote'
|
import { CustomBlockquote } from '~/components/Editor/extensions/CustomBlockquote'
|
||||||
import { Figcaption } from '~/components/Editor/extensions/Figcaption'
|
import { Figcaption } from '~/components/Editor/extensions/Figcaption'
|
||||||
import { Figure } from '~/components/Editor/extensions/Figure'
|
import { Figure } from '~/components/Editor/extensions/Figure'
|
||||||
|
@ -53,9 +59,17 @@ export const custom: EditorOptions['extensions'] = [
|
||||||
]
|
]
|
||||||
|
|
||||||
export const extended: EditorOptions['extensions'] = [
|
export const extended: EditorOptions['extensions'] = [
|
||||||
|
HorizontalRule.configure({ HTMLAttributes: { class: 'horizontalRule' } }),
|
||||||
|
Highlight.configure({ multicolor: true, HTMLAttributes: { class: 'highlight' } }),
|
||||||
|
Dropcursor,
|
||||||
|
CustomBlockquote,
|
||||||
|
Span,
|
||||||
|
ToggleTextWrap,
|
||||||
Footnote,
|
Footnote,
|
||||||
CustomBlockquote
|
Focus,
|
||||||
// TODO: Добавьте другие кастомные расширения здесь
|
Gapcursor,
|
||||||
|
HardBreak,
|
||||||
|
ArticleNode
|
||||||
]
|
]
|
||||||
|
|
||||||
/*
|
/*
|
|
@ -1,23 +1,23 @@
|
||||||
// biome-ignore lint/correctness/noNodejsModules: used during build
|
// biome-ignore lint/correctness/noNodejsModules: used during build
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
// import { visualizer } from 'rollup-plugin-visualizer'
|
||||||
|
import dotenv from 'dotenv'
|
||||||
import { CSSOptions } from 'vite'
|
import { CSSOptions } from 'vite'
|
||||||
import mkcert from 'vite-plugin-mkcert'
|
import mkcert from 'vite-plugin-mkcert'
|
||||||
import { PolyfillOptions, nodePolyfills } from 'vite-plugin-node-polyfills'
|
import { PolyfillOptions, nodePolyfills } from 'vite-plugin-node-polyfills'
|
||||||
import sassDts from 'vite-plugin-sass-dts'
|
import sassDts from 'vite-plugin-sass-dts'
|
||||||
// import { visualizer } from 'rollup-plugin-visualizer'
|
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV !== 'production'
|
// Load environment variables from .env file
|
||||||
console.log(`[vite.config] development mode: ${isDev}`)
|
dotenv.config()
|
||||||
|
|
||||||
|
export const isDev = process.env.NODE_ENV !== 'production'
|
||||||
|
console.log(`[vite.config] ${process.env.NODE_ENV} mode`)
|
||||||
|
|
||||||
const polyfillOptions = {
|
const polyfillOptions = {
|
||||||
include: ['path', 'stream', 'util'],
|
include: ['path', 'stream', 'util'],
|
||||||
exclude: ['http'],
|
exclude: ['http'],
|
||||||
globals: {
|
globals: { Buffer: true },
|
||||||
Buffer: true
|
overrides: { fs: 'memfs' },
|
||||||
},
|
|
||||||
overrides: {
|
|
||||||
fs: 'memfs'
|
|
||||||
},
|
|
||||||
protocolImports: true
|
protocolImports: true
|
||||||
} as PolyfillOptions
|
} as PolyfillOptions
|
||||||
|
|
||||||
|
@ -45,12 +45,19 @@ export default {
|
||||||
build: {
|
build: {
|
||||||
target: 'esnext',
|
target: 'esnext',
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
|
minify: 'terser', // explicit terser usage
|
||||||
|
terserOptions: {
|
||||||
|
compress: {
|
||||||
|
drop_console: true // removes console logs in production
|
||||||
|
}
|
||||||
|
},
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
// plugins: [visualizer()]
|
// plugins: [visualizer()]
|
||||||
output: {
|
output: {
|
||||||
manualChunks: {
|
manualChunks: {
|
||||||
icons: ['./src/components/_shared/Icon/Icon.tsx'],
|
icons: ['./src/components/_shared/Icon/Icon.tsx'],
|
||||||
session: ['./src/context/session.tsx'],
|
session: ['./src/context/session.tsx'],
|
||||||
|
localize: ['./src/context/localize.tsx'],
|
||||||
editor: ['./src/context/editor.tsx'],
|
editor: ['./src/context/editor.tsx'],
|
||||||
connect: ['./src/context/connect.tsx']
|
connect: ['./src/context/connect.tsx']
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user