Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tiptap/suggestion

Package Overview
Dependencies
Maintainers
5
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/suggestion - npm Package Compare versions

Comparing version 3.0.0-next.1 to 3.0.0-next.2

10

dist/index.d.ts

@@ -9,2 +9,3 @@ import { Range, Editor } from '@tiptap/core';

allowSpaces: boolean;
allowToIncludeChar: boolean;
allowedPrefixes: string[] | null;

@@ -40,3 +41,3 @@ startOfLine: boolean;

/**
* Allow spaces in the suggestion query.
* Allow spaces in the suggestion query. Not compatible with `allowToIncludeChar`. Will be disabled if `allowToIncludeChar` is set to `true`.
* @default false

@@ -47,2 +48,7 @@ * @example true

/**
* Allow the character to be included in the suggestion query. Not compatible with `allowSpaces`.
* @default false
*/
allowToIncludeChar?: boolean;
/**
* Allow prefixes in the suggestion query.

@@ -171,4 +177,4 @@ * @default [' ']

*/
declare function Suggestion<I = any, TSelected = any>({ pluginKey, editor, char, allowSpaces, allowedPrefixes, startOfLine, decorationTag, decorationClass, command, items, render, allow, findSuggestionMatch, }: SuggestionOptions<I, TSelected>): Plugin<any>;
declare function Suggestion<I = any, TSelected = any>({ pluginKey, editor, char, allowSpaces, allowToIncludeChar, allowedPrefixes, startOfLine, decorationTag, decorationClass, command, items, render, allow, findSuggestionMatch, }: SuggestionOptions<I, TSelected>): Plugin<any>;
export { Suggestion, type SuggestionKeyDownProps, type SuggestionMatch, type SuggestionOptions, SuggestionPluginKey, type SuggestionProps, type Trigger, Suggestion as default, findSuggestionMatch };

13

dist/index.js

@@ -11,3 +11,4 @@ // src/suggestion.ts

char,
allowSpaces,
allowSpaces: allowSpacesOption,
allowToIncludeChar,
allowedPrefixes,

@@ -17,6 +18,8 @@ startOfLine,

} = config;
const allowSpaces = allowSpacesOption && !allowToIncludeChar;
const escapedChar = escapeForRegEx(char);
const suffix = new RegExp(`\\s${escapedChar}$`);
const prefix = startOfLine ? "^" : "";
const regexp = allowSpaces ? new RegExp(`${prefix}${escapedChar}.*?(?=\\s${escapedChar}|$)`, "gm") : new RegExp(`${prefix}(?:^)?${escapedChar}[^\\s${escapedChar}]*`, "gm");
const finalEscapedChar = allowToIncludeChar ? "" : escapedChar;
const regexp = allowSpaces ? new RegExp(`${prefix}${escapedChar}.*?(?=\\s${finalEscapedChar}|$)`, "gm") : new RegExp(`${prefix}(?:^)?${escapedChar}[^\\s${finalEscapedChar}]*`, "gm");
const text = ((_a = $position.nodeBefore) == null ? void 0 : _a.isText) && $position.nodeBefore.text;

@@ -62,2 +65,3 @@ if (!text) {

allowSpaces = false,
allowToIncludeChar = false,
allowedPrefixes = [" "],

@@ -87,5 +91,5 @@ startOfLine = false,

const changed = !started && !stopped && prev.query !== next.query;
const handleStart = started;
const handleStart = started || moved && changed;
const handleChange = changed || moved;
const handleExit = stopped;
const handleExit = stopped || moved && changed;
if (!handleStart && !handleChange && !handleExit) {

@@ -184,2 +188,3 @@ return;

allowSpaces,
allowToIncludeChar,
allowedPrefixes,

@@ -186,0 +191,0 @@ startOfLine,

{
"name": "@tiptap/suggestion",
"description": "suggestion plugin for tiptap",
"version": "3.0.0-next.1",
"version": "3.0.0-next.2",
"homepage": "https://tiptap.dev",

@@ -31,4 +31,4 @@ "keywords": [

"devDependencies": {
"@tiptap/core": "^3.0.0-next.1",
"@tiptap/pm": "^3.0.0-next.1"
"@tiptap/core": "^3.0.0-next.2",
"@tiptap/pm": "^3.0.0-next.2"
},

@@ -35,0 +35,0 @@ "peerDependencies": {

@@ -7,2 +7,3 @@ import { escapeForRegEx, Range } from '@tiptap/core'

allowSpaces: boolean
allowToIncludeChar: boolean
allowedPrefixes: string[] | null

@@ -21,11 +22,14 @@ startOfLine: boolean

const {
char, allowSpaces, allowedPrefixes, startOfLine, $position,
char, allowSpaces: allowSpacesOption, allowToIncludeChar, allowedPrefixes, startOfLine, $position,
} = config
const allowSpaces = allowSpacesOption && !allowToIncludeChar
const escapedChar = escapeForRegEx(char)
const suffix = new RegExp(`\\s${escapedChar}$`)
const prefix = startOfLine ? '^' : ''
const finalEscapedChar = allowToIncludeChar ? '' : escapedChar
const regexp = allowSpaces
? new RegExp(`${prefix}${escapedChar}.*?(?=\\s${escapedChar}|$)`, 'gm')
: new RegExp(`${prefix}(?:^)?${escapedChar}[^\\s${escapedChar}]*`, 'gm')
? new RegExp(`${prefix}${escapedChar}.*?(?=\\s${finalEscapedChar}|$)`, 'gm')
: new RegExp(`${prefix}(?:^)?${escapedChar}[^\\s${finalEscapedChar}]*`, 'gm')

@@ -32,0 +36,0 @@ const text = $position.nodeBefore?.isText && $position.nodeBefore.text

@@ -29,3 +29,3 @@ import { Editor, Range } from '@tiptap/core'

/**
* Allow spaces in the suggestion query.
* Allow spaces in the suggestion query. Not compatible with `allowToIncludeChar`. Will be disabled if `allowToIncludeChar` is set to `true`.
* @default false

@@ -37,2 +37,8 @@ * @example true

/**
* Allow the character to be included in the suggestion query. Not compatible with `allowSpaces`.
* @default false
*/
allowToIncludeChar?: boolean
/**
* Allow prefixes in the suggestion query.

@@ -172,2 +178,3 @@ * @default [' ']

allowSpaces = false,
allowToIncludeChar = false,
allowedPrefixes = [' '],

@@ -201,5 +208,5 @@ startOfLine = false,

const handleStart = started
const handleStart = started || (moved && changed)
const handleChange = changed || moved
const handleExit = stopped
const handleExit = stopped || (moved && changed)

@@ -330,2 +337,3 @@ // Cancel when suggestion isn't active

allowSpaces,
allowToIncludeChar,
allowedPrefixes,

@@ -332,0 +340,0 @@ startOfLine,

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc