diff --git a/lib/package-lock.json b/lib/package-lock.json index 050e8dfa..19fadfc4 100644 --- a/lib/package-lock.json +++ b/lib/package-lock.json @@ -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", diff --git a/lib/package.json b/lib/package.json index 6ad1c485..e971aa3c 100644 --- a/lib/package.json +++ b/lib/package.json @@ -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", diff --git a/lib/src/Components/Input/RichTextEditor/Extensions/CustomImage.ts b/lib/src/Components/Input/RichTextEditor/Extensions/CustomImage.ts index 0dbc0cfd..a48609b3 100644 --- a/lib/src/Components/Input/RichTextEditor/Extensions/CustomImage.ts +++ b/lib/src/Components/Input/RichTextEditor/Extensions/CustomImage.ts @@ -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 + 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 } : {} + }, }, } }, diff --git a/lib/src/Components/Input/RichTextEditor/Extensions/MentionList.tsx b/lib/src/Components/Input/RichTextEditor/Extensions/MentionList.tsx index 1329eb75..80bb55c0 100644 --- a/lib/src/Components/Input/RichTextEditor/Extensions/MentionList.tsx +++ b/lib/src/Components/Input/RichTextEditor/Extensions/MentionList.tsx @@ -16,6 +16,7 @@ export const MentionList = forwardRef(funct const [selectedIndex, setSelectedIndex] = useState(0) const selectItem = (index: number) => { + // eslint-disable-next-line security/detect-object-injection const item = items[index] if (item) { command({ id: item }) diff --git a/lib/src/Components/Input/RichTextEditor/RichTextEditor.tsx b/lib/src/Components/Input/RichTextEditor/RichTextEditor.tsx index 44fa1096..e2fdbd09 100644 --- a/lib/src/Components/Input/RichTextEditor/RichTextEditor.tsx +++ b/lib/src/Components/Input/RichTextEditor/RichTextEditor.tsx @@ -71,7 +71,6 @@ export function RichTextEditor({ const handleChange = () => { if (updateFormValue) { if (editor) { - console.log(getStyledMarkdown(editor)) updateFormValue(getStyledMarkdown(editor)) } }