@tiptap/suggestion
Advanced tools
Comparing version 2.3.2 to 2.4.0
@@ -54,2 +54,6 @@ import { PluginKey, Plugin } from '@tiptap/pm/state'; | ||
const SuggestionPluginKey = new PluginKey('suggestion'); | ||
/** | ||
* This utility allows you to create suggestions. | ||
* @see https://tiptap.dev/api/utilities/suggestion | ||
*/ | ||
function Suggestion({ pluginKey = SuggestionPluginKey, editor, char = '@', allowSpaces = false, allowedPrefixes = [' '], startOfLine = false, decorationTag = 'span', decorationClass = 'suggestion', command = () => null, items = () => [], render = () => ({}), allow = () => true, findSuggestionMatch: findSuggestionMatch$1 = findSuggestionMatch, }) { | ||
@@ -56,0 +60,0 @@ let props; |
@@ -56,2 +56,6 @@ (function (global, factory) { | ||
const SuggestionPluginKey = new state.PluginKey('suggestion'); | ||
/** | ||
* This utility allows you to create suggestions. | ||
* @see https://tiptap.dev/api/utilities/suggestion | ||
*/ | ||
function Suggestion({ pluginKey = SuggestionPluginKey, editor, char = '@', allowSpaces = false, allowedPrefixes = [' '], startOfLine = false, decorationTag = 'span', decorationClass = 'suggestion', command = () => null, items = () => [], render = () => ({}), allow = () => true, findSuggestionMatch: findSuggestionMatch$1 = findSuggestionMatch, }) { | ||
@@ -58,0 +62,0 @@ let props; |
@@ -6,10 +6,58 @@ import { Editor, Range } from '@tiptap/core'; | ||
export interface SuggestionOptions<I = any> { | ||
/** | ||
* The plugin key for the suggestion plugin. | ||
* @default 'suggestion' | ||
* @example 'mention' | ||
*/ | ||
pluginKey?: PluginKey; | ||
/** | ||
* The editor instance. | ||
* @default null | ||
*/ | ||
editor: Editor; | ||
/** | ||
* The character that triggers the suggestion. | ||
* @default '@' | ||
* @example '#' | ||
*/ | ||
char?: string; | ||
/** | ||
* Allow spaces in the suggestion query. | ||
* @default false | ||
* @example true | ||
*/ | ||
allowSpaces?: boolean; | ||
/** | ||
* Allow prefixes in the suggestion query. | ||
* @default [' '] | ||
* @example [' ', '@'] | ||
*/ | ||
allowedPrefixes?: string[] | null; | ||
/** | ||
* Only match suggestions at the start of the line. | ||
* @default false | ||
* @example true | ||
*/ | ||
startOfLine?: boolean; | ||
/** | ||
* The tag name of the decoration node. | ||
* @default 'span' | ||
* @example 'div' | ||
*/ | ||
decorationTag?: string; | ||
/** | ||
* The class name of the decoration node. | ||
* @default 'suggestion' | ||
* @example 'mention' | ||
*/ | ||
decorationClass?: string; | ||
/** | ||
* A function that is called when a suggestion is selected. | ||
* @param props The props object. | ||
* @param props.editor The editor instance. | ||
* @param props.range The range of the suggestion. | ||
* @param props.props The props of the selected suggestion. | ||
* @returns void | ||
* @example ({ editor, range, props }) => { props.command(props.props) } | ||
*/ | ||
command?: (props: { | ||
@@ -20,2 +68,10 @@ editor: Editor; | ||
}) => void; | ||
/** | ||
* A function that returns the suggestion items in form of an array. | ||
* @param props The props object. | ||
* @param props.editor The editor instance. | ||
* @param props.query The current suggestion query. | ||
* @returns An array of suggestion items. | ||
* @example ({ editor, query }) => [{ id: 1, label: 'John Doe' }] | ||
*/ | ||
items?: (props: { | ||
@@ -25,2 +81,6 @@ query: string; | ||
}) => I[] | Promise<I[]>; | ||
/** | ||
* The render function for the suggestion. | ||
* @returns An object with render functions. | ||
*/ | ||
render?: () => { | ||
@@ -34,2 +94,7 @@ onBeforeStart?: (props: SuggestionProps<I>) => void; | ||
}; | ||
/** | ||
* A function that returns a boolean to indicate if the suggestion should be active. | ||
* @param props The props object. | ||
* @returns {boolean} | ||
*/ | ||
allow?: (props: { | ||
@@ -43,9 +108,38 @@ editor: Editor; | ||
export interface SuggestionProps<I = any> { | ||
/** | ||
* The editor instance. | ||
*/ | ||
editor: Editor; | ||
/** | ||
* The range of the suggestion. | ||
*/ | ||
range: Range; | ||
/** | ||
* The current suggestion query. | ||
*/ | ||
query: string; | ||
/** | ||
* The current suggestion text. | ||
*/ | ||
text: string; | ||
/** | ||
* The suggestion items array. | ||
*/ | ||
items: I[]; | ||
/** | ||
* A function that is called when a suggestion is selected. | ||
* @param props The props object. | ||
* @returns void | ||
*/ | ||
command: (props: I) => void; | ||
/** | ||
* The decoration node HTML element | ||
* @default null | ||
*/ | ||
decorationNode: Element | null; | ||
/** | ||
* The function that returns the client rect | ||
* @default null | ||
* @example () => new DOMRect(0, 0, 0, 0) | ||
*/ | ||
clientRect?: (() => DOMRect | null) | null; | ||
@@ -59,2 +153,6 @@ } | ||
export declare const SuggestionPluginKey: PluginKey<any>; | ||
/** | ||
* This utility allows you to create suggestions. | ||
* @see https://tiptap.dev/api/utilities/suggestion | ||
*/ | ||
export declare function Suggestion<I = any>({ pluginKey, editor, char, allowSpaces, allowedPrefixes, startOfLine, decorationTag, decorationClass, command, items, render, allow, findSuggestionMatch, }: SuggestionOptions<I>): Plugin<any>; |
{ | ||
"name": "@tiptap/suggestion", | ||
"description": "suggestion plugin for tiptap", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"homepage": "https://tiptap.dev", | ||
@@ -32,4 +32,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/core": "^2.3.2", | ||
"@tiptap/pm": "^2.3.2" | ||
"@tiptap/core": "^2.4.0", | ||
"@tiptap/pm": "^2.4.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "peerDependencies": { |
@@ -8,12 +8,82 @@ import { Editor, Range } from '@tiptap/core' | ||
export interface SuggestionOptions<I = any> { | ||
/** | ||
* The plugin key for the suggestion plugin. | ||
* @default 'suggestion' | ||
* @example 'mention' | ||
*/ | ||
pluginKey?: PluginKey | ||
/** | ||
* The editor instance. | ||
* @default null | ||
*/ | ||
editor: Editor | ||
/** | ||
* The character that triggers the suggestion. | ||
* @default '@' | ||
* @example '#' | ||
*/ | ||
char?: string | ||
/** | ||
* Allow spaces in the suggestion query. | ||
* @default false | ||
* @example true | ||
*/ | ||
allowSpaces?: boolean | ||
/** | ||
* Allow prefixes in the suggestion query. | ||
* @default [' '] | ||
* @example [' ', '@'] | ||
*/ | ||
allowedPrefixes?: string[] | null | ||
/** | ||
* Only match suggestions at the start of the line. | ||
* @default false | ||
* @example true | ||
*/ | ||
startOfLine?: boolean | ||
/** | ||
* The tag name of the decoration node. | ||
* @default 'span' | ||
* @example 'div' | ||
*/ | ||
decorationTag?: string | ||
/** | ||
* The class name of the decoration node. | ||
* @default 'suggestion' | ||
* @example 'mention' | ||
*/ | ||
decorationClass?: string | ||
/** | ||
* A function that is called when a suggestion is selected. | ||
* @param props The props object. | ||
* @param props.editor The editor instance. | ||
* @param props.range The range of the suggestion. | ||
* @param props.props The props of the selected suggestion. | ||
* @returns void | ||
* @example ({ editor, range, props }) => { props.command(props.props) } | ||
*/ | ||
command?: (props: { editor: Editor; range: Range; props: I }) => void | ||
/** | ||
* A function that returns the suggestion items in form of an array. | ||
* @param props The props object. | ||
* @param props.editor The editor instance. | ||
* @param props.query The current suggestion query. | ||
* @returns An array of suggestion items. | ||
* @example ({ editor, query }) => [{ id: 1, label: 'John Doe' }] | ||
*/ | ||
items?: (props: { query: string; editor: Editor }) => I[] | Promise<I[]> | ||
/** | ||
* The render function for the suggestion. | ||
* @returns An object with render functions. | ||
*/ | ||
render?: () => { | ||
@@ -27,2 +97,8 @@ onBeforeStart?: (props: SuggestionProps<I>) => void | ||
} | ||
/** | ||
* A function that returns a boolean to indicate if the suggestion should be active. | ||
* @param props The props object. | ||
* @returns {boolean} | ||
*/ | ||
allow?: (props: { editor: Editor; state: EditorState; range: Range }) => boolean | ||
@@ -33,9 +109,45 @@ findSuggestionMatch?: typeof defaultFindSuggestionMatch | ||
export interface SuggestionProps<I = any> { | ||
/** | ||
* The editor instance. | ||
*/ | ||
editor: Editor | ||
/** | ||
* The range of the suggestion. | ||
*/ | ||
range: Range | ||
/** | ||
* The current suggestion query. | ||
*/ | ||
query: string | ||
/** | ||
* The current suggestion text. | ||
*/ | ||
text: string | ||
/** | ||
* The suggestion items array. | ||
*/ | ||
items: I[] | ||
/** | ||
* A function that is called when a suggestion is selected. | ||
* @param props The props object. | ||
* @returns void | ||
*/ | ||
command: (props: I) => void | ||
/** | ||
* The decoration node HTML element | ||
* @default null | ||
*/ | ||
decorationNode: Element | null | ||
/** | ||
* The function that returns the client rect | ||
* @default null | ||
* @example () => new DOMRect(0, 0, 0, 0) | ||
*/ | ||
clientRect?: (() => DOMRect | null) | null | ||
@@ -52,2 +164,6 @@ } | ||
/** | ||
* This utility allows you to create suggestions. | ||
* @see https://tiptap.dev/api/utilities/suggestion | ||
*/ | ||
export function Suggestion<I = any>({ | ||
@@ -54,0 +170,0 @@ pluginKey = SuggestionPluginKey, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124202
1282
237
4
6
0
63