@livepreso/react-plugin-textfield 0.2.1 → 0.2.2

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,18 @@
1
1
  {
2
2
  "name": "@livepreso/react-plugin-textfield",
3
3
  "entries": [
4
+ {
5
+ "version": "0.2.2",
6
+ "tag": "@livepreso/react-plugin-textfield_v0.2.2",
7
+ "date": "Tue, 25 Nov 2025 00:07:07 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Change reserveWhitespace to \"true\" to keep token's trailing whitespace, but trim whitespace between paragraphs in Strategy Recs. Add contenteditable: false to Token when not burst. Add leading space to @ when using the token button (when required)."
12
+ }
13
+ ]
14
+ }
15
+ },
4
16
  {
5
17
  "version": "0.2.1",
6
18
  "tag": "@livepreso/react-plugin-textfield_v0.2.1",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @livepreso/react-plugin-textfield
2
2
 
3
- This log was last generated on Sun, 23 Nov 2025 23:46:44 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 25 Nov 2025 00:07:07 GMT and should not be manually modified.
4
+
5
+ ## 0.2.2
6
+ Tue, 25 Nov 2025 00:07:07 GMT
7
+
8
+ ### Patches
9
+
10
+ - Change reserveWhitespace to "true" to keep token's trailing whitespace, but trim whitespace between paragraphs in Strategy Recs. Add contenteditable: false to Token when not burst. Add leading space to @ when using the token button (when required).
4
11
 
5
12
  ## 0.2.1
6
13
  Sun, 23 Nov 2025 23:46:44 GMT
@@ -102,6 +102,7 @@ const TokenBase = Mention.extend({
102
102
 
103
103
  const editableNode = document.createElement("span");
104
104
  editableNode.setAttribute("contenteditable", options.fieldIsEditable);
105
+ tokenDOM.setAttribute("contenteditable", false);
105
106
 
106
107
  const dom = options.burstOnCreate ? editableNode : tokenDOM;
107
108
  const contentDOM = dom.appendChild(document.createTextNode(content));
@@ -293,8 +293,27 @@ const insertTokenButton = ({ tokens = [] }) =>
293
293
  icon: <icons.WandStars />,
294
294
  // Token extension is always enabled, so nothing to load here
295
295
  extensions: [],
296
- command: (editor) =>
297
- editor.chain().focus().insertContent(TOKEN_TRIGGER_CHAR).run(),
296
+ command: (editor) => {
297
+ const { $from } = editor.view.state.selection;
298
+ const prevPos = $from.pos - 1;
299
+
300
+ let tokenTriggerStr = TOKEN_TRIGGER_CHAR;
301
+
302
+ // Add a space before the token trigger if necessary.
303
+ // Without a leading space the token functionality won't run.
304
+ if (prevPos && editor.view.state.doc.nodeAt(prevPos)) {
305
+ const charBefore = editor.view.state.doc.textBetween(
306
+ prevPos,
307
+ $from.pos,
308
+ );
309
+
310
+ if (charBefore !== " ") {
311
+ tokenTriggerStr = ` ${TOKEN_TRIGGER_CHAR}`;
312
+ }
313
+ }
314
+
315
+ return editor.chain().focus().insertContent(tokenTriggerStr).run();
316
+ },
298
317
  }
299
318
  : null;
300
319
 
package/index.js CHANGED
@@ -157,7 +157,7 @@ function EditableTextField({
157
157
  onUpdate: debounce(({ editor }) => {
158
158
  onChange?.(editor.getHTML());
159
159
  }, 100),
160
- parseOptions: { preserveWhitespace: "full" },
160
+ parseOptions: { preserveWhitespace: true },
161
161
  });
162
162
 
163
163
  const { refs } = useFloating({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livepreso/react-plugin-textfield",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {