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

prosemirror-suggest

Package Overview
Dependencies
Maintainers
2
Versions
273
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-suggest - npm Package Compare versions

Comparing version 3.0.0-beta.3 to 3.0.0-beta.4

10

dist/prosemirror-suggest.d.ts

@@ -61,11 +61,1 @@ export { addSuggester } from './_tsup-dts-rollup';

export { SelectionProps } from './_tsup-dts-rollup';
export { isChange } from './_tsup-dts-rollup';
export { isIdentical } from './_tsup-dts-rollup';
export { isMove } from './_tsup-dts-rollup';
export { isEntry } from './_tsup-dts-rollup';
export { isExit } from './_tsup-dts-rollup';
export { isJump } from './_tsup-dts-rollup';
export { isTextSelection } from './_tsup-dts-rollup';
export { suggestPluginKey } from './_tsup-dts-rollup';
export { findReason } from './_tsup-dts-rollup';
export { getCharAsRegex } from './_tsup-dts-rollup';

907

dist/prosemirror-suggest.js

@@ -1,17 +0,29 @@

var _docChanged, _ignoreNextExit, _suggesters, _next, _prev, _handlerMatches, _ignored, _removed, _lastChangeFromAppend;
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __typeError = (msg) => {
throw TypeError(msg);
};
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
// src/suggest-plugin.ts

@@ -30,3 +42,3 @@ import { Plugin } from "prosemirror-state";

// src/suggest-types.ts
var ExitReason = /* @__PURE__ */(ExitReason2 => {
var ExitReason = /* @__PURE__ */ ((ExitReason2) => {
ExitReason2["End"] = "exit-end";

@@ -43,3 +55,3 @@ ExitReason2["Removed"] = "delete";

})(ExitReason || {});
var ChangeReason = /* @__PURE__ */(ChangeReason2 => {
var ChangeReason = /* @__PURE__ */ ((ChangeReason2) => {
ChangeReason2["Start"] = "start";

@@ -76,9 +88,18 @@ ChangeReason2["Text"] = "change-character";

}
var selectionExitReasons = ["move-end" /* MoveEnd */, "move-start" /* MoveStart */, "selection-outside" /* SelectionOutside */, "jump-forward-exit" /* JumpForward */, "jump-backward-exit" /* JumpBackward */];
var selectionExitReasons = [
"move-end" /* MoveEnd */,
"move-start" /* MoveStart */,
"selection-outside" /* SelectionOutside */,
"jump-forward-exit" /* JumpForward */,
"jump-backward-exit" /* JumpBackward */
];
function isSelectionExitReason(value) {
return includes(selectionExitReasons, value);
}
var selectionChangeReasons = ["jump-backward-change" /* JumpBackward */, "jump-forward-change" /* JumpForward */, "move" /* Move */, "selection-inside" /* SelectionInside */];
var selectionChangeReasons = [
"jump-backward-change" /* JumpBackward */,
"jump-forward-change" /* JumpForward */,
"move" /* Move */,
"selection-inside" /* SelectionInside */
];
function isSelectionChangeReason(value) {

@@ -90,16 +111,13 @@ return includes(selectionChangeReasons, value);

}
function isInvalidSplitReason(value) {
return value === "invalid-exit-split" /* InvalidSplit */;
}
function isRemovedReason(value) {
return value === "delete" /* Removed */;
}
var exitJump = ["jump-backward-exit" /* JumpBackward */, "jump-forward-exit" /* JumpForward */];
var changeJump = ["jump-backward-change" /* JumpBackward */, "jump-forward-change" /* JumpForward */];
function isJumpReason(map) {
var _map$exit, _map$change;
return includes(exitJump, (_map$exit = map.exit) === null || _map$exit === void 0 ? void 0 : _map$exit.exitReason) || includes(changeJump, (_map$change = map.change) === null || _map$change === void 0 ? void 0 : _map$change.changeReason);
var _a, _b;
return includes(exitJump, (_a = map.exit) == null ? void 0 : _a.exitReason) || includes(changeJump, (_b = map.change) == null ? void 0 : _b.changeReason);
}

@@ -110,4 +128,3 @@ function isValidMatch(match) {

function selectionOutsideMatch(props) {
var match = props.match,
selection = props.selection;
const { match, selection } = props;
return !!match && (selection.from < match.range.from || selection.from > match.range.to);

@@ -122,8 +139,13 @@ }

import { NULL_CHARACTER } from "@remirror/core-constants";
import { findMatches, isEmptyArray, isRegExp, isString as isString2, object, range } from "@remirror/core-helpers";
import {
findMatches,
isEmptyArray,
isRegExp,
isString as isString2,
object,
range
} from "@remirror/core-helpers";
function createMatchWithReason(props) {
var match = props.match,
changeReason = props.changeReason,
exitReason = props.exitReason;
return _objectSpread(_objectSpread({}, match), {}, {
const { match, changeReason, exitReason } = props;
return __spreadProps(__spreadValues({}, match), {
changeReason,

@@ -134,39 +156,31 @@ exitReason

function isPrefixValid(prefix, options) {
var invalidPrefixCharacters = options.invalidPrefixCharacters,
validPrefixCharacters = options.validPrefixCharacters;
const { invalidPrefixCharacters, validPrefixCharacters } = options;
if (invalidPrefixCharacters) {
var regex = new RegExp(regexToString(invalidPrefixCharacters));
const regex = new RegExp(regexToString(invalidPrefixCharacters));
return !regex.test(prefix);
}
{
var _regex = new RegExp(regexToString(validPrefixCharacters));
return _regex.test(prefix);
const regex = new RegExp(regexToString(validPrefixCharacters));
return regex.test(prefix);
}
}
function findPosition(props) {
var text = props.text,
regexp = props.regexp,
$pos = props.$pos,
suggester = props.suggester;
var start = $pos.start();
var position;
findMatches(text, regexp).forEach(match => {
var matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index);
const { text, regexp, $pos, suggester } = props;
const start = $pos.start();
let position;
findMatches(text, regexp).forEach((match) => {
const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index);
if (isPrefixValid(matchPrefix, suggester)) {
var from = match.index + start;
var fullMatch = match[0];
var charMatch = match[1];
const from = match.index + start;
const fullMatch = match[0];
const charMatch = match[1];
if (!isString2(fullMatch) || !isString2(charMatch)) {
return;
}
var to = from + fullMatch.length;
var cursor = Math.min(to, $pos.pos);
var matchLength = cursor - from;
const to = from + fullMatch.length;
const cursor = Math.min(to, $pos.pos);
const matchLength = cursor - from;
if (from < $pos.pos && to >= $pos.pos) {
position = {
range: {
from,
to,
cursor
},
range: { from, to, cursor },
match,

@@ -177,6 +191,3 @@ query: {

},
text: {
partial: fullMatch.slice(0, matchLength),
full: fullMatch
},
text: { partial: fullMatch.slice(0, matchLength), full: fullMatch },
textAfter: $pos.doc.textBetween(to, $pos.end(), NULL_CHARACTER, NULL_CHARACTER),

@@ -192,15 +203,16 @@ textBefore: $pos.doc.textBetween(start, from, NULL_CHARACTER, NULL_CHARACTER),

function findMatch(props) {
var $pos = props.$pos,
suggester = props.suggester;
var char = suggester.char,
name = suggester.name,
startOfLine = suggester.startOfLine,
supportedCharacters = suggester.supportedCharacters,
matchOffset = suggester.matchOffset,
multiline = suggester.multiline,
caseInsensitive = suggester.caseInsensitive,
unicode = suggester.unicode;
var regexp = createRegexFromSuggester({
const { $pos, suggester } = props;
const {
char,
name,
startOfLine,
supportedCharacters,
matchOffset,
multiline,
caseInsensitive,
unicode
} = suggester;
const regexp = createRegexFromSuggester({
char,
matchOffset,
startOfLine,

@@ -212,3 +224,3 @@ supportedCharacters,

});
var text = $pos.doc.textBetween($pos.before(), $pos.end(), NULL_CHARACTER, NULL_CHARACTER);
const text = $pos.doc.textBetween($pos.before(), $pos.end(), NULL_CHARACTER, NULL_CHARACTER);
return findPosition({

@@ -224,4 +236,3 @@ suggester,

function recheckMatch(props) {
var state = props.state,
match = props.match;
const { state, match } = props;
try {

@@ -232,3 +243,3 @@ return findMatch({

});
} catch (_unused) {
} catch (e) {
return;

@@ -238,5 +249,3 @@ }

function createInsertReason(props) {
var prev = props.prev,
next = props.next,
state = props.state;
const { prev, next, state } = props;
if (!next && prev.range.from >= state.doc.nodeSize) {

@@ -250,3 +259,2 @@ return {

}
if (!next || !prev.query.partial) {

@@ -260,154 +268,68 @@ return {

}
if (prev.range.to === next.range.cursor) {
return {
exit: createMatchWithReason({
match: next,
exitReason: "exit-end" /* End */
})
};
return { exit: createMatchWithReason({ match: next, exitReason: "exit-end" /* End */ }) };
}
if (prev.query.partial) {
return {
exit: createMatchWithReason({
match: next,
exitReason: "exit-split" /* Split */
})
};
return { exit: createMatchWithReason({ match: next, exitReason: "exit-split" /* Split */ }) };
}
return {};
}
function findJumpReason(props) {
var prev = props.prev,
next = props.next,
state = props.state;
var value = object();
var updatedPrevious = recheckMatch({
state,
match: prev
});
var _ref = updatedPrevious && updatedPrevious.query.full !== prev.query.full ? createInsertReason({
prev,
next: updatedPrevious,
state
}) : value,
exit = _ref.exit;
var isJumpForward = prev.range.from < next.range.from;
const { prev, next, state } = props;
const value = object();
const updatedPrevious = recheckMatch({ state, match: prev });
const { exit } = updatedPrevious && updatedPrevious.query.full !== prev.query.full ? createInsertReason({ prev, next: updatedPrevious, state }) : value;
const isJumpForward = prev.range.from < next.range.from;
if (isJumpForward) {
return {
exit: exit !== null && exit !== void 0 ? exit : createMatchWithReason({
match: prev,
exitReason: "jump-forward-exit" /* JumpForward */
}),
change: createMatchWithReason({
match: next,
changeReason: "jump-forward-change" /* JumpForward */
})
exit: exit != null ? exit : createMatchWithReason({ match: prev, exitReason: "jump-forward-exit" /* JumpForward */ }),
change: createMatchWithReason({ match: next, changeReason: "jump-forward-change" /* JumpForward */ })
};
}
return {
exit: exit !== null && exit !== void 0 ? exit : createMatchWithReason({
match: prev,
exitReason: "jump-backward-exit" /* JumpBackward */
}),
change: createMatchWithReason({
match: next,
changeReason: "jump-backward-change" /* JumpBackward */
})
exit: exit != null ? exit : createMatchWithReason({ match: prev, exitReason: "jump-backward-exit" /* JumpBackward */ }),
change: createMatchWithReason({ match: next, changeReason: "jump-backward-change" /* JumpBackward */ })
};
}
function findExitReason(props) {
var match = props.match,
state = props.state,
$pos = props.$pos;
var selection = state.selection;
var updatedPrevious = recheckMatch({
match,
state
});
const { match, state, $pos } = props;
const { selection } = state;
const updatedPrevious = recheckMatch({ match, state });
if (!updatedPrevious || updatedPrevious.text.full !== match.text.full) {
return createInsertReason({
prev: match,
next: updatedPrevious,
state
});
return createInsertReason({ prev: match, next: updatedPrevious, state });
}
if (!selection.empty && (selection.from <= match.range.from || selection.to >= match.range.to)) {
return {
exit: createMatchWithReason({
match,
exitReason: "selection-outside" /* SelectionOutside */
})
};
return { exit: createMatchWithReason({ match, exitReason: "selection-outside" /* SelectionOutside */ }) };
}
if ($pos.pos > match.range.to) {
return {
exit: createMatchWithReason({
match,
exitReason: "move-end" /* MoveEnd */
})
};
return { exit: createMatchWithReason({ match, exitReason: "move-end" /* MoveEnd */ }) };
}
if ($pos.pos <= match.range.from) {
return {
exit: createMatchWithReason({
match,
exitReason: "move-start" /* MoveStart */
})
};
return { exit: createMatchWithReason({ match, exitReason: "move-start" /* MoveStart */ }) };
}
return {};
}
function findReason(props) {
var prev = props.prev,
next = props.next,
state = props.state,
$pos = props.$pos;
var value = object();
const { prev, next, state, $pos } = props;
const value = object();
if (!prev && !next) {
return value;
}
var compare = {
prev,
next
};
const compare = { prev, next };
if (isJump(compare)) {
return findJumpReason({
prev: compare.prev,
next: compare.next,
state
});
return findJumpReason({ prev: compare.prev, next: compare.next, state });
}
if (isEntry(compare)) {
return {
change: createMatchWithReason({
match: compare.next,
changeReason: "start" /* Start */
})
change: createMatchWithReason({ match: compare.next, changeReason: "start" /* Start */ })
};
}
if (isExit(compare)) {
return findExitReason({
$pos,
match: compare.prev,
state
});
return findExitReason({ $pos, match: compare.prev, state });
}
if (isChange(compare)) {
return {
change: createMatchWithReason({
match: compare.next,
changeReason: "change-character" /* Text */
})
change: createMatchWithReason({ match: compare.next, changeReason: "change-character" /* Text */ })
};
}
if (isMove(compare)) {

@@ -421,8 +343,7 @@ return {

}
return value;
}
function hasParentNode($pos, types) {
for (var depth = $pos.depth; depth > 0; depth--) {
var node = $pos.node(depth);
for (let depth = $pos.depth; depth > 0; depth--) {
const node = $pos.node(depth);
if (types.includes(node.type.name)) {

@@ -435,26 +356,23 @@ return true;

function markActiveInRange(resolvedRange, marks) {
var $from = resolvedRange.$from,
$to = resolvedRange.$to;
const { $from, $to } = resolvedRange;
if (rangeHasMarks(resolvedRange, marks)) {
return true;
}
return range($from.pos, $to.pos).some(value => positionHasMarks($from.doc.resolve(value), marks));
return range($from.pos, $to.pos).some(
(value) => positionHasMarks($from.doc.resolve(value), marks)
);
}
function rangeHasMarks(resolvedRange, marks) {
var _$from$marksAcross;
var $from = resolvedRange.$from,
$to = resolvedRange.$to;
var setOfMarks = new Set(((_$from$marksAcross = $from.marksAcross($to)) !== null && _$from$marksAcross !== void 0 ? _$from$marksAcross : []).map(mark => mark.type.name));
return marks.some(item => setOfMarks.has(item));
var _a;
const { $from, $to } = resolvedRange;
const setOfMarks = new Set(((_a = $from.marksAcross($to)) != null ? _a : []).map((mark) => mark.type.name));
return marks.some((item) => setOfMarks.has(item));
}
function positionHasMarks($pos, marks) {
var setOfMarks = new Set($pos.marks().map(mark => mark.type.name));
return marks.some(item => setOfMarks.has(item));
const setOfMarks = new Set($pos.marks().map((mark) => mark.type.name));
return marks.some((item) => setOfMarks.has(item));
}
function isPositionValidForSuggester(suggester, resolvedRange) {
var $cursor = resolvedRange.$cursor;
var validMarks = suggester.validMarks,
validNodes = suggester.validNodes,
invalidMarks = suggester.invalidMarks,
invalidNodes = suggester.invalidNodes;
const { $cursor } = resolvedRange;
const { validMarks, validNodes, invalidMarks, invalidNodes } = suggester;
if (!validMarks && !validNodes && isEmptyArray(invalidMarks) && isEmptyArray(invalidNodes)) {

@@ -478,35 +396,22 @@ return true;

function findFromSuggesters(props) {
var suggesters = props.suggesters,
$pos = props.$pos,
selectionEmpty = props.selectionEmpty;
var _iterator = _createForOfIteratorHelper(suggesters),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var suggester = _step.value;
if (suggester.emptySelectionsOnly && !selectionEmpty) {
const { suggesters, $pos, selectionEmpty } = props;
for (const suggester of suggesters) {
if (suggester.emptySelectionsOnly && !selectionEmpty) {
continue;
}
try {
const match = findMatch({ suggester, $pos });
if (!match) {
continue;
}
try {
var match = findMatch({
suggester,
$pos
});
if (!match) {
continue;
}
var resolvedRange = {
$from: $pos.doc.resolve(match.range.from),
$to: $pos.doc.resolve(match.range.to),
$cursor: $pos
};
if (isPositionValidForSuggester(suggester, resolvedRange) && suggester.isValidPosition(resolvedRange, match)) {
return match;
}
} catch (_unused2) {}
const resolvedRange = {
$from: $pos.doc.resolve(match.range.from),
$to: $pos.doc.resolve(match.range.to),
$cursor: $pos
};
if (isPositionValidForSuggester(suggester, resolvedRange) && suggester.isValidPosition(resolvedRange, match)) {
return match;
}
} catch (e) {
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}

@@ -528,20 +433,24 @@ return;

function createRegexFromSuggester(props) {
var char = props.char,
matchOffset = props.matchOffset,
startOfLine = props.startOfLine,
supportedCharacters = props.supportedCharacters,
_props$captureChar = props.captureChar,
captureChar = _props$captureChar === void 0 ? true : _props$captureChar,
_props$caseInsensitiv = props.caseInsensitive,
caseInsensitive = _props$caseInsensitiv === void 0 ? false : _props$caseInsensitiv,
_props$multiline = props.multiline,
multiline = _props$multiline === void 0 ? false : _props$multiline,
_props$unicode = props.unicode,
unicode = _props$unicode === void 0 ? false : _props$unicode;
var flags = "g".concat(multiline ? "m" : "").concat(caseInsensitive ? "i" : "").concat(unicode ? "u" : "");
var charRegex = getCharAsRegex(char).source;
const {
char,
matchOffset,
startOfLine,
supportedCharacters,
captureChar = true,
caseInsensitive = false,
multiline = false,
unicode = false
} = props;
const flags = "g".concat(multiline ? "m" : "").concat(caseInsensitive ? "i" : "").concat(unicode ? "u" : "");
let charRegex = getCharAsRegex(char).source;
if (captureChar) {
charRegex = "(".concat(charRegex, ")");
}
return new RegExp("".concat(getRegexPrefix(startOfLine)).concat(charRegex).concat(getRegexSupportedCharacters(supportedCharacters, matchOffset)), flags);
return new RegExp(
"".concat(getRegexPrefix(startOfLine)).concat(charRegex).concat(getRegexSupportedCharacters(
supportedCharacters,
matchOffset
)),
flags
);
}

@@ -575,43 +484,9 @@ var DEFAULT_SUGGESTER = {

function getSuggesterWithDefaults(suggester) {
return _objectSpread(_objectSpread({}, DEFAULT_SUGGESTER), suggester);
return __spreadValues(__spreadValues({}, DEFAULT_SUGGESTER), suggester);
}
// src/suggest-state.ts
var SuggestState = (_docChanged = /*#__PURE__*/new WeakMap(), _ignoreNextExit = /*#__PURE__*/new WeakMap(), _suggesters = /*#__PURE__*/new WeakMap(), _next = /*#__PURE__*/new WeakMap(), _prev = /*#__PURE__*/new WeakMap(), _handlerMatches = /*#__PURE__*/new WeakMap(), _ignored = /*#__PURE__*/new WeakMap(), _removed = /*#__PURE__*/new WeakMap(), _lastChangeFromAppend = /*#__PURE__*/new WeakMap(), class _SuggestState {
var _docChanged, _ignoreNextExit, _suggesters, _next, _prev, _handlerMatches, _ignored, _removed, _lastChangeFromAppend;
var _SuggestState = class _SuggestState {
/**
* Create an instance of the SuggestState class.
*/
static create(suggesters) {
return new _SuggestState(suggesters);
}
/**
* True when the doc changed in the most recently applied transaction.
*/
/**
* The set of all decorations.
*/
get decorationSet() {
return _classPrivateFieldGet(this, _ignored);
}
/**
* True when the most recent change was to remove a mention.
*
* @remarks
*
* This is needed because sometimes removing a prosemirror `Mark` has no
* effect. Hence we need to keep track of whether it's removed and then later
* in the apply step check that a removal has happened and reset the
* `handlerMatches` to prevent an infinite loop.
*/
get removed() {
return _classPrivateFieldGet(this, _removed);
}
/**
* Returns the current active suggester state field if one exists
*/
get match() {
return _classPrivateFieldGet(this, _next) ? _classPrivateFieldGet(this, _next) : _classPrivateFieldGet(this, _prev) && _classPrivateFieldGet(this, _handlerMatches).exit ? _classPrivateFieldGet(this, _prev) : void 0;
}
/**
* Create the state for the `prosemirror-suggest` plugin.

@@ -629,67 +504,43 @@ *

*/
constructor(_suggesters2) {
_classPrivateFieldInitSpec(this, _docChanged, {
writable: true,
value: false
});
constructor(suggesters) {
/**
* True when the doc changed in the most recently applied transaction.
*/
__privateAdd(this, _docChanged, false);
/**
* Whether the next exit should be ignored.
*/
_classPrivateFieldInitSpec(this, _ignoreNextExit, {
writable: true,
value: false
});
__privateAdd(this, _ignoreNextExit, false);
/**
* The suggesters that have been registered for the suggesters plugin.
*/
_classPrivateFieldInitSpec(this, _suggesters, {
writable: true,
value: void 0
});
__privateAdd(this, _suggesters);
/**
* Keeps track of the current state.
*/
_classPrivateFieldInitSpec(this, _next, {
writable: true,
value: void 0
});
__privateAdd(this, _next);
/**
* Holds onto the previous active state.
*/
_classPrivateFieldInitSpec(this, _prev, {
writable: true,
value: void 0
});
__privateAdd(this, _prev);
/**
* The handler matches which are passed into the `onChange` handler.
*/
_classPrivateFieldInitSpec(this, _handlerMatches, {
writable: true,
value: object2()
});
__privateAdd(this, _handlerMatches, object2());
/**
* Holds a copy of the view
*/
_defineProperty(this, "view", void 0);
__publicField(this, "view");
/**
* The set of ignored decorations
*/
_classPrivateFieldInitSpec(this, _ignored, {
writable: true,
value: DecorationSet.empty
});
__privateAdd(this, _ignored, DecorationSet.empty);
/**
* Lets us know whether the most recent change was to remove a mention.
*/
_classPrivateFieldInitSpec(this, _removed, {
writable: true,
value: false
});
__privateAdd(this, _removed, false);
/**
* This is true when the last change was caused by a transaction being appended via this plugin.
*/
_classPrivateFieldInitSpec(this, _lastChangeFromAppend, {
writable: true,
value: false
});
__privateAdd(this, _lastChangeFromAppend, false);
/**

@@ -700,4 +551,4 @@ * Sets the removed property to be true.

*/
_defineProperty(this, "setMarkRemoved", () => {
_classPrivateFieldSet(this, _removed, true);
__publicField(this, "setMarkRemoved", () => {
__privateSet(this, _removed, true);
});

@@ -707,7 +558,7 @@ /**

*/
_defineProperty(this, "findNextTextSelection", selection => {
var doc = selection.$from.doc;
var pos = Math.min(doc.nodeSize - 2, selection.to + 1);
var $pos = doc.resolve(pos);
var nextSelection = Selection.findFrom($pos, 1, true);
__publicField(this, "findNextTextSelection", (selection) => {
const doc = selection.$from.doc;
const pos = Math.min(doc.nodeSize - 2, selection.to + 1);
const $pos = doc.resolve(pos);
const nextSelection = Selection.findFrom($pos, 1, true);
if (!isTextSelection(nextSelection)) {

@@ -726,4 +577,4 @@ return;

*/
_defineProperty(this, "ignoreNextExit", () => {
_classPrivateFieldSet(this, _ignoreNextExit, true);
__publicField(this, "ignoreNextExit", () => {
__privateSet(this, _ignoreNextExit, true);
});

@@ -739,24 +590,17 @@ /**

*/
_defineProperty(this, "addIgnored", _ref2 => {
var from = _ref2.from,
name = _ref2.name,
_ref2$specific = _ref2.specific,
specific = _ref2$specific === void 0 ? false : _ref2$specific;
var suggester = _classPrivateFieldGet(this, _suggesters).find(value => value.name === name);
__publicField(this, "addIgnored", ({ from, name, specific = false }) => {
const suggester = __privateGet(this, _suggesters).find((value) => value.name === name);
if (!suggester) {
throw new Error("No suggester exists for the name provided: ".concat(name));
}
var offset = isString3(suggester.char) ? suggester.char.length : 1;
var to = from + offset;
var attributes = suggester.ignoredClassName ? {
class: suggester.ignoredClassName
} : {};
var decoration = Decoration.inline(from, to, _objectSpread({
nodeName: suggester.ignoredTag
}, attributes), {
name,
specific,
char: suggester.char
});
_classPrivateFieldSet(this, _ignored, _classPrivateFieldGet(this, _ignored).add(this.view.state.doc, [decoration]));
const offset = isString3(suggester.char) ? suggester.char.length : 1;
const to = from + offset;
const attributes = suggester.ignoredClassName ? { class: suggester.ignoredClassName } : {};
const decoration = Decoration.inline(
from,
to,
__spreadValues({ nodeName: suggester.ignoredTag }, attributes),
{ name, specific, char: suggester.char }
);
__privateSet(this, _ignored, __privateGet(this, _ignored).add(this.view.state.doc, [decoration]));
});

@@ -771,15 +615,13 @@ /**

*/
_defineProperty(this, "removeIgnored", _ref3 => {
var from = _ref3.from,
name = _ref3.name;
var suggester = _classPrivateFieldGet(this, _suggesters).find(value => value.name === name);
__publicField(this, "removeIgnored", ({ from, name }) => {
const suggester = __privateGet(this, _suggesters).find((value) => value.name === name);
if (!suggester) {
throw new Error("No suggester exists for the name provided: ".concat(name));
}
var offset = isString3(suggester.char) ? suggester.char.length : 1;
var decoration = _classPrivateFieldGet(this, _ignored).find(from, from + offset)[0];
const offset = isString3(suggester.char) ? suggester.char.length : 1;
const decoration = __privateGet(this, _ignored).find(from, from + offset)[0];
if (!decoration || decoration.spec.name !== name) {
return;
}
_classPrivateFieldSet(this, _ignored, _classPrivateFieldGet(this, _ignored).remove([decoration]));
__privateSet(this, _ignored, __privateGet(this, _ignored).remove([decoration]));
});

@@ -790,13 +632,10 @@ /**

*/
_defineProperty(this, "clearIgnored", name => {
__publicField(this, "clearIgnored", (name) => {
if (!name) {
_classPrivateFieldSet(this, _ignored, DecorationSet.empty);
__privateSet(this, _ignored, DecorationSet.empty);
return;
}
var decorations = _classPrivateFieldGet(this, _ignored).find();
var decorationsToClear = decorations.filter(_ref4 => {
var spec = _ref4.spec;
return spec.name === name;
});
_classPrivateFieldSet(this, _ignored, _classPrivateFieldGet(this, _ignored).remove(decorationsToClear));
const decorations = __privateGet(this, _ignored).find();
const decorationsToClear = decorations.filter(({ spec }) => spec.name === name);
__privateSet(this, _ignored, __privateGet(this, _ignored).remove(decorationsToClear));
});

@@ -807,10 +646,5 @@ /**

*/
_defineProperty(this, "findMatchAtPosition", ($pos, name) => {
var suggesters = name ? _classPrivateFieldGet(this, _suggesters).filter(suggester => suggester.name === name) : _classPrivateFieldGet(this, _suggesters);
return findFromSuggesters({
suggesters,
$pos,
docChanged: false,
selectionEmpty: true
});
__publicField(this, "findMatchAtPosition", ($pos, name) => {
const suggesters = name ? __privateGet(this, _suggesters).filter((suggester) => suggester.name === name) : __privateGet(this, _suggesters);
return findFromSuggesters({ suggesters, $pos, docChanged: false, selectionEmpty: true });
});

@@ -822,10 +656,41 @@ /**

*/
_defineProperty(this, "setLastChangeFromAppend", () => {
_classPrivateFieldSet(this, _lastChangeFromAppend, true);
__publicField(this, "setLastChangeFromAppend", () => {
__privateSet(this, _lastChangeFromAppend, true);
});
var mapper = createSuggesterMapper();
_classPrivateFieldSet(this, _suggesters, _suggesters2.map(mapper));
_classPrivateFieldSet(this, _suggesters, sort(_classPrivateFieldGet(this, _suggesters), (a, b) => b.priority - a.priority));
const mapper = createSuggesterMapper();
__privateSet(this, _suggesters, suggesters.map(mapper));
__privateSet(this, _suggesters, sort(__privateGet(this, _suggesters), (a, b) => b.priority - a.priority));
}
/**
* Create an instance of the SuggestState class.
*/
static create(suggesters) {
return new _SuggestState(suggesters);
}
/**
* The set of all decorations.
*/
get decorationSet() {
return __privateGet(this, _ignored);
}
/**
* True when the most recent change was to remove a mention.
*
* @remarks
*
* This is needed because sometimes removing a prosemirror `Mark` has no
* effect. Hence we need to keep track of whether it's removed and then later
* in the apply step check that a removal has happened and reset the
* `handlerMatches` to prevent an infinite loop.
*/
get removed() {
return __privateGet(this, _removed);
}
/**
* Returns the current active suggester state field if one exists
*/
get match() {
return __privateGet(this, _next) ? __privateGet(this, _next) : __privateGet(this, _prev) && __privateGet(this, _handlerMatches).exit ? __privateGet(this, _prev) : void 0;
}
/**
* Initialize the SuggestState with a view which is stored for use later.

@@ -841,6 +706,4 @@ */

createProps(match) {
var _match$suggester = match.suggester,
name = _match$suggester.name,
char = _match$suggester.char;
return _objectSpread({
const { name, char } = match.suggester;
return __spreadValues({
view: this.view,

@@ -859,4 +722,4 @@ addIgnored: this.addIgnored,

shouldRunExit() {
if (_classPrivateFieldGet(this, _ignoreNextExit)) {
_classPrivateFieldSet(this, _ignoreNextExit, false);
if (__privateGet(this, _ignoreNextExit)) {
__privateSet(this, _ignoreNextExit, false);
return false;

@@ -874,23 +737,11 @@ }

updateWithNextSelection(tr) {
var nextSelection = this.findNextTextSelection(tr.selection);
var _a, _b, _c;
const nextSelection = this.findNextTextSelection(tr.selection);
if (!nextSelection) {
return;
}
var _iterator2 = _createForOfIteratorHelper(_classPrivateFieldGet(this, _suggesters)),
_step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
var _classPrivateFieldGet2, _classPrivateFieldGet3, _suggester$checkNextV;
var suggester = _step2.value;
var change = (_classPrivateFieldGet2 = _classPrivateFieldGet(this, _handlerMatches).change) === null || _classPrivateFieldGet2 === void 0 ? void 0 : _classPrivateFieldGet2.suggester.name;
var exit = (_classPrivateFieldGet3 = _classPrivateFieldGet(this, _handlerMatches).exit) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.suggester.name;
(_suggester$checkNextV = suggester.checkNextValidSelection) === null || _suggester$checkNextV === void 0 ? void 0 : _suggester$checkNextV.call(suggester, nextSelection.$from, tr, {
change,
exit
});
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
for (const suggester of __privateGet(this, _suggesters)) {
const change = (_a = __privateGet(this, _handlerMatches).change) == null ? void 0 : _a.suggester.name;
const exit = (_b = __privateGet(this, _handlerMatches).exit) == null ? void 0 : _b.suggester.name;
(_c = suggester.checkNextValidSelection) == null ? void 0 : _c.call(suggester, nextSelection.$from, tr, { change, exit });
}

@@ -904,21 +755,16 @@ }

changeHandler(tr, appendTransaction) {
var _classPrivateFieldGet4 = _classPrivateFieldGet(this, _handlerMatches),
change = _classPrivateFieldGet4.change,
exit = _classPrivateFieldGet4.exit;
var match = this.match;
const { change, exit } = __privateGet(this, _handlerMatches);
const match = this.match;
if (!change && !exit || !isValidMatch(match)) {
return;
}
var shouldRunExit = appendTransaction === (exit === null || exit === void 0 ? void 0 : exit.suggester.appendTransaction) && this.shouldRunExit();
var shouldRunChange = appendTransaction === (change === null || change === void 0 ? void 0 : change.suggester.appendTransaction);
const shouldRunExit = appendTransaction === (exit == null ? void 0 : exit.suggester.appendTransaction) && this.shouldRunExit();
const shouldRunChange = appendTransaction === (change == null ? void 0 : change.suggester.appendTransaction);
if (!shouldRunExit && !shouldRunChange) {
return;
}
if (change && exit && isJumpReason({
change,
exit
})) {
var exitDetails = this.createProps(exit);
var changeDetails = this.createProps(change);
var movedForwards = exit.range.from < change.range.from;
if (change && exit && isJumpReason({ change, exit })) {
const exitDetails = this.createProps(exit);
const changeDetails = this.createProps(change);
const movedForwards = exit.range.from < change.range.from;
if (movedForwards) {

@@ -932,3 +778,3 @@ shouldRunExit && exit.suggester.onChange(exitDetails, tr);

if (shouldRunExit) {
_classPrivateFieldSet(this, _removed, false);
__privateSet(this, _removed, false);
}

@@ -942,5 +788,5 @@ return;

exit.suggester.onChange(this.createProps(exit), tr);
_classPrivateFieldSet(this, _removed, false);
__privateSet(this, _removed, false);
if (isInvalidSplitReason(exit.exitReason)) {
_classPrivateFieldSet(this, _handlerMatches, object2());
__privateSet(this, _handlerMatches, object2());
}

@@ -955,9 +801,6 @@ }

mapIgnoredDecorations(tr) {
var ignored = _classPrivateFieldGet(this, _ignored).map(tr.mapping, tr.doc);
var decorations = ignored.find();
var invalid = decorations.filter(_ref5 => {
var from = _ref5.from,
to = _ref5.to,
spec = _ref5.spec;
var charLength = isString3(spec.char) ? spec.char.length : 1;
const ignored = __privateGet(this, _ignored).map(tr.mapping, tr.doc);
const decorations = ignored.find();
const invalid = decorations.filter(({ from, to, spec }) => {
const charLength = isString3(spec.char) ? spec.char.length : 1;
if (to - from !== charLength) {

@@ -968,3 +811,3 @@ return true;

});
_classPrivateFieldSet(this, _ignored, ignored.remove(invalid));
__privateSet(this, _ignored, ignored.remove(invalid));
}

@@ -977,9 +820,5 @@ /**

*/
shouldIgnoreMatch(_ref6) {
var range2 = _ref6.range,
name = _ref6.suggester.name;
var decorations = _classPrivateFieldGet(this, _ignored).find();
var shouldIgnore = decorations.some(_ref7 => {
var spec = _ref7.spec,
from = _ref7.from;
shouldIgnoreMatch({ range: range2, suggester: { name } }) {
const decorations = __privateGet(this, _ignored).find();
const shouldIgnore = decorations.some(({ spec, from }) => {
if (from !== range2.from) {

@@ -996,6 +835,6 @@ return false;

resetState() {
_classPrivateFieldSet(this, _handlerMatches, object2());
_classPrivateFieldSet(this, _next, void 0);
_classPrivateFieldSet(this, _removed, false);
_classPrivateFieldSet(this, _lastChangeFromAppend, false);
__privateSet(this, _handlerMatches, object2());
__privateSet(this, _next, void 0);
__privateSet(this, _removed, false);
__privateSet(this, _lastChangeFromAppend, false);
}

@@ -1006,20 +845,9 @@ /**

updateReasons(props) {
var $pos = props.$pos,
state = props.state;
var docChanged = _classPrivateFieldGet(this, _docChanged);
var suggesters = _classPrivateFieldGet(this, _suggesters);
var selectionEmpty = state.selection.empty;
var match = isTextSelection(state.selection) ? findFromSuggesters({
suggesters,
$pos,
docChanged,
selectionEmpty
}) : void 0;
_classPrivateFieldSet(this, _next, match && this.shouldIgnoreMatch(match) ? void 0 : match);
_classPrivateFieldSet(this, _handlerMatches, findReason({
next: _classPrivateFieldGet(this, _next),
prev: _classPrivateFieldGet(this, _prev),
state,
$pos
}));
const { $pos, state } = props;
const docChanged = __privateGet(this, _docChanged);
const suggesters = __privateGet(this, _suggesters);
const selectionEmpty = state.selection.empty;
const match = isTextSelection(state.selection) ? findFromSuggesters({ suggesters, $pos, docChanged, selectionEmpty }) : void 0;
__privateSet(this, _next, match && this.shouldIgnoreMatch(match) ? void 0 : match);
__privateSet(this, _handlerMatches, findReason({ next: __privateGet(this, _next), prev: __privateGet(this, _prev), state, $pos }));
}

@@ -1030,9 +858,11 @@ /**

addSuggester(suggester) {
var previous = _classPrivateFieldGet(this, _suggesters).find(item => item.name === suggester.name);
var mapper = createSuggesterMapper();
const previous = __privateGet(this, _suggesters).find((item) => item.name === suggester.name);
const mapper = createSuggesterMapper();
if (previous) {
_classPrivateFieldSet(this, _suggesters, _classPrivateFieldGet(this, _suggesters).map(item => item === previous ? mapper(suggester) : item));
__privateSet(this, _suggesters, __privateGet(this, _suggesters).map(
(item) => item === previous ? mapper(suggester) : item
));
} else {
var suggesters = [..._classPrivateFieldGet(this, _suggesters), mapper(suggester)];
_classPrivateFieldSet(this, _suggesters, sort(suggesters, (a, b) => b.priority - a.priority));
const suggesters = [...__privateGet(this, _suggesters), mapper(suggester)];
__privateSet(this, _suggesters, sort(suggesters, (a, b) => b.priority - a.priority));
}

@@ -1045,4 +875,4 @@ return () => this.removeSuggester(suggester.name);

removeSuggester(suggester) {
var name = isString3(suggester) ? suggester : suggester.name;
_classPrivateFieldSet(this, _suggesters, _classPrivateFieldGet(this, _suggesters).filter(item => item.name !== name));
const name = isString3(suggester) ? suggester : suggester.name;
__privateSet(this, _suggesters, __privateGet(this, _suggesters).filter((item) => item.name !== name));
this.clearIgnored(name);

@@ -1059,19 +889,16 @@ }

apply(props) {
var _classPrivateFieldGet5 = _classPrivateFieldGet(this, _handlerMatches),
exit = _classPrivateFieldGet5.exit,
change = _classPrivateFieldGet5.change;
if (_classPrivateFieldGet(this, _lastChangeFromAppend)) {
_classPrivateFieldSet(this, _lastChangeFromAppend, false);
if (!(exit !== null && exit !== void 0 && exit.suggester.appendTransaction) && !(change !== null && change !== void 0 && change.suggester.appendTransaction)) {
const { exit, change } = __privateGet(this, _handlerMatches);
if (__privateGet(this, _lastChangeFromAppend)) {
__privateSet(this, _lastChangeFromAppend, false);
if (!(exit == null ? void 0 : exit.suggester.appendTransaction) && !(change == null ? void 0 : change.suggester.appendTransaction)) {
return this;
}
}
var tr = props.tr,
state = props.state;
var transactionHasChanged = tr.docChanged || tr.selectionSet;
var shouldIgnoreUpdate = tr.getMeta(IGNORE_SUGGEST_META_KEY);
if (shouldIgnoreUpdate || !transactionHasChanged && !_classPrivateFieldGet(this, _removed)) {
const { tr, state } = props;
const transactionHasChanged = tr.docChanged || tr.selectionSet;
const shouldIgnoreUpdate = tr.getMeta(IGNORE_SUGGEST_META_KEY);
if (shouldIgnoreUpdate || !transactionHasChanged && !__privateGet(this, _removed)) {
return this;
}
_classPrivateFieldSet(this, _docChanged, tr.docChanged);
__privateSet(this, _docChanged, tr.docChanged);
this.mapIgnoredDecorations(tr);

@@ -1081,7 +908,4 @@ if (exit) {

}
_classPrivateFieldSet(this, _prev, _classPrivateFieldGet(this, _next));
this.updateReasons({
$pos: tr.selection.$from,
state
});
__privateSet(this, _prev, __privateGet(this, _next));
this.updateReasons({ $pos: tr.selection.$from, state });
return this;

@@ -1094,33 +918,46 @@ }

createDecorations(state) {
var match = this.match;
const match = this.match;
if (!isValidMatch(match)) {
return _classPrivateFieldGet(this, _ignored);
return __privateGet(this, _ignored);
}
var disableDecorations = match.suggester.disableDecorations;
var shouldSkip = isFunction(disableDecorations) ? disableDecorations(state, match) : disableDecorations;
const { disableDecorations } = match.suggester;
const shouldSkip = isFunction(disableDecorations) ? disableDecorations(state, match) : disableDecorations;
if (shouldSkip) {
return _classPrivateFieldGet(this, _ignored);
return __privateGet(this, _ignored);
}
var range2 = match.range,
suggester = match.suggester;
var name = suggester.name,
suggestTag = suggester.suggestTag,
suggestClassName = suggester.suggestClassName;
var from = range2.from,
to = range2.to;
return this.shouldIgnoreMatch(match) ? _classPrivateFieldGet(this, _ignored) : _classPrivateFieldGet(this, _ignored).add(state.doc, [Decoration.inline(from, to, {
nodeName: suggestTag,
class: name ? "".concat(suggestClassName, " suggest-").concat(name) : suggestClassName
}, {
name
})]);
const { range: range2, suggester } = match;
const { name, suggestTag, suggestClassName } = suggester;
const { from, to } = range2;
return this.shouldIgnoreMatch(match) ? __privateGet(this, _ignored) : __privateGet(this, _ignored).add(state.doc, [
Decoration.inline(
from,
to,
{
nodeName: suggestTag,
class: name ? "".concat(suggestClassName, " suggest-").concat(name) : suggestClassName
},
{ name }
)
]);
}
});
};
_docChanged = new WeakMap();
_ignoreNextExit = new WeakMap();
_suggesters = new WeakMap();
_next = new WeakMap();
_prev = new WeakMap();
_handlerMatches = new WeakMap();
_ignored = new WeakMap();
_removed = new WeakMap();
_lastChangeFromAppend = new WeakMap();
var SuggestState = _SuggestState;
function createSuggesterMapper() {
var names = /* @__PURE__ */new Set();
return suggester => {
const names = /* @__PURE__ */ new Set();
return (suggester) => {
if (names.has(suggester.name)) {
throw new Error("A suggester already exists with the name '".concat(suggester.name, "'. The name provided must be unique."));
throw new Error(
"A suggester already exists with the name '".concat(suggester.name, "'. The name provided must be unique.")
);
}
var suggesterWithDefaults = _objectSpread(_objectSpread({}, DEFAULT_SUGGESTER), suggester);
const suggesterWithDefaults = __spreadValues(__spreadValues({}, DEFAULT_SUGGESTER), suggester);
names.add(suggester.name);

@@ -1145,14 +982,11 @@ return suggesterWithDefaults;

}
function suggest() {
for (var _len = arguments.length, suggesters = new Array(_len), _key = 0; _key < _len; _key++) {
suggesters[_key] = arguments[_key];
}
var pluginState = SuggestState.create(suggesters);
function suggest(...suggesters) {
const pluginState = SuggestState.create(suggesters);
return new Plugin({
key: suggestPluginKey,
// Handle the plugin view
view: _view => {
pluginState.init(_view);
view: (view) => {
pluginState.init(view);
return {
update: view2 => pluginState.changeHandler(view2.state.tr, false)
update: (view2) => pluginState.changeHandler(view2.state.tr, false)
};

@@ -1164,10 +998,7 @@ },

// Apply changes to the state
apply: (tr, _pluginState, _oldState, state) => pluginState.apply({
tr,
state
})
apply: (tr, _pluginState, _oldState, state) => pluginState.apply({ tr, state })
},
/** Append a transaction via the onChange handlers */
appendTransaction: (_, __, state) => {
var tr = state.tr;
const tr = state.tr;
pluginState.updateWithNextSelection(tr);

@@ -1184,6 +1015,32 @@ pluginState.changeHandler(tr, true);

// decoration
decorations: state => pluginState.createDecorations(state)
decorations: (state) => pluginState.createDecorations(state)
}
});
}
export { ChangeReason, DEFAULT_SUGGESTER, ExitReason, IGNORE_SUGGEST_META_KEY, addSuggester, createRegexFromSuggester, findFromSuggesters, getSuggestPluginState, getSuggesterWithDefaults, ignoreUpdateForSuggest, isChangeReason, isExitReason, isInvalidSplitReason, isJumpReason, isRemovedReason, isSelectionChangeReason, isSelectionExitReason, isSplitReason, isValidMatch, markActiveInRange, positionHasMarks, rangeHasMarks, removeSuggester, selectionOutsideMatch, suggest };
export {
ChangeReason,
DEFAULT_SUGGESTER,
ExitReason,
IGNORE_SUGGEST_META_KEY,
addSuggester,
createRegexFromSuggester,
findFromSuggesters,
getSuggestPluginState,
getSuggesterWithDefaults,
ignoreUpdateForSuggest,
isChangeReason,
isExitReason,
isInvalidSplitReason,
isJumpReason,
isRemovedReason,
isSelectionChangeReason,
isSelectionExitReason,
isSplitReason,
isValidMatch,
markActiveInRange,
positionHasMarks,
rangeHasMarks,
removeSuggester,
selectionOutsideMatch,
suggest
};
{
"name": "prosemirror-suggest",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"description": "Primitives for building your prosemirror suggestion and autocomplete functionality",

@@ -34,17 +34,17 @@ "homepage": "https://github.com/remirror/remirror/tree/HEAD/packages/prosemirror-suggest",

"@babel/runtime": "^7.22.3",
"@remirror/core-constants": "3.0.0-beta.2",
"@remirror/core-helpers": "4.0.0-beta.2",
"@remirror/types": "2.0.0-beta.2",
"@remirror/core-constants": "3.0.0-beta.3",
"@remirror/core-helpers": "4.0.0-beta.3",
"@remirror/types": "2.0.0-beta.3",
"escape-string-regexp": "^4.0.0"
},
"devDependencies": {
"@remirror/cli": "1.0.1",
"prosemirror-model": "^1.19.3",
"@remirror/cli": "1.1.0-beta.0",
"prosemirror-model": "^1.22.1",
"prosemirror-state": "^1.4.3",
"prosemirror-view": "^1.32.3"
"prosemirror-view": "^1.33.8"
},
"peerDependencies": {
"prosemirror-model": "^1.19.0",
"prosemirror-model": "^1.22.1",
"prosemirror-state": "^1.4.2",
"prosemirror-view": "^1.32.3"
"prosemirror-view": "^1.33.8"
},

@@ -51,0 +51,0 @@ "peerDependenciesMeta": {},

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