Skip to content

Commit

Permalink
Merge pull request #2468 from zetkin/undocumented/zui-editor-paste
Browse files Browse the repository at this point in the history
ZUI editor pasting prototype
  • Loading branch information
richardolsson authored Jan 17, 2025
2 parents 769e187 + c440e0a commit 26d63ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/zui/ZUIEditor/extensions/ImageExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export default class ImageExtension extends NodeExtension<ImageOptions> {
parseDOM: [
{
getAttrs: (element) => {
return extra.parse(element);
return {
...extra.parse(element),
src: element.getAttribute('src'),
};
},
tag: 'img',
},
Expand Down
7 changes: 6 additions & 1 deletion src/zui/ZUIEditor/extensions/LinkExtension.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ class LinkExtension extends MarkExtension<LinkOptions> {
},
parseDOM: [
{
getAttrs: extra.parse,
getAttrs: (node) => {
return {
...extra.parse(node),
href: node.getAttribute('href'),
};
},
tag: 'a',
//Sätt href-propertyn till värdet href från options
} as TagParseRule,
Expand Down
2 changes: 2 additions & 0 deletions src/zui/ZUIEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@remirror/react';
import { FC } from 'react';
import { BoldExtension, HeadingExtension } from 'remirror/extensions';
import { PasteRulesExtension } from 'remirror';
import { Box } from '@mui/material';

import LinkExtension from './extensions/LinkExtension';
Expand Down Expand Up @@ -66,6 +67,7 @@ const ZUIEditor: FC<Props> = ({ enableButton, enableHeading, enableImage }) => {
type: 'doc',
},
extensions: () => [
new PasteRulesExtension({}),
new BoldExtension({}),
...extensions,
new LinkExtension(),
Expand Down

0 comments on commit 26d63ab

Please sign in to comment.