@tiptap/extension-character-count 2.0.0-beta.21 → 2.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packages/extension-character-count/src/character-count.d.ts +2 -2
- package/dist/tiptap-extension-character-count.cjs.js +5 -6
- package/dist/tiptap-extension-character-count.cjs.js.map +1 -1
- package/dist/tiptap-extension-character-count.esm.js +5 -6
- package/dist/tiptap-extension-character-count.esm.js.map +1 -1
- package/dist/tiptap-extension-character-count.umd.js +5 -6
- package/dist/tiptap-extension-character-count.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/character-count.ts +7 -7
|
@@ -5292,8 +5292,8 @@ const CharacterCount = Extension.create({
|
|
|
5292
5292
|
},
|
|
5293
5293
|
addStorage() {
|
|
5294
5294
|
return {
|
|
5295
|
-
characters:
|
|
5296
|
-
words:
|
|
5295
|
+
characters: () => 0,
|
|
5296
|
+
words: () => 0,
|
|
5297
5297
|
};
|
|
5298
5298
|
},
|
|
5299
5299
|
onBeforeCreate() {
|
|
@@ -5320,14 +5320,13 @@ const CharacterCount = Extension.create({
|
|
|
5320
5320
|
new Plugin({
|
|
5321
5321
|
key: new PluginKey('characterCount'),
|
|
5322
5322
|
filterTransaction: (transaction, state) => {
|
|
5323
|
-
var _a, _b, _c, _d, _e, _f;
|
|
5324
5323
|
const limit = this.options.limit;
|
|
5325
5324
|
// Nothing has changed or no limit is defined. Ignore it.
|
|
5326
5325
|
if (!transaction.docChanged || limit === 0) {
|
|
5327
5326
|
return true;
|
|
5328
5327
|
}
|
|
5329
|
-
const oldSize =
|
|
5330
|
-
const newSize =
|
|
5328
|
+
const oldSize = this.storage.characters({ node: state.doc });
|
|
5329
|
+
const newSize = this.storage.characters({ node: transaction.doc });
|
|
5331
5330
|
// Everything is in the limit. Good.
|
|
5332
5331
|
if (newSize <= limit) {
|
|
5333
5332
|
return true;
|
|
@@ -5357,7 +5356,7 @@ const CharacterCount = Extension.create({
|
|
|
5357
5356
|
// This happens e.g. when truncating within a complex node (e.g. table)
|
|
5358
5357
|
// and ProseMirror has to close this node again.
|
|
5359
5358
|
// If this is the case, we prevent the transaction completely.
|
|
5360
|
-
const updatedSize =
|
|
5359
|
+
const updatedSize = this.storage.characters({ node: transaction.doc });
|
|
5361
5360
|
if (updatedSize > limit) {
|
|
5362
5361
|
return false;
|
|
5363
5362
|
}
|