How to use prosemirror-suggest - 5 common examples

To help you get started, we’ve selected a few prosemirror-suggest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ifiokjr / remirror / @remirror / extension-mention / src / mention-extension.ts View on Github external
range,
          } = match;
          const create = getActions('createMention');
          const update = getActions('updateMention');
          const remove = getActions('removeMention');
          const isActive = isMarkActive({
            from: match.range.from,
            to: match.range.end,
            type: type,

            state: getState(),
          });

          const fn = isActive ? update : create;
          const isSplit = isSplitReason(reason);
          const isInvalid = isInvalidSplitReason(reason);
          const isRemoved = isRemovedReason(reason);

          const removeCommand = () => {
            setMarkRemoved();
            try {
              // This might fail when a deletion has taken place.
              isInvalid ? remove({ range: match.range }) : noop();
            } catch {
              // This sometimes fails and it's best to ignore until more is
              // known about the impact.
            }
          };

          const createCommand = ({
            replacementType = isSplit ? 'partial' : 'full',
            id = match.queryText[replacementType],
github ifiokjr / remirror / @remirror / extension-mention / src / mention-extension.ts View on Github external
} = match;
          const create = getActions('createMention');
          const update = getActions('updateMention');
          const remove = getActions('removeMention');
          const isActive = isMarkActive({
            from: match.range.from,
            to: match.range.end,
            type: type,

            state: getState(),
          });

          const fn = isActive ? update : create;
          const isSplit = isSplitReason(reason);
          const isInvalid = isInvalidSplitReason(reason);
          const isRemoved = isRemovedReason(reason);

          const removeCommand = () => {
            setMarkRemoved();
            try {
              // This might fail when a deletion has taken place.
              isInvalid ? remove({ range: match.range }) : noop();
            } catch {
              // This sometimes fails and it's best to ignore until more is
              // known about the impact.
            }
          };

          const createCommand = ({
            replacementType = isSplit ? 'partial' : 'full',
            id = match.queryText[replacementType],
            label = match.matchText[replacementType],
github ifiokjr / remirror / @remirror / extension-mention / src / mention-extension.ts View on Github external
suggester: { name },
            range,
          } = match;
          const create = getActions('createMention');
          const update = getActions('updateMention');
          const remove = getActions('removeMention');
          const isActive = isMarkActive({
            from: match.range.from,
            to: match.range.end,
            type: type,

            state: getState(),
          });

          const fn = isActive ? update : create;
          const isSplit = isSplitReason(reason);
          const isInvalid = isInvalidSplitReason(reason);
          const isRemoved = isRemovedReason(reason);

          const removeCommand = () => {
            setMarkRemoved();
            try {
              // This might fail when a deletion has taken place.
              isInvalid ? remove({ range: match.range }) : noop();
            } catch {
              // This sometimes fails and it's best to ignore until more is
              // known about the impact.
            }
          };

          const createCommand = ({
            replacementType = isSplit ? 'partial' : 'full',
github ifiokjr / remirror / @remirror / core / src / extension-manager.ts View on Github external
private suggestions() {
    this.checkInitialized();
    const suggestions: Suggester[] = [];

    const extensionSuggesters = this.extensions
      .filter(hasExtensionProperty('suggestions'))
      .filter(extension => !extension.options.exclude.suggestions)
      .map(extensionPropertyMapper('suggestions', this.params));

    extensionSuggesters.forEach(suggester => {
      suggestions.push(...(isArray(suggester) ? suggester : [suggester]));
    });

    return suggest(...suggestions);
  }
github ifiokjr / remirror / @remirror / extension-mention / src / mention-extension.ts View on Github external
return this.options.matchers.map(matcher => {
      const { startOfLine, char, supportedCharacters, name } = {
        ...DEFAULT_MATCHER,
        ...matcher,
      };
      const regexp = new RegExp(
        `(${getRegexPrefix(startOfLine)}${escapeChar(char)}${regexToString(supportedCharacters)})`,
        'g',
      );

      return markPasteRule({
        regexp,
        type,
        getAttrs: str => ({
          id: getMatchString(str.slice(char.length, str.length)),
          label: getMatchString(str),
          name,
        }),
      });
    });
  }

prosemirror-suggest

Primitives for building your prosemirror suggestion and autocomplete functionality

MIT
Latest version published 12 days ago

Package Health Score

89 / 100
Full package analysis

Similar packages