Merge branch 'master' into v1.0

# Conflicts:
#	examples/Components/Routes/Basic/index.vue
#	examples/Components/Routes/Export/index.vue
#	examples/Components/Routes/MarkdownShortcuts/index.vue
#	examples/Components/Routes/Suggestions/index.vue
This commit is contained in:
Philipp Kühn
2018-11-08 21:41:33 +01:00
12 changed files with 57 additions and 51 deletions

View File

@@ -103,14 +103,14 @@ import { Editor } from 'tiptap'
import { import {
// Nodes // Nodes
BlockquoteNode, BlockquoteNode,
BulletListNode,
CodeBlockNode, CodeBlockNode,
CodeBlockHighlightNode, CodeBlockHighlightNode,
HardBreakNode, HardBreakNode,
HeadingNode, HeadingNode,
ImageNode, ImageNode,
ListItemNode,
OrderedListNode, OrderedListNode,
BulletListNode,
ListItemNode,
TodoItemNode, TodoItemNode,
TodoListNode, TodoListNode,

View File

@@ -133,12 +133,12 @@ import Icon from 'Components/Icon'
import { Editor, EditorContent, MenuBar } from 'tiptap' import { Editor, EditorContent, MenuBar } from 'tiptap'
import { import {
Blockquote, Blockquote,
BulletList,
CodeBlock, CodeBlock,
HardBreak, HardBreak,
Heading, Heading,
ListItem,
OrderedList, OrderedList,
BulletList,
ListItem,
TodoItem, TodoItem,
TodoList, TodoList,
Bold, Bold,

View File

@@ -115,12 +115,12 @@ import Icon from 'Components/Icon'
import { Editor, EditorContent, MenuBar } from 'tiptap' import { Editor, EditorContent, MenuBar } from 'tiptap'
import { import {
Blockquote, Blockquote,
BulletList,
CodeBlock, CodeBlock,
HardBreak, HardBreak,
Heading, Heading,
ListItem,
OrderedList, OrderedList,
BulletList,
ListItem,
TodoItem, TodoItem,
TodoList, TodoList,
Bold, Bold,

View File

@@ -9,12 +9,12 @@ import Icon from 'Components/Icon'
import { Editor, EditorContent } from 'tiptap' import { Editor, EditorContent } from 'tiptap'
import { import {
Blockquote, Blockquote,
BulletList,
CodeBlock, CodeBlock,
HardBreak, HardBreak,
Heading, Heading,
ListItem,
OrderedList, OrderedList,
BulletList,
ListItem,
TodoItem, TodoItem,
TodoList, TodoList,
Bold, Bold,

View File

@@ -52,14 +52,16 @@ export default {
new Heading({ levels: [1, 2, 3] }), new Heading({ levels: [1, 2, 3] }),
new Mention({ new Mention({
// a list of all suggested items // a list of all suggested items
items: [ items: () => [
{ id: 1, name: 'Philipp Kühn' }, { id: 1, name: 'Philipp Kühn' },
{ id: 2, name: 'Hans Pagel' }, { id: 2, name: 'Hans Pagel' },
{ id: 3, name: 'Kris Siepert' }, { id: 3, name: 'Kris Siepert' },
{ id: 4, name: 'Justin Schueler' }, { id: 4, name: 'Justin Schueler' },
], ],
// is called when a suggestion starts // is called when a suggestion starts
onEnter: ({ items, query, range, command, virtualNode }) => { onEnter: ({
items, query, range, command, virtualNode,
}) => {
this.query = query this.query = query
this.filteredUsers = items this.filteredUsers = items
this.suggestionRange = range this.suggestionRange = range
@@ -70,7 +72,9 @@ export default {
this.insertMention = command this.insertMention = command
}, },
// is called when a suggestion has changed // is called when a suggestion has changed
onChange: ({ items, query, range, virtualNode }) => { onChange: ({
items, query, range, virtualNode,
}) => {
this.query = query this.query = query
this.filteredUsers = items this.filteredUsers = items
this.suggestionRange = range this.suggestionRange = range

View File

@@ -1,6 +1,6 @@
{ {
"name": "tiptap", "name": "tiptap",
"version": "0.20.0", "version": "0.20.1",
"description": "A rich-text editor for Vue.js", "description": "A rich-text editor for Vue.js",
"homepage": "https://tiptap.scrumpy.io", "homepage": "https://tiptap.scrumpy.io",
"license": "MIT", "license": "MIT",
@@ -27,8 +27,8 @@
"prosemirror-model": "^1.6.2", "prosemirror-model": "^1.6.2",
"prosemirror-state": "^1.2.1", "prosemirror-state": "^1.2.1",
"prosemirror-view": "^1.6.1", "prosemirror-view": "^1.6.1",
"tiptap-commands": "^0.7.0", "tiptap-commands": "^0.7.1",
"tiptap-utils": "^0.4.0" "tiptap-utils": "^0.4.1"
}, },
"peerDependencies": { "peerDependencies": {
"vue": "^2.5.17", "vue": "^2.5.17",

View File

@@ -1,6 +1,6 @@
{ {
"name": "tiptap-commands", "name": "tiptap-commands",
"version": "0.7.0", "version": "0.7.1",
"description": "Commands for tiptap", "description": "Commands for tiptap",
"homepage": "https://tiptap.scrumpy.io", "homepage": "https://tiptap.scrumpy.io",
"license": "MIT", "license": "MIT",
@@ -23,6 +23,6 @@
"prosemirror-commands": "^1.0.7", "prosemirror-commands": "^1.0.7",
"prosemirror-inputrules": "^1.0.1", "prosemirror-inputrules": "^1.0.1",
"prosemirror-schema-list": "^1.0.1", "prosemirror-schema-list": "^1.0.1",
"tiptap-utils": "^0.4.0" "tiptap-utils": "^0.4.1"
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "tiptap-extensions", "name": "tiptap-extensions",
"version": "0.22.0", "version": "0.23.0",
"description": "Extensions for tiptap", "description": "Extensions for tiptap",
"homepage": "https://tiptap.scrumpy.io", "homepage": "https://tiptap.scrumpy.io",
"license": "MIT", "license": "MIT",
@@ -25,8 +25,8 @@
"prosemirror-history": "^1.0.2", "prosemirror-history": "^1.0.2",
"prosemirror-state": "^1.2.2", "prosemirror-state": "^1.2.2",
"prosemirror-view": "^1.6.1", "prosemirror-view": "^1.6.1",
"tiptap": "^0.20.0", "tiptap": "^0.20.1",
"tiptap-commands": "^0.7.0" "tiptap-commands": "^0.7.1"
}, },
"peerDependencies": { "peerDependencies": {
"vue": "^2.5.17", "vue": "^2.5.17",

View File

@@ -10,7 +10,6 @@ export default class ListItem extends Node {
get schema() { get schema() {
return { return {
content: 'paragraph block*', content: 'paragraph block*',
group: 'block',
defining: true, defining: true,
draggable: false, draggable: false,
parseDOM: [ parseDOM: [

View File

@@ -28,6 +28,7 @@ function triggerCharacter({
// JavaScript doesn't have lookbehinds; this hacks a check that first character is " " // JavaScript doesn't have lookbehinds; this hacks a check that first character is " "
// or the line beginning // or the line beginning
const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index) const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index)
if (/^[\s\0]?$/.test(matchPrefix)) { if (/^[\s\0]?$/.test(matchPrefix)) {
// The absolute position of the match in the document // The absolute position of the match in the document
const from = match.index + $position.start() const from = match.index + $position.start()
@@ -52,8 +53,10 @@ function triggerCharacter({
} }
} }
} }
match = regexp.exec(text) match = regexp.exec(text)
} }
return position return position
} }
} }
@@ -124,7 +127,7 @@ export default function SuggestionsPlugin({
text: state.text, text: state.text,
decorationNode, decorationNode,
virtualNode, virtualNode,
items: onFilter(items, state.query), items: onFilter(Array.isArray(items) ? items : items(), state.query),
command: ({ range, attrs }) => { command: ({ range, attrs }) => {
command({ command({
range, range,

View File

@@ -1,6 +1,6 @@
{ {
"name": "tiptap-utils", "name": "tiptap-utils",
"version": "0.4.0", "version": "0.4.1",
"description": "Utility functions for tiptap", "description": "Utility functions for tiptap",
"homepage": "https://tiptap.scrumpy.io", "homepage": "https://tiptap.scrumpy.io",
"license": "MIT", "license": "MIT",

View File

@@ -1,10 +1,10 @@
import { findParentNode } from 'prosemirror-utils' import { findParentNode } from 'prosemirror-utils'
export default function (state, type, attrs) { export default function (state, type, attrs = {}) {
const predicate = node => node.type === type const predicate = node => node.type === type
const parent = findParentNode(predicate)(state.selection) const parent = findParentNode(predicate)(state.selection)
if (attrs === {} || !parent) { if (!Object.keys(attrs).length || !parent) {
return !!parent return !!parent
} }