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

image customAttrs

parent e786663e
No related branches found
No related tags found
1 merge request!426Questions ToolGroup
......@@ -170,7 +170,7 @@ const Hhmi = () => {
value={content}
readonly={readOnly}
layout={HhmiLayout}
// onChange={source => console.log(source)}
onChange={source => console.log(source)}
/>
</>
);
......
......@@ -6,9 +6,8 @@ const findPlaceholder = (state, id, placeholderPlugin) => {
return found.length ? found[0].from : null;
};
export default (view, fileUpload, placeholderPlugin) => file => {
export default (view, fileUpload, placeholderPlugin) => (file, customAttrs) => {
const { state } = view;
// A fresh object to act as the ID for this upload
const id = {};
......@@ -36,12 +35,10 @@ export default (view, fileUpload, placeholderPlugin) => file => {
.replaceWith(
pos,
pos,
// view.state.schema.nodes.image.create({
// src: url,
// }),
view.state.schema.nodes.image.create({
src: url,
id: uuidv4(),
customAttrs,
}),
)
.setMeta(placeholderPlugin, { remove: { id } }),
......
// import { SchemaHelpers } from 'wax-prosemirror-core';
import { isEmpty } from 'lodash';
const imageNode = {
attrs: {
id: { default: '' },
src: {},
alt: { default: '' },
title: { default: null },
customAttrs: { default: {} },
// track: { default: [] },
fileid: { default: null },
},
......@@ -29,7 +30,6 @@ const imageNode = {
],
toDOM(hook, next) {
const attrs = {};
if (hook.node.attrs.track && hook.node.attrs.track.length) {
// attrs['data-track'] = JSON.stringify(hook.node.attrs.track);
attrs['data-id'] = hook.node.attrs.id;
......@@ -49,6 +49,16 @@ const imageNode = {
'data-fileid': fileid,
},
];
if (
hook.node.attrs.customAttrs.customAttrs &&
!isEmpty(hook.node.attrs.customAttrs.customAttrs)
) {
const { customAttrs } = hook.node.attrs.customAttrs;
Object.assign(hook.value[1], { ...customAttrs });
}
next();
},
};
......
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