diff --git a/README.md b/README.md index d5f7b25b..1e1fd439 100644 --- a/README.md +++ b/README.md @@ -103,14 +103,14 @@ import { Editor } from 'tiptap' import { // Nodes BlockquoteNode, - BulletListNode, CodeBlockNode, CodeBlockHighlightNode, HardBreakNode, HeadingNode, ImageNode, - ListItemNode, OrderedListNode, + BulletListNode, + ListItemNode, TodoItemNode, TodoListNode, diff --git a/examples/Components/Routes/Basic/index.vue b/examples/Components/Routes/Basic/index.vue index 4e9b6899..6f0d9fb0 100644 --- a/examples/Components/Routes/Basic/index.vue +++ b/examples/Components/Routes/Basic/index.vue @@ -133,12 +133,12 @@ import Icon from 'Components/Icon' import { Editor, EditorContent, MenuBar } from 'tiptap' import { Blockquote, - BulletList, CodeBlock, HardBreak, Heading, - ListItem, OrderedList, + BulletList, + ListItem, TodoItem, TodoList, Bold, diff --git a/examples/Components/Routes/Export/index.vue b/examples/Components/Routes/Export/index.vue index 132b1aef..f14238f0 100644 --- a/examples/Components/Routes/Export/index.vue +++ b/examples/Components/Routes/Export/index.vue @@ -115,12 +115,12 @@ import Icon from 'Components/Icon' import { Editor, EditorContent, MenuBar } from 'tiptap' import { Blockquote, - BulletList, CodeBlock, HardBreak, Heading, - ListItem, OrderedList, + BulletList, + ListItem, TodoItem, TodoList, Bold, diff --git a/examples/Components/Routes/MarkdownShortcuts/index.vue b/examples/Components/Routes/MarkdownShortcuts/index.vue index e379ed1b..09d1f4fc 100644 --- a/examples/Components/Routes/MarkdownShortcuts/index.vue +++ b/examples/Components/Routes/MarkdownShortcuts/index.vue @@ -9,12 +9,12 @@ import Icon from 'Components/Icon' import { Editor, EditorContent } from 'tiptap' import { Blockquote, - BulletList, CodeBlock, HardBreak, Heading, - ListItem, OrderedList, + BulletList, + ListItem, TodoItem, TodoList, Bold, diff --git a/examples/Components/Routes/Suggestions/index.vue b/examples/Components/Routes/Suggestions/index.vue index ed2993e8..d5e4101c 100644 --- a/examples/Components/Routes/Suggestions/index.vue +++ b/examples/Components/Routes/Suggestions/index.vue @@ -52,14 +52,16 @@ export default { new Heading({ levels: [1, 2, 3] }), new Mention({ // a list of all suggested items - items: [ + items: () => [ { id: 1, name: 'Philipp Kühn' }, { id: 2, name: 'Hans Pagel' }, { id: 3, name: 'Kris Siepert' }, { id: 4, name: 'Justin Schueler' }, ], // is called when a suggestion starts - onEnter: ({ items, query, range, command, virtualNode }) => { + onEnter: ({ + items, query, range, command, virtualNode, + }) => { this.query = query this.filteredUsers = items this.suggestionRange = range @@ -70,7 +72,9 @@ export default { this.insertMention = command }, // is called when a suggestion has changed - onChange: ({ items, query, range, virtualNode }) => { + onChange: ({ + items, query, range, virtualNode, + }) => { this.query = query this.filteredUsers = items this.suggestionRange = range diff --git a/packages/_legacy-tiptap/package.json b/packages/_legacy-tiptap/package.json index 8731a3e5..0d60fa31 100644 --- a/packages/_legacy-tiptap/package.json +++ b/packages/_legacy-tiptap/package.json @@ -1,6 +1,6 @@ { "name": "tiptap", - "version": "0.20.0", + "version": "0.20.1", "description": "A rich-text editor for Vue.js", "homepage": "https://tiptap.scrumpy.io", "license": "MIT", @@ -27,8 +27,8 @@ "prosemirror-model": "^1.6.2", "prosemirror-state": "^1.2.1", "prosemirror-view": "^1.6.1", - "tiptap-commands": "^0.7.0", - "tiptap-utils": "^0.4.0" + "tiptap-commands": "^0.7.1", + "tiptap-utils": "^0.4.1" }, "peerDependencies": { "vue": "^2.5.17", diff --git a/packages/tiptap-commands/package.json b/packages/tiptap-commands/package.json index d2cb39b8..08823c8e 100644 --- a/packages/tiptap-commands/package.json +++ b/packages/tiptap-commands/package.json @@ -1,6 +1,6 @@ { "name": "tiptap-commands", - "version": "0.7.0", + "version": "0.7.1", "description": "Commands for tiptap", "homepage": "https://tiptap.scrumpy.io", "license": "MIT", @@ -23,6 +23,6 @@ "prosemirror-commands": "^1.0.7", "prosemirror-inputrules": "^1.0.1", "prosemirror-schema-list": "^1.0.1", - "tiptap-utils": "^0.4.0" + "tiptap-utils": "^0.4.1" } } diff --git a/packages/tiptap-extensions/package.json b/packages/tiptap-extensions/package.json index b1e13b49..a6d07a7f 100644 --- a/packages/tiptap-extensions/package.json +++ b/packages/tiptap-extensions/package.json @@ -1,6 +1,6 @@ { "name": "tiptap-extensions", - "version": "0.22.0", + "version": "0.23.0", "description": "Extensions for tiptap", "homepage": "https://tiptap.scrumpy.io", "license": "MIT", @@ -25,8 +25,8 @@ "prosemirror-history": "^1.0.2", "prosemirror-state": "^1.2.2", "prosemirror-view": "^1.6.1", - "tiptap": "^0.20.0", - "tiptap-commands": "^0.7.0" + "tiptap": "^0.20.1", + "tiptap-commands": "^0.7.1" }, "peerDependencies": { "vue": "^2.5.17", diff --git a/packages/tiptap-extensions/src/nodes/ListItem.js b/packages/tiptap-extensions/src/nodes/ListItem.js index 6f1dc9c3..bcbfb01b 100644 --- a/packages/tiptap-extensions/src/nodes/ListItem.js +++ b/packages/tiptap-extensions/src/nodes/ListItem.js @@ -10,7 +10,6 @@ export default class ListItem extends Node { get schema() { return { content: 'paragraph block*', - group: 'block', defining: true, draggable: false, parseDOM: [ diff --git a/packages/tiptap-extensions/src/plugins/Suggestions.js b/packages/tiptap-extensions/src/plugins/Suggestions.js index cb697b7c..b6a48e65 100644 --- a/packages/tiptap-extensions/src/plugins/Suggestions.js +++ b/packages/tiptap-extensions/src/plugins/Suggestions.js @@ -22,39 +22,42 @@ function triggerCharacter({ const textTo = $position.end() const text = $position.doc.textBetween(textFrom, textTo, '\0', '\0') - let match = regexp.exec(text) - let position + let match = regexp.exec(text) + let position while (match !== null) { - // JavaScript doesn't have lookbehinds; this hacks a check that first character is " " - // or the line beginning + // JavaScript doesn't have lookbehinds; this hacks a check that first character is " " + // or the line beginning const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index) + if (/^[\s\0]?$/.test(matchPrefix)) { - // The absolute position of the match in the document - const from = match.index + $position.start() - let to = from + match[0].length + // The absolute position of the match in the document + const from = match.index + $position.start() + let to = from + match[0].length - // Edge case handling; if spaces are allowed and we're directly in between - // two triggers - if (allowSpaces && suffix.test(text.slice(to - 1, to + 1))) { - match[0] += ' ' - to += 1 - } + // Edge case handling; if spaces are allowed and we're directly in between + // two triggers + if (allowSpaces && suffix.test(text.slice(to - 1, to + 1))) { + match[0] += ' ' + to += 1 + } - // If the $position is located within the matched substring, return that range - if (from < $position.pos && to >= $position.pos) { - position = { - range: { - from, - to, - }, - query: match[0].slice(char.length), - text: match[0], - } - } + // If the $position is located within the matched substring, return that range + if (from < $position.pos && to >= $position.pos) { + position = { + range: { + from, + to, + }, + query: match[0].slice(char.length), + text: match[0], + } + } } - match = regexp.exec(text) - } - return position + + match = regexp.exec(text) + } + + return position } } @@ -124,7 +127,7 @@ export default function SuggestionsPlugin({ text: state.text, decorationNode, virtualNode, - items: onFilter(items, state.query), + items: onFilter(Array.isArray(items) ? items : items(), state.query), command: ({ range, attrs }) => { command({ range, diff --git a/packages/tiptap-utils/package.json b/packages/tiptap-utils/package.json index 5893991e..f6f16df4 100644 --- a/packages/tiptap-utils/package.json +++ b/packages/tiptap-utils/package.json @@ -1,6 +1,6 @@ { "name": "tiptap-utils", - "version": "0.4.0", + "version": "0.4.1", "description": "Utility functions for tiptap", "homepage": "https://tiptap.scrumpy.io", "license": "MIT", diff --git a/packages/tiptap-utils/src/utils/nodeIsActive.js b/packages/tiptap-utils/src/utils/nodeIsActive.js index 1ebcdd40..a7d5c8d5 100644 --- a/packages/tiptap-utils/src/utils/nodeIsActive.js +++ b/packages/tiptap-utils/src/utils/nodeIsActive.js @@ -1,10 +1,10 @@ import { findParentNode } from 'prosemirror-utils' -export default function (state, type, attrs) { +export default function (state, type, attrs = {}) { const predicate = node => node.type === type const parent = findParentNode(predicate)(state.selection) - if (attrs === {} || !parent) { + if (!Object.keys(attrs).length || !parent) { return !!parent }