Skip to content

Commit

Permalink
Update MicpIcon.js and index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar Koster committed Jan 10, 2021
1 parent d9db384 commit e835eb2
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
66 changes: 66 additions & 0 deletions src/extentions/MicpIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
export class MicpIcon {
get name () {
return 'micp_icon';
}

get schema () {
return {
attrs: {
src: {
default: null
}
},
group: 'block',
selectable: false,
parseDOM: [
{
tag: 'micp_icon',
getAttrs: dom => ({
src: dom.getAttribute('src')
})
}
],
toDOM: node => [
'micp_icon',
{
src: node.attrs.src
}
]
};
}

commands ({ type }) {
return attrs => (state, dispatch) => {
const { selection } = state;
const position = selection.$cursor
? selection.$cursor.pos
: selection.$to.pos;
const node = type.create(attrs);
const transaction = state.tr.insert(position, node);
dispatch(transaction);
};
}

get view () {
return {
props: ['node', 'updateAttrs', 'view'],
computed: {
src: {
get () {
return this.node.attrs.src;
},
set (src) {
this.updateAttrs({
src
});
}
}
},
template: `
<div class='micp_tiptap_icon'>
TEST
</div>
`
};
}
}
10 changes: 9 additions & 1 deletion src/extentions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export { default as OPrint } from 'src/extentions/Print'
export { default as OImage } from 'src/extentions/Image'
export { default as OEmbed } from 'src/extentions/Embed'

// MICP
export { default as MicpIcon } from 'src/extension/MicpIcon'

// --------------------------------------------------------------------------------
// Exposed Extension List
// --------------------------------------------------------------------------------
Expand Down Expand Up @@ -80,7 +83,12 @@ export const QuasarTipTapExtensions = [
'OEmbed',
]

export const MicpTipTapExtensions = [
'MicpIcon'
]

export const RecommendedExtensions = [
...TipTapExtensions,
...QuasarTipTapExtensions
...QuasarTipTapExtensions,
...MicpTipTapExtensions
]

0 comments on commit e835eb2

Please sign in to comment.