Skip to content
Snippets Groups Projects
Commit c07966cf authored by chris's avatar chris
Browse files

add image id

parent 1339f5f5
No related branches found
No related tags found
1 merge request!413Image alt text
...@@ -2,6 +2,7 @@ import { SchemaHelpers } from 'wax-prosemirror-utilities'; ...@@ -2,6 +2,7 @@ import { SchemaHelpers } from 'wax-prosemirror-utilities';
const image = { const image = {
attrs: { attrs: {
id: { default: '' },
src: {}, src: {},
alt: { default: null }, alt: { default: null },
title: { default: null }, title: { default: null },
......
...@@ -18,6 +18,7 @@ export default ({ setPosition, position }) => { ...@@ -18,6 +18,7 @@ export default ({ setPosition, position }) => {
useLayoutEffect(() => { useLayoutEffect(() => {
const WaxSurface = activeView.dom.getBoundingClientRect(); const WaxSurface = activeView.dom.getBoundingClientRect();
console.log(activeView.state.selection);
const left = 300; const left = 300;
const top = 500; const top = 500;
setPosition({ ...position, left, top }); setPosition({ ...position, left, top });
......
import { v4 as uuidv4 } from 'uuid';
const findPlaceholder = (state, id, placeholderPlugin) => { const findPlaceholder = (state, id, placeholderPlugin) => {
const decos = placeholderPlugin.getState(state); const decos = placeholderPlugin.getState(state);
const found = decos.find(null, null, spec => spec.id === id); const found = decos.find(null, null, spec => spec.id === id);
...@@ -39,6 +41,7 @@ export default (view, fileUpload, placeholderPlugin) => file => { ...@@ -39,6 +41,7 @@ export default (view, fileUpload, placeholderPlugin) => file => {
// }), // }),
view.state.schema.nodes.image.create({ view.state.schema.nodes.image.create({
src: url, src: url,
id: uuidv4(),
}), }),
) )
.setMeta(placeholderPlugin, { remove: { id } }), .setMeta(placeholderPlugin, { remove: { id } }),
......
...@@ -30,4 +30,5 @@ figcaption:focus { ...@@ -30,4 +30,5 @@ figcaption:focus {
figcaption:before { figcaption:before {
content: 'Caption: '; content: 'Caption: ';
font-weight: bold; font-weight: bold;
} }
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment