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

block importer

parent 266e3cff
No related branches found
No related tags found
1 merge request!240Inline custom tags
...@@ -62,7 +62,10 @@ const Editoria = () => { ...@@ -62,7 +62,10 @@ const Editoria = () => {
autoFocus autoFocus
placeholder="Type Something..." placeholder="Type Something..."
fileUpload={file => renderImage(file)} fileUpload={file => renderImage(file)}
value={demo} value={
'<p>hello</p><p class="custom-tag-label-3" data-type="block">Lorem ipsum dolor si</p>'
}
// value={demo}
// readonly // readonly
layout={layout} layout={layout}
// onChange={source => console.log(source)} // onChange={source => console.log(source)}
......
...@@ -412,19 +412,19 @@ export default css` ...@@ -412,19 +412,19 @@ export default css`
font-weight: 600; font-weight: 600;
} }
custom-tag-block { p[data-type='block'] {
display: block; display: block;
margin-top: 1em; margin-top: 1em;
} }
custom-tag-block:before { p[data-type='block']:before {
color: #006f19; color: #006f19;
content: '|'; content: '|';
display: inline; display: inline;
font-weight: 600; font-weight: 600;
} }
custom-tag-block:after { p[data-type='block']:after {
color: #006f19; color: #006f19;
content: '|'; content: '|';
display: inline; display: inline;
......
...@@ -5,21 +5,27 @@ const customBlockNode = { ...@@ -5,21 +5,27 @@ const customBlockNode = {
defining: true, defining: true,
attrs: { attrs: {
class: { default: '' }, class: { default: '' },
type: { default: 'block' },
}, },
parseDOM: [ parseDOM: [
{ {
tag: 'custom-tag-block', tag: 'p[data-type="block"]',
getAttrs(hook, next) { getAttrs(hook, next) {
Object.assign(hook, { Object.assign(hook, {
class: hook.dom.getAttribute('class'), class: hook.dom.getAttribute('class'),
type: hook.dom.dataset.type,
}); });
next(); next();
}, },
}, },
], ],
toDOM(hook, next) { toDOM(hook, next) {
const attrs = { class: hook.attrs.class }; const attrs = {
return (hook.value = ['custom-tag-block', attrs, 0]); class: hook.node.attrs.class,
'data-type': hook.node.attrs.type,
};
hook.value = ['p', attrs, 0];
next();
}, },
}; };
......
...@@ -6,9 +6,12 @@ class CustomTagBlockService extends Service { ...@@ -6,9 +6,12 @@ class CustomTagBlockService extends Service {
register() { register() {
this.container.bind('CustomTagBlockTool').to(CustomTagBlockTool); this.container.bind('CustomTagBlockTool').to(CustomTagBlockTool);
const createNode = this.container.get('CreateNode'); const createNode = this.container.get('CreateNode');
createNode({ createNode(
customTagBlock: customBlockNode, {
}); customTagBlock: customBlockNode,
},
{ toWaxSchema: true },
);
} }
} }
......
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