This commit is contained in:
Anton Tranelis 2025-06-28 08:49:17 +02:00
parent 49a2e9a6bf
commit f3406d50c0
5 changed files with 29 additions and 10 deletions

1
lib/package-lock.json generated
View File

@ -39,6 +39,7 @@
"html-truncate": "^1.2.2",
"leaflet": "^1.9.4",
"leaflet.locatecontrol": "^0.79.0",
"mdast-util-to-string": "^4.0.0",
"prosemirror-markdown": "^1.13.2",
"prosemirror-state": "^1.4.3",
"radash": "^12.1.0",

View File

@ -127,6 +127,7 @@
"html-truncate": "^1.2.2",
"leaflet": "^1.9.4",
"leaflet.locatecontrol": "^0.79.0",
"mdast-util-to-string": "^4.0.0",
"prosemirror-markdown": "^1.13.2",
"prosemirror-state": "^1.4.3",
"radash": "^12.1.0",

View File

@ -1,28 +1,45 @@
import { Image } from '@tiptap/extension-image'
import type { Attribute } from '@tiptap/core'
export const CustomImage = Image.extend({
addAttributes() {
const parentAttrs = (this.parent?.() ?? {}) as Record<string, Attribute>
return {
...this.parent?.(),
...parentAttrs,
style: {
default: null,
parseHTML: (element) => element.getAttribute('style'),
renderHTML: (attributes) => {
if (!attributes.style) {
parseHTML: (element: Element): string | null => {
return element.getAttribute('style')
},
renderHTML: (attrs: { style: string | null }) => {
if (!attrs.style) {
return {}
}
return { style: attributes.style }
return { style: attrs.style }
},
},
width: {
default: null,
parseHTML: (element) => element.getAttribute('width'),
renderHTML: (attrs) => (attrs.width ? { width: attrs.width } : {}),
parseHTML: (element: Element): string | null => {
return element.getAttribute('width')
},
renderHTML: (attrs: { width: string | null }) => {
return attrs.width ? { width: attrs.width } : {}
},
},
height: {
default: null,
parseHTML: (element) => element.getAttribute('height'),
renderHTML: (attrs) => (attrs.height ? { height: attrs.height } : {}),
parseHTML: (element: Element): string | null => {
return element.getAttribute('height')
},
renderHTML: (attrs: { height: string | null }) => {
return attrs.height ? { height: attrs.height } : {}
},
},
}
},

View File

@ -16,6 +16,7 @@ export const MentionList = forwardRef<MentionListHandle, MentionListProps>(funct
const [selectedIndex, setSelectedIndex] = useState<number>(0)
const selectItem = (index: number) => {
// eslint-disable-next-line security/detect-object-injection
const item = items[index]
if (item) {
command({ id: item })

View File

@ -71,7 +71,6 @@ export function RichTextEditor({
const handleChange = () => {
if (updateFormValue) {
if (editor) {
console.log(getStyledMarkdown(editor))
updateFormValue(getStyledMarkdown(editor))
}
}