remove some comments
This commit is contained in:
@@ -1,22 +1,13 @@
|
|||||||
import { Plugin, PluginKey } from 'prosemirror-state';
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
||||||
import { Decoration, DecorationSet } from 'prosemirror-view';
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
||||||
|
|
||||||
/**
|
// Create a matcher that matches when a specific character is typed. Useful for @mentions and #tags.
|
||||||
* Create a matcher that matches when a specific character is typed. Useful for @mentions and #tags.
|
|
||||||
*
|
|
||||||
* @param {String} char
|
|
||||||
* @param {Boolean} allowSpaces
|
|
||||||
* @returns {function(*)}
|
|
||||||
*/
|
|
||||||
function triggerCharacter({
|
function triggerCharacter({
|
||||||
char = '@',
|
char = '@',
|
||||||
allowSpaces = false,
|
allowSpaces = false,
|
||||||
startOfLine = false,
|
startOfLine = false,
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ResolvedPos} $position
|
|
||||||
*/
|
|
||||||
return $position => {
|
return $position => {
|
||||||
// Matching expressions used for later
|
// Matching expressions used for later
|
||||||
const suffix = new RegExp(`\\s${char}$`)
|
const suffix = new RegExp(`\\s${char}$`)
|
||||||
@@ -64,9 +55,6 @@ function triggerCharacter({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns {Plugin}
|
|
||||||
*/
|
|
||||||
export default function SuggestionsPlugin({
|
export default function SuggestionsPlugin({
|
||||||
matcher = {
|
matcher = {
|
||||||
char: '@',
|
char: '@',
|
||||||
@@ -159,11 +147,8 @@ export default function SuggestionsPlugin({
|
|||||||
},
|
},
|
||||||
|
|
||||||
state: {
|
state: {
|
||||||
/**
|
|
||||||
* Initialize the plugin's internal state.
|
// Initialize the plugin's internal state.
|
||||||
*
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
init() {
|
init() {
|
||||||
return {
|
return {
|
||||||
active: false,
|
active: false,
|
||||||
@@ -173,14 +158,7 @@ export default function SuggestionsPlugin({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
// Apply changes to the plugin state from a view transaction.
|
||||||
* Apply changes to the plugin state from a view transaction.
|
|
||||||
*
|
|
||||||
* @param {Transaction} tr
|
|
||||||
* @param {Object} prev
|
|
||||||
*
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
apply(tr, prev) {
|
apply(tr, prev) {
|
||||||
const { selection } = tr
|
const { selection } = tr
|
||||||
const next = { ...prev }
|
const next = { ...prev }
|
||||||
@@ -224,13 +202,8 @@ export default function SuggestionsPlugin({
|
|||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
/**
|
|
||||||
* Call the keydown hook if suggestion is active.
|
// Call the keydown hook if suggestion is active.
|
||||||
*
|
|
||||||
* @param view
|
|
||||||
* @param event
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
handleKeyDown(view, event) {
|
handleKeyDown(view, event) {
|
||||||
const { active, range } = this.getState(view.state)
|
const { active, range } = this.getState(view.state)
|
||||||
|
|
||||||
@@ -239,13 +212,7 @@ export default function SuggestionsPlugin({
|
|||||||
return onKeyDown({ view, event, range })
|
return onKeyDown({ view, event, range })
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
// Setup decorator on the currently active suggestion.
|
||||||
* Setup decorator on the currently active suggestion.
|
|
||||||
*
|
|
||||||
* @param {EditorState} editorState
|
|
||||||
*
|
|
||||||
* @returns {?DecorationSet}
|
|
||||||
*/
|
|
||||||
decorations(editorState) {
|
decorations(editorState) {
|
||||||
const { active, range, decorationId } = this.getState(editorState)
|
const { active, range, decorationId } = this.getState(editorState)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user