editor fixed

This commit is contained in:
Untone 2024-08-01 00:41:15 +03:00
parent e875212ae7
commit a39190e2b1
7 changed files with 519 additions and 632 deletions

1049
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -37,40 +37,40 @@
"@solidjs/meta": "^0.29.4", "@solidjs/meta": "^0.29.4",
"@solidjs/router": "^0.14.1", "@solidjs/router": "^0.14.1",
"@solidjs/start": "^1.0.6", "@solidjs/start": "^1.0.6",
"@tiptap/core": "^2.5.5", "@tiptap/core": "^2.5.8",
"@tiptap/extension-blockquote": "^2.5.5", "@tiptap/extension-blockquote": "^2.5.8",
"@tiptap/extension-bold": "^2.5.5", "@tiptap/extension-bold": "^2.5.8",
"@tiptap/extension-bubble-menu": "^2.5.5", "@tiptap/extension-bubble-menu": "^2.5.8",
"@tiptap/extension-bullet-list": "^2.5.5", "@tiptap/extension-bullet-list": "^2.5.8",
"@tiptap/extension-character-count": "^2.5.5", "@tiptap/extension-character-count": "^2.5.8",
"@tiptap/extension-collaboration": "^2.5.5", "@tiptap/extension-collaboration": "^2.5.8",
"@tiptap/extension-collaboration-cursor": "^2.5.5", "@tiptap/extension-collaboration-cursor": "^2.5.8",
"@tiptap/extension-document": "^2.5.5", "@tiptap/extension-document": "^2.5.8",
"@tiptap/extension-dropcursor": "^2.5.5", "@tiptap/extension-dropcursor": "^2.5.8",
"@tiptap/extension-floating-menu": "^2.5.5", "@tiptap/extension-floating-menu": "^2.5.8",
"@tiptap/extension-focus": "^2.5.5", "@tiptap/extension-focus": "^2.5.8",
"@tiptap/extension-gapcursor": "^2.5.5", "@tiptap/extension-gapcursor": "^2.5.8",
"@tiptap/extension-hard-break": "^2.5.5", "@tiptap/extension-hard-break": "^2.5.8",
"@tiptap/extension-heading": "^2.5.5", "@tiptap/extension-heading": "^2.5.8",
"@tiptap/extension-highlight": "^2.5.5", "@tiptap/extension-highlight": "^2.5.8",
"@tiptap/extension-history": "^2.5.5", "@tiptap/extension-history": "^2.5.8",
"@tiptap/extension-horizontal-rule": "^2.5.5", "@tiptap/extension-horizontal-rule": "^2.5.8",
"@tiptap/extension-image": "^2.5.5", "@tiptap/extension-image": "^2.5.8",
"@tiptap/extension-italic": "^2.5.5", "@tiptap/extension-italic": "^2.5.8",
"@tiptap/extension-link": "^2.5.5", "@tiptap/extension-link": "^2.5.8",
"@tiptap/extension-list-item": "^2.5.5", "@tiptap/extension-list-item": "^2.5.8",
"@tiptap/extension-ordered-list": "^2.5.5", "@tiptap/extension-ordered-list": "^2.5.8",
"@tiptap/extension-paragraph": "^2.5.5", "@tiptap/extension-paragraph": "^2.5.8",
"@tiptap/extension-placeholder": "^2.5.5", "@tiptap/extension-placeholder": "^2.5.8",
"@tiptap/extension-strike": "^2.5.5", "@tiptap/extension-strike": "^2.5.8",
"@tiptap/extension-text": "^2.5.5", "@tiptap/extension-text": "^2.5.8",
"@tiptap/extension-underline": "^2.5.5", "@tiptap/extension-underline": "^2.5.8",
"@tiptap/extension-youtube": "^2.5.5", "@tiptap/extension-youtube": "^2.5.8",
"@types/cookie": "^0.6.0", "@types/cookie": "^0.6.0",
"@types/cookie-signature": "^1.1.2", "@types/cookie-signature": "^1.1.2",
"@types/node": "^20.14.11", "@types/node": "^20.14.13",
"@types/throttle-debounce": "^5.0.2", "@types/throttle-debounce": "^5.0.2",
"@urql/core": "^5.0.4", "@urql/core": "^5.0.5",
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"cookie": "^0.6.0", "cookie": "^0.6.0",
@ -90,16 +90,16 @@
"prosemirror-view": "^1.33.9", "prosemirror-view": "^1.33.9",
"rollup-plugin-visualizer": "^5.12.0", "rollup-plugin-visualizer": "^5.12.0",
"sass": "1.76.0", "sass": "1.76.0",
"solid-js": "^1.8.18", "solid-js": "^1.8.19",
"solid-popper": "^0.3.0", "solid-popper": "^0.3.0",
"solid-tiptap": "0.7.0", "solid-tiptap": "0.7.0",
"solid-transition-group": "^0.2.3", "solid-transition-group": "^0.2.3",
"stylelint": "^16.7.0", "stylelint": "^16.8.1",
"stylelint-config-recommended": "^14.0.1", "stylelint-config-recommended": "^14.0.1",
"stylelint-config-standard-scss": "^13.1.0", "stylelint-config-standard-scss": "^13.1.0",
"stylelint-order": "^6.0.4", "stylelint-order": "^6.0.4",
"stylelint-scss": "^6.4.1", "stylelint-scss": "^6.4.1",
"swiper": "^11.1.5", "swiper": "^11.1.8",
"throttle-debounce": "^5.0.2", "throttle-debounce": "^5.0.2",
"tslib": "^2.6.3", "tslib": "^2.6.3",
"typescript": "^5.5.4", "typescript": "^5.5.4",
@ -108,7 +108,7 @@
"vinxi": "^0.4.1", "vinxi": "^0.4.1",
"vite-plugin-mkcert": "^1.17.5", "vite-plugin-mkcert": "^1.17.5",
"vite-plugin-node-polyfills": "^0.22.0", "vite-plugin-node-polyfills": "^0.22.0",
"vite-plugin-sass-dts": "^1.3.24", "vite-plugin-sass-dts": "^1.3.25",
"y-prosemirror": "1.2.9", "y-prosemirror": "1.2.9",
"yjs": "13.6.18" "yjs": "13.6.18"
}, },

View File

@ -235,9 +235,9 @@ export const EditorComponent = (props: Props) => {
const isEmptyTextBlock = const isEmptyTextBlock =
doc.textBetween(from, to).length === 0 && isTextSelection(selection) doc.textBetween(from, to).length === 0 && isTextSelection(selection)
if (isEmptyTextBlock) { if (isEmptyTextBlock) {
e.chain().focus().removeTextWrap({ class: 'highlight-fake-selection' }).run() e?.chain().focus().removeTextWrap({ class: 'highlight-fake-selection' }).run()
} }
setIsCommonMarkup(e.isActive('figcaption')) setIsCommonMarkup(e?.isActive('figcaption'))
const result = const result =
(view.hasFocus() && (view.hasFocus() &&
!empty && !empty &&

View File

@ -46,7 +46,7 @@ export const EditorFloatingMenu = (props: FloatingMenuProps) => {
// TODO: add support instagram embed (blockquote) // TODO: add support instagram embed (blockquote)
const emb = await embedData(value) const emb = await embedData(value)
props.editor props.editor
.chain() ?.chain()
.focus() .focus()
.insertContent({ .insertContent({
type: 'figure', type: 'figure',
@ -83,7 +83,7 @@ export const EditorFloatingMenu = (props: FloatingMenuProps) => {
return return
} }
case 'horizontal-rule': { case 'horizontal-rule': {
props.editor.chain().focus().setHorizontalRule().run() props.editor?.chain().focus().setHorizontalRule().run()
setSelectedMenuItem() setSelectedMenuItem()
return return
} }

View File

@ -29,13 +29,13 @@ export const InsertLinkForm = (props: Props) => {
) )
const handleClearLinkForm = () => { const handleClearLinkForm = () => {
if (currentUrl()) { if (currentUrl()) {
props.editor.chain().focus().unsetLink().run() props.editor?.chain().focus().unsetLink().run()
} }
} }
const handleLinkFormSubmit = (value: string) => { const handleLinkFormSubmit = (value: string) => {
props.editor props.editor
.chain() ?.chain()
.focus() .focus()
.setLink({ href: checkUrl(value) }) .setLink({ href: checkUrl(value) })
.run() .run()

View File

@ -58,11 +58,11 @@ export const EditSettingsView = (props: Props) => {
() => props.shout, () => props.shout,
(shout) => { (shout) => {
if (shout) { if (shout) {
console.debug(`[EditView] shout is loaded: ${shout}`) // console.debug(`[EditView] shout is loaded: ${shout}`)
setShoutTopics((shout.topics as Topic[]) || []) setShoutTopics((shout.topics as Topic[]) || [])
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(stored)
} else { } else {
if (!shout.slug) { if (!shout.slug) {
@ -113,11 +113,11 @@ export const EditSettingsView = (props: Props) => {
const resp = await client()?.query(getMyShoutQuery, { shout_id: shoutId }) const resp = await client()?.query(getMyShoutQuery, { shout_id: shoutId })
const result = resp?.data?.get_my_shout const result = resp?.data?.get_my_shout
if (result) { if (result) {
console.debug('[EditView] getMyShout result: ', result) // console.debug('[EditView] getMyShout result: ', result)
const { shout: loadedShout, error } = result const { shout: loadedShout, error } = result
setDraft(loadedShout) setDraft(loadedShout)
console.debug('[EditView] loadedShout:', loadedShout) // console.debug('[EditView] loadedShout:', loadedShout)
console.log(error) error && console.log(error)
} }
} }
}, },

View File

@ -92,11 +92,11 @@ export const EditView = (props: Props) => {
() => props.shout, () => props.shout,
(shout) => { (shout) => {
if (shout) { if (shout) {
console.debug(`[EditView] shout is loaded: ${shout}`) // console.debug(`[EditView] shout is loaded: ${shout}`)
setShoutTopics((shout.topics as Topic[]) || []) setShoutTopics((shout.topics as Topic[]) || [])
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(stored)
} else { } else {
if (!shout.slug) { if (!shout.slug) {
@ -147,11 +147,11 @@ export const EditView = (props: Props) => {
const resp = await client()?.query(getMyShoutQuery, { shout_id: shoutId }) const resp = await client()?.query(getMyShoutQuery, { shout_id: shoutId })
const result = resp?.data?.get_my_shout const result = resp?.data?.get_my_shout
if (result) { if (result) {
console.debug('[EditView] getMyShout result: ', result) // console.debug('[EditView] getMyShout result: ', result)
const { shout: loadedShout, error } = result const { shout: loadedShout, error } = result
setDraft(loadedShout) setDraft(loadedShout)
console.debug('[EditView] loadedShout:', loadedShout) // console.debug('[EditView] loadedShout:', loadedShout)
console.log(error) error && console.log(error)
} }
} }
}, },