@livepreso/react-plugin-textfield 0.2.2 → 0.3.0

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/CHANGELOG.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@livepreso/react-plugin-textfield",
3
3
  "entries": [
4
+ {
5
+ "version": "0.3.0",
6
+ "tag": "@livepreso/react-plugin-textfield_v0.3.0",
7
+ "date": "Tue, 25 Nov 2025 06:55:05 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "When Token content renders an empty string, remove the node insted of replacing (text nodes cannot be empty)"
12
+ }
13
+ ],
14
+ "minor": [
15
+ {
16
+ "comment": "Support react 19 as well"
17
+ }
18
+ ],
19
+ "dependency": [
20
+ {
21
+ "comment": "Updating dependency \"@livepreso/content-react\" to `2.1.0`"
22
+ }
23
+ ]
24
+ }
25
+ },
4
26
  {
5
27
  "version": "0.2.2",
6
28
  "tag": "@livepreso/react-plugin-textfield_v0.2.2",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
1
  # Change Log - @livepreso/react-plugin-textfield
2
2
 
3
- This log was last generated on Tue, 25 Nov 2025 00:07:07 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 25 Nov 2025 06:55:05 GMT and should not be manually modified.
4
+
5
+ ## 0.3.0
6
+ Tue, 25 Nov 2025 06:55:05 GMT
7
+
8
+ ### Minor changes
9
+
10
+ - Support react 19 as well
11
+
12
+ ### Patches
13
+
14
+ - When Token content renders an empty string, remove the node insted of replacing (text nodes cannot be empty)
4
15
 
5
16
  ## 0.2.2
6
17
  Tue, 25 Nov 2025 00:07:07 GMT
@@ -37,9 +37,13 @@ export const convertTokensToTextNodes = (editor, options) => {
37
37
  : tokenRender();
38
38
 
39
39
  const endPos = pos + editor.state.doc.nodeAt(pos).nodeSize;
40
- const textNode = editor.state.schema.text(content);
41
40
 
42
- tr.replaceWith(pos, endPos, textNode);
41
+ if (content) {
42
+ const textNode = editor.state.schema.text(content);
43
+ tr.replaceWith(pos, endPos, textNode);
44
+ } else {
45
+ tr.delete(pos, endPos);
46
+ }
43
47
  });
44
48
 
45
49
  editor.view.dispatch(tr);
@@ -98,7 +102,7 @@ const TokenBase = Mention.extend({
98
102
  const content =
99
103
  options.fieldIsEditable && options.usePlaceholder
100
104
  ? tokenSummary
101
- : render();
105
+ : render() || "";
102
106
 
103
107
  const editableNode = document.createElement("span");
104
108
  editableNode.setAttribute("contenteditable", options.fieldIsEditable);
@@ -110,17 +114,25 @@ const TokenBase = Mention.extend({
110
114
  const convertToTextNode = () => {
111
115
  // To reference this specific node in a command, get its position.
112
116
  const pos = getPos();
113
- const endPos = pos + node.nodeSize;
114
-
115
- // convert the node to a text node and insert the content
116
- // replacing the token in the process
117
- editor
118
- .chain()
119
- .focus()
120
- .setNodeSelection(pos)
121
- .insertContentAt({ from: pos, to: endPos }, content)
122
- .toggleNode(NODE_TYPES.TOKEN, "text")
123
- .run();
117
+
118
+ if (pos && editor.state.doc.nodeAt(pos)) {
119
+ const endPos = pos + node.nodeSize;
120
+
121
+ if (content) {
122
+ // convert the node to a text node and insert the content
123
+ // replacing the token in the process
124
+ editor
125
+ .chain()
126
+ .focus()
127
+ .setNodeSelection(pos)
128
+ .insertContentAt({ from: pos, to: endPos }, content)
129
+ .toggleNode(NODE_TYPES.TOKEN, "text")
130
+ .run();
131
+ } else {
132
+ // delete node if no renderable content
133
+ editor.chain().focus().setNodeSelection(pos).deleteNode().run();
134
+ }
135
+ }
124
136
  };
125
137
 
126
138
  // Attach the double-click event listener in all modes where content is available.
@@ -134,10 +146,7 @@ const TokenBase = Mention.extend({
134
146
  if (options.burstOnCreate) {
135
147
  // this will be run, once, after the node is created
136
148
  // after which, the Token will no longer exist.
137
- // Only run if currently editing and adding tokens (ie. not on editor load)
138
- if (editor.isFocused) {
139
- setTimeout(() => convertToTextNode(), 50);
140
- }
149
+ setTimeout(() => convertToTextNode(), 50);
141
150
  }
142
151
  return {
143
152
  dom,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livepreso/react-plugin-textfield",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -12,8 +12,8 @@
12
12
  "devDependencies": {
13
13
  "eslint": "~9.15.0",
14
14
  "@babel/preset-react": "~7.25.9",
15
- "react": "18.x",
16
- "react-dom": "18.x",
15
+ "react": "~19.2.0",
16
+ "react-dom": "~19.2.0",
17
17
  "@babel/parser": "^7.26.10",
18
18
  "@babel/traverse": "^7.26.10",
19
19
  "@svgr/core": "^8.1.0",
@@ -21,8 +21,8 @@
21
21
  "@livepreso/eslint-config": "1.0.0"
22
22
  },
23
23
  "peerDependencies": {
24
- "react": "18.x",
25
- "react-dom": "18.x"
24
+ "react": ">= 18.0.0 <= 19",
25
+ "react-dom": ">= 19.0.0 <= 19"
26
26
  },
27
27
  "dependencies": {
28
28
  "@floating-ui/react-dom": "~2.1.6",
@@ -58,7 +58,7 @@
58
58
  "@tiptap/extension-mention": "~3.10.1",
59
59
  "@tiptap/suggestion": "~3.10.1",
60
60
  "fuse.js": "~7.1.0",
61
- "@livepreso/content-react": "2.0.2"
61
+ "@livepreso/content-react": "2.1.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": ""