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

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

View File

@@ -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,