diff --git a/examples/Components/Routes/Images/index.vue b/examples/Components/Routes/Images/index.vue index 58300586..648d735c 100644 --- a/examples/Components/Routes/Images/index.vue +++ b/examples/Components/Routes/Images/index.vue @@ -2,6 +2,19 @@
+ +

Images @@ -17,6 +30,7 @@ \ No newline at end of file diff --git a/examples/assets/images/icons/image.svg b/examples/assets/images/icons/image.svg new file mode 100644 index 00000000..8e1a8f4f --- /dev/null +++ b/examples/assets/images/icons/image.svg @@ -0,0 +1 @@ +paginate-filter-picture-alternate \ No newline at end of file diff --git a/packages/tiptap-extensions/src/nodes/Image.js b/packages/tiptap-extensions/src/nodes/Image.js index e01fcb53..59bf4fed 100644 --- a/packages/tiptap-extensions/src/nodes/Image.js +++ b/packages/tiptap-extensions/src/nodes/Image.js @@ -34,6 +34,16 @@ export default class ImageNode extends Node { } } + command({ type, attrs }) { + return (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 plugins() { return [ new Plugin({