Sha256: 2f6064662eb31b3739faee8ade9bb521472b8c646a5f32f11bb386b94c83aea1
Contents?: true
Size: 890 Bytes
Versions: 13
Compression:
Stored size: 890 Bytes
Contents
import { Plugin } from "prosemirror-state"; import CharacterCount from "@tiptap/extension-character-count"; /** * Extends the character counter to prevent adding new paragraphs after the * character limit is reached. The original character counter allows that. * * See: https://github.com/ueberdosis/tiptap/issues/3721 */ export default CharacterCount.extend({ addProseMirrorPlugins() { const limit = this.options.limit; const plugins = this.parent?.(); if (limit === 0 || limit === null || !limit) { return plugins; } const { storage } = this.editor; return [ ...plugins, new Plugin({ props: { handleKeyDown(view, event) { if (event.key === "Enter") { return storage.characterCount.characters() >= limit; } return false; } } }) ]; } });
Version data entries
13 entries across 13 versions & 1 rubygems