How to use the @remirror/core-utils.getPluginState function in @remirror/core-utils

To help you get started, we’ve selected a few @remirror/core-utils 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 / core-extensions / src / extensions / composition / composition-plugin.ts View on Github external
view: view => {
      getPluginState(ctx.pluginKey, view.state).init(view);
      return {};
    },
    props: {
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / composition / composition-plugin.ts View on Github external
appendTransaction: (transactions, _b, state) => {
      return getPluginState(ctx.pluginKey, state).appendTransaction(transactions);
    },
    state: {
github ifiokjr / remirror / packages / prosemirror-suggest / src / suggest-plugin.ts View on Github external
export const getSuggestPluginState = (state: EditorState) =>
  getPluginState(suggestPluginKey, state);
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / position-tracker-extension.ts View on Github external
findPositionTracker: (id: unknown) => {
        const decorations = getPluginState(this.pluginKey, getState());
        const found = decorations.find(undefined, undefined, spec => spec.id === id);

        return found.length ? found[0].from : undefined;
      },
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / node-cursor-extension.ts View on Github external
decorations(state: EditorState) {
        const { doc } = state;
        const positions = getPluginState(ctx.pluginKey, state);

        if (positions?.length) {
          const decorations = positions.map(position => {
            const node = document.createElement('span');
            node.appendChild(document.createTextNode(ZERO_WIDTH_SPACE_CHAR));
            return Decoration.widget(position, node, {
              raw: true,
              side: -1,
            } as any);
          });
          return DecorationSet.create(doc, decorations);
        }

        return null;
      },
    },
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / composition / composition-plugin.ts View on Github external
beforeinput: (view, ev: Event) => {
          const event = Cast(ev);
          if (event.inputType === 'deleteContentBackward' && isAndroidOS()) {
            const pluginState = getPluginState(ctx.pluginKey, view.state);
            pluginState.startDelete();
            return patchDeleteContentBackward(ctx.options, view, event, pluginState);
          }
          return true;
        },
      },
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / position-tracker-extension.ts View on Github external
clearPositionTrackers: (tr: Transaction = getState().tr) => {
        const positionTrackerState = getPluginState(this.pluginKey, getState());

        if (positionTrackerState === DecorationSet.empty) {
          return;
        }

        return tr.setMeta(this.pluginKey, { clear: CLEAR });
      },
github ifiokjr / remirror / @remirror / core / src / extension-manager.ts View on Github external
public getPluginState(name: this['_N']): GState {
    this.checkInitialized();
    const key = this.pluginKeys[name];
    if (!key) {
      throw new Error(`Cannot retrieve state for an extension: ${name} which doesn't exist`);
    }
    return getPluginState(key, this.getState());
  }
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / placeholder / placeholder-plugin.ts View on Github external
const createDecorationSet = ({ extension, state }: SharedParams) => {
  const { empty } = getPluginState(extension.pluginKey, state);
  const { emptyNodeClass, placeholder } = extension.options;

  if (!empty) {
    return;
  }
  const decorations: Decoration[] = [];
  state.doc.descendants((node, pos) => {
    const decoration = Decoration.node(pos, pos + node.nodeSize, {
      class: emptyNodeClass,
      'data-placeholder': placeholder,
    });
    decorations.push(decoration);
  });

  return DecorationSet.create(state.doc, decorations);
};