@tiptap/suggestion
Advanced tools
Comparing version 3.0.0-next.3 to 3.0.0-next.4
@@ -43,3 +43,3 @@ import { Range, Editor } from '@tiptap/core'; | ||
* @example true | ||
*/ | ||
*/ | ||
allowSpaces?: boolean; | ||
@@ -46,0 +46,0 @@ /** |
@@ -9,10 +9,3 @@ // src/suggestion.ts | ||
var _a; | ||
const { | ||
char, | ||
allowSpaces: allowSpacesOption, | ||
allowToIncludeChar, | ||
allowedPrefixes, | ||
startOfLine, | ||
$position | ||
} = config; | ||
const { char, allowSpaces: allowSpacesOption, allowToIncludeChar, allowedPrefixes, startOfLine, $position } = config; | ||
const allowSpaces = allowSpacesOption && !allowToIncludeChar; | ||
@@ -96,5 +89,3 @@ const escapedChar = escapeForRegEx(char); | ||
const state = handleExit && !handleStart ? prev : next; | ||
const decorationNode = view.dom.querySelector( | ||
`[data-decoration-id="${state.decorationId}"]` | ||
); | ||
const decorationNode = view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`); | ||
props = { | ||
@@ -119,5 +110,3 @@ editor, | ||
const { decorationId } = (_a2 = this.key) == null ? void 0 : _a2.getState(editor.state); | ||
const currentDecorationNode = view.dom.querySelector( | ||
`[data-decoration-id="${decorationId}"]` | ||
); | ||
const currentDecorationNode = view.dom.querySelector(`[data-decoration-id="${decorationId}"]`); | ||
return (currentDecorationNode == null ? void 0 : currentDecorationNode.getBoundingClientRect()) || null; | ||
@@ -249,9 +238,9 @@ } : null | ||
// src/index.ts | ||
var src_default = Suggestion; | ||
var index_default = Suggestion; | ||
export { | ||
Suggestion, | ||
SuggestionPluginKey, | ||
src_default as default, | ||
index_default as default, | ||
findSuggestionMatch | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tiptap/suggestion", | ||
"description": "suggestion plugin for tiptap", | ||
"version": "3.0.0-next.3", | ||
"version": "3.0.0-next.4", | ||
"homepage": "https://tiptap.dev", | ||
@@ -17,3 +17,6 @@ "keywords": [ | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"types": { | ||
"import": "./dist/index.d.ts", | ||
"require": "./dist/index.d.cts" | ||
}, | ||
"import": "./dist/index.js", | ||
@@ -32,4 +35,4 @@ "require": "./dist/index.cjs" | ||
"devDependencies": { | ||
"@tiptap/core": "^3.0.0-next.3", | ||
"@tiptap/pm": "^3.0.0-next.3" | ||
"@tiptap/core": "^3.0.0-next.4", | ||
"@tiptap/pm": "^3.0.0-next.4" | ||
}, | ||
@@ -46,4 +49,5 @@ "peerDependencies": { | ||
"scripts": { | ||
"build": "tsup" | ||
"build": "tsup", | ||
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/" | ||
} | ||
} | ||
} |
# @tiptap/suggestion | ||
[![Version](https://img.shields.io/npm/v/@tiptap/suggestion.svg?label=version)](https://www.npmjs.com/package/@tiptap/suggestion) | ||
@@ -8,8 +9,11 @@ [![Downloads](https://img.shields.io/npm/dm/@tiptap/suggestion.svg)](https://npmcharts.com/compare/tiptap?minimal=true) | ||
## Introduction | ||
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*. | ||
Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_. | ||
## Official Documentation | ||
Documentation can be found on the [Tiptap website](https://tiptap.dev). | ||
## License | ||
Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md). |
@@ -20,5 +20,3 @@ import { escapeForRegEx, Range } from '@tiptap/core' | ||
export function findSuggestionMatch(config: Trigger): SuggestionMatch { | ||
const { | ||
char, allowSpaces: allowSpacesOption, allowToIncludeChar, allowedPrefixes, startOfLine, $position, | ||
} = config | ||
const { char, allowSpaces: allowSpacesOption, allowToIncludeChar, allowedPrefixes, startOfLine, $position } = config | ||
@@ -25,0 +23,0 @@ const allowSpaces = allowSpacesOption && !allowToIncludeChar |
@@ -32,3 +32,3 @@ import { Editor, Range } from '@tiptap/core' | ||
* @example true | ||
*/ | ||
*/ | ||
allowSpaces?: boolean | ||
@@ -96,8 +96,8 @@ | ||
render?: () => { | ||
onBeforeStart?: (props: SuggestionProps<I, TSelected>) => void; | ||
onStart?: (props: SuggestionProps<I, TSelected>) => void; | ||
onBeforeUpdate?: (props: SuggestionProps<I, TSelected>) => void; | ||
onUpdate?: (props: SuggestionProps<I, TSelected>) => void; | ||
onExit?: (props: SuggestionProps<I, TSelected>) => void; | ||
onKeyDown?: (props: SuggestionKeyDownProps) => boolean; | ||
onBeforeStart?: (props: SuggestionProps<I, TSelected>) => void | ||
onStart?: (props: SuggestionProps<I, TSelected>) => void | ||
onBeforeUpdate?: (props: SuggestionProps<I, TSelected>) => void | ||
onUpdate?: (props: SuggestionProps<I, TSelected>) => void | ||
onExit?: (props: SuggestionProps<I, TSelected>) => void | ||
onKeyDown?: (props: SuggestionKeyDownProps) => boolean | ||
} | ||
@@ -110,3 +110,3 @@ | ||
*/ | ||
allow?: (props: { editor: Editor; state: EditorState; range: Range, isActive?: boolean }) => boolean | ||
allow?: (props: { editor: Editor; state: EditorState; range: Range; isActive?: boolean }) => boolean | ||
findSuggestionMatch?: typeof defaultFindSuggestionMatch | ||
@@ -218,5 +218,3 @@ } | ||
const state = handleExit && !handleStart ? prev : next | ||
const decorationNode = view.dom.querySelector( | ||
`[data-decoration-id="${state.decorationId}"]`, | ||
) | ||
const decorationNode = view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`) | ||
@@ -241,10 +239,8 @@ props = { | ||
? () => { | ||
// because of `items` can be asynchrounous we’ll search for the current decoration node | ||
// because of `items` can be asynchrounous we’ll search for the current decoration node | ||
const { decorationId } = this.key?.getState(editor.state) // eslint-disable-line | ||
const currentDecorationNode = view.dom.querySelector( | ||
`[data-decoration-id="${decorationId}"]`, | ||
) | ||
const currentDecorationNode = view.dom.querySelector(`[data-decoration-id="${decorationId}"]`) | ||
return currentDecorationNode?.getBoundingClientRect() || null | ||
} | ||
return currentDecorationNode?.getBoundingClientRect() || null | ||
} | ||
: null, | ||
@@ -346,5 +342,11 @@ } | ||
// If we found a match, update the current state to show it | ||
if (match && allow({ | ||
editor, state, range: match.range, isActive: prev.active, | ||
})) { | ||
if ( | ||
match && | ||
allow({ | ||
editor, | ||
state, | ||
range: match.range, | ||
isActive: prev.active, | ||
}) | ||
) { | ||
next.active = true | ||
@@ -351,0 +353,0 @@ next.decorationId = prev.decorationId ? prev.decorationId : decorationId |
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
Unstable ownership
Supply chain riskA new collaborator has begun publishing package versions. Package stability and security risk may be elevated.
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
84066
12
19
1088
1