New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@chatwoot/prosemirror-schema

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chatwoot/prosemirror-schema - npm Package Compare versions

Comparing version 1.1.0-next to 1.1.1-next

src/plugins/image.js

2

package.json
{
"name": "@chatwoot/prosemirror-schema",
"version": "1.1.0-next",
"version": "1.1.1-next",
"description": "Schema setup for using prosemirror in chatwoot. Based on 👉 https://github.com/ProseMirror/prosemirror-example-setup/",

@@ -5,0 +5,0 @@ "main": "dist/index.es.js",

@@ -9,8 +9,20 @@ /**

export const triggerCharacters = char => $position => {
const regexp = new RegExp(`(?:^)?${char}[^\\s${char}]*`, 'g');
/**
* Creates a function to detect if the trigger character followed by a specified number of characters
* has been typed, starting from a new word, after a space, or after a newline.
* @param {string} char - The trigger character to detect.
* @param {number} [minChars=0] - The minimum number of characters that should follow the trigger character.
* @returns {Function} A function that takes a position object and returns the match if the condition is met.
*/
export const triggerCharacters = (char, minChars = 0) => $position => {
// Regular expression to find occurrences of 'char' followed by at least 'minChars' non-space characters.
// It matches these sequences starting from the beginning of the text or after a space.
const regexp = new RegExp(`(?:^)?${char}[^\\s${char}]{${minChars},}`, 'g');
// Get the position before the current cursor position in the document.
const textFrom = $position.before();
// Get the position at the end of the current node.
const textTo = $position.end();
// Get the text between the start of the node and the cursor position.
const text = $position.doc.textBetween(textFrom, textTo, '\0', '\0');

@@ -22,4 +34,6 @@

while ((match = regexp.exec(text))) {
// Check if the character before the match is a space, start of string, or null character
const prefix = match.input.slice(Math.max(0, match.index - 1), match.index);
if (!/^[\s\0]?$/.test(prefix)) {
// If the prefix is not empty, space, or null, skip this match
// eslint-disable-next-line

@@ -30,6 +44,9 @@ continue;

const from = match.index + $position.start();
let to = from + match[0].length;
const to = from + match[0].length;
if (from < $position.pos && to >= $position.pos) {
return { range: { from, to }, text: match[0] };
const fullMatch = match[0];
// Remove trigger char and trim
const trimmedText = fullMatch ? fullMatch.slice(char.length) : '';
return { range: { from, to }, text: trimmedText };
}

@@ -36,0 +53,0 @@ }

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