pass extension option to plugin

This commit is contained in:
Philipp Kühn
2018-09-05 22:09:18 +02:00
parent 82c956dfe9
commit 20a7a490e9
3 changed files with 31 additions and 26 deletions

View File

@@ -169,15 +169,6 @@
} }
} }
.mention {
background: rgba($color-black, 0.1);
color: rgba($color-black, 0.6);
font-size: 0.8rem;
font-weight: bold;
border-radius: 5px;
padding: 0.2rem 0.5rem;
}
ul[data-type="todo_list"] { ul[data-type="todo_list"] {
padding-left: 0; padding-left: 0;
} }

View File

@@ -50,7 +50,17 @@ export default {
new HardBreakNode(), new HardBreakNode(),
new HeadingNode({ maxLevel: 3 }), new HeadingNode({ maxLevel: 3 }),
new ListItemNode(), new ListItemNode(),
new MentionNode(), new MentionNode({
onEnter(args) {
console.log('start', args);
},
onChange(args) {
console.log('change', args);
},
onExit(args) {
console.log('stop', args);
},
}),
new OrderedListNode(), new OrderedListNode(),
new TodoItemNode(), new TodoItemNode(),
new TodoListNode(), new TodoListNode(),
@@ -64,3 +74,16 @@ export default {
}, },
} }
</script> </script>
<style lang="scss">
@import "~variables";
.mention {
background: rgba($color-black, 0.1);
color: rgba($color-black, 0.6);
font-size: 0.8rem;
font-weight: bold;
border-radius: 5px;
padding: 0.2rem 0.5rem;
}
</style>

View File

@@ -1,10 +1,10 @@
import { Node } from 'tiptap' import { Node } from 'tiptap'
import { triggerCharacter, suggestionsPlugin } from '../plugins/suggestions' import { triggerCharacter, suggestionsPlugin } from '../plugins/suggestions'
export default class BlockquoteNode extends Node { export default class MentionNode extends Node {
get name() { get name() {
return 'blockquote' return 'mention'
} }
get schema() { get schema() {
@@ -49,19 +49,10 @@ export default class BlockquoteNode extends Node {
allowSpaces: true, allowSpaces: true,
startOfLine: false, startOfLine: false,
}), }),
onEnter(args) { onEnter: this.options.onEnter,
console.log('start', args); onChange: this.options.onChange,
}, onExit: this.options.onExit,
onChange(args) { onKeyDown: this.options.onKeyDown,
console.log('change', args);
},
onExit(args) {
console.log('stop', args);
},
onKeyDown({ view, event }) {
// console.log(event.key);
return false;
},
}), }),
] ]
} }