@lexical/plain-text 0.36.2-nightly.20250930.0 → 0.36.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/LexicalPlainText.dev.js
CHANGED
|
@@ -56,7 +56,7 @@ function onCopyForPlainText(event, editor) {
|
|
|
56
56
|
if (event !== null) {
|
|
57
57
|
const clipboardData = utils.objectKlassEquals(event, KeyboardEvent) ? null : event.clipboardData;
|
|
58
58
|
const selection = lexical.$getSelection();
|
|
59
|
-
if (selection !== null && clipboardData != null) {
|
|
59
|
+
if (selection !== null && !selection.isCollapsed() && clipboardData != null) {
|
|
60
60
|
event.preventDefault();
|
|
61
61
|
const htmlString = clipboard.$getHtmlContent(editor);
|
|
62
62
|
if (htmlString !== null) {
|
package/LexicalPlainText.dev.mjs
CHANGED
|
@@ -54,7 +54,7 @@ function onCopyForPlainText(event, editor) {
|
|
|
54
54
|
if (event !== null) {
|
|
55
55
|
const clipboardData = objectKlassEquals(event, KeyboardEvent) ? null : event.clipboardData;
|
|
56
56
|
const selection = $getSelection();
|
|
57
|
-
if (selection !== null && clipboardData != null) {
|
|
57
|
+
if (selection !== null && !selection.isCollapsed() && clipboardData != null) {
|
|
58
58
|
event.preventDefault();
|
|
59
59
|
const htmlString = $getHtmlContent(editor);
|
|
60
60
|
if (htmlString !== null) {
|
package/LexicalPlainText.prod.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("@lexical/clipboard"),t=require("@lexical/dragon"),n=require("@lexical/selection"),i=require("@lexical/utils"),r=require("lexical");const o="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,a=o&&"documentMode"in document?document.documentMode:null,l=o&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=!(!o||!("InputEvent"in window)||a)&&"getTargetRanges"in new window.InputEvent("input"),c=o&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),R=o&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,O=o&&/^(?=.*Chrome).*/i.test(navigator.userAgent),D=o&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&l&&!O;function M(t,n){n.update((
|
|
9
|
+
"use strict";var e=require("@lexical/clipboard"),t=require("@lexical/dragon"),n=require("@lexical/selection"),i=require("@lexical/utils"),r=require("lexical");const o="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,a=o&&"documentMode"in document?document.documentMode:null,l=o&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=!(!o||!("InputEvent"in window)||a)&&"getTargetRanges"in new window.InputEvent("input"),c=o&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),R=o&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,O=o&&/^(?=.*Chrome).*/i.test(navigator.userAgent),D=o&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&l&&!O;function M(t,n){n.update(()=>{if(null!==t){const o=i.objectKlassEquals(t,KeyboardEvent)?null:t.clipboardData,a=r.$getSelection();if(null!==a&&!a.isCollapsed()&&null!=o){t.preventDefault();const i=e.$getHtmlContent(n);null!==i&&o.setData("text/html",i),o.setData("text/plain",a.getTextContent())}}})}function g(t){const o=i.mergeRegister(t.registerCommand(r.DELETE_CHARACTER_COMMAND,e=>{const t=r.$getSelection();return!!r.$isRangeSelection(t)&&(t.deleteCharacter(e),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.DELETE_WORD_COMMAND,e=>{const t=r.$getSelection();return!!r.$isRangeSelection(t)&&(t.deleteWord(e),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.DELETE_LINE_COMMAND,e=>{const t=r.$getSelection();return!!r.$isRangeSelection(t)&&(t.deleteLine(e),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.CONTROLLED_TEXT_INSERTION_COMMAND,t=>{const n=r.$getSelection();if(!r.$isRangeSelection(n))return!1;if("string"==typeof t)n.insertText(t);else{const i=t.dataTransfer;if(null!=i)e.$insertDataTransferForPlainText(i,n);else{const e=t.data;e&&n.insertText(e)}}return!0},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.REMOVE_TEXT_COMMAND,()=>{const e=r.$getSelection();return!!r.$isRangeSelection(e)&&(e.removeText(),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.INSERT_LINE_BREAK_COMMAND,e=>{const t=r.$getSelection();return!!r.$isRangeSelection(t)&&(t.insertLineBreak(e),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.INSERT_PARAGRAPH_COMMAND,()=>{const e=r.$getSelection();return!!r.$isRangeSelection(e)&&(e.insertLineBreak(),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.KEY_ARROW_LEFT_COMMAND,e=>{const t=r.$getSelection();if(!r.$isRangeSelection(t))return!1;const i=e,o=i.shiftKey;return!!n.$shouldOverrideDefaultCharacterSelection(t,!0)&&(i.preventDefault(),n.$moveCharacter(t,o,!0),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.KEY_ARROW_RIGHT_COMMAND,e=>{const t=r.$getSelection();if(!r.$isRangeSelection(t))return!1;const i=e,o=i.shiftKey;return!!n.$shouldOverrideDefaultCharacterSelection(t,!1)&&(i.preventDefault(),n.$moveCharacter(t,o,!1),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.KEY_BACKSPACE_COMMAND,e=>{const n=r.$getSelection();return!!r.$isRangeSelection(n)&&((!R||"ko-KR"!==navigator.language)&&(e.preventDefault(),t.dispatchCommand(r.DELETE_CHARACTER_COMMAND,!0)))},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.KEY_DELETE_COMMAND,e=>{const n=r.$getSelection();return!!r.$isRangeSelection(n)&&(e.preventDefault(),t.dispatchCommand(r.DELETE_CHARACTER_COMMAND,!1))},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.KEY_ENTER_COMMAND,e=>{const n=r.$getSelection();if(!r.$isRangeSelection(n))return!1;if(null!==e){if((R||c||D)&&s)return!1;e.preventDefault()}return t.dispatchCommand(r.INSERT_LINE_BREAK_COMMAND,!1)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.SELECT_ALL_COMMAND,()=>(r.$selectAll(),!0),r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.COPY_COMMAND,e=>{const n=r.$getSelection();return!!r.$isRangeSelection(n)&&(M(e,t),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.CUT_COMMAND,e=>{const n=r.$getSelection();return!!r.$isRangeSelection(n)&&(function(e,t){M(e,t),t.update(()=>{const e=r.$getSelection();r.$isRangeSelection(e)&&e.removeText()})}(e,t),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.PASTE_COMMAND,n=>{const o=r.$getSelection();return!!r.$isRangeSelection(o)&&(function(t,n){t.preventDefault(),n.update(()=>{const n=r.$getSelection(),o=i.objectKlassEquals(t,ClipboardEvent)?t.clipboardData:null;null!=o&&r.$isRangeSelection(n)&&e.$insertDataTransferForPlainText(o,n)},{tag:r.PASTE_TAG})}(n,t),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.DROP_COMMAND,e=>{const t=r.$getSelection();return!!r.$isRangeSelection(t)&&(e.preventDefault(),!0)},r.COMMAND_PRIORITY_EDITOR),t.registerCommand(r.DRAGSTART_COMMAND,e=>{const t=r.$getSelection();return!!r.$isRangeSelection(t)&&(e.preventDefault(),!0)},r.COMMAND_PRIORITY_EDITOR));return o}const C=r.defineExtension({conflictsWith:["@lexical/rich-text"],dependencies:[t.DragonExtension],name:"@lexical/plain-text",register:g});exports.PlainTextExtension=C,exports.registerPlainText=g;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import{$insertDataTransferForPlainText as e,$getHtmlContent as t}from"@lexical/clipboard";import{DragonExtension as n}from"@lexical/dragon";import{$shouldOverrideDefaultCharacterSelection as r,$moveCharacter as o}from"@lexical/selection";import{mergeRegister as i,objectKlassEquals as a}from"@lexical/utils";import{defineExtension as s,DELETE_CHARACTER_COMMAND as
|
|
9
|
+
import{$insertDataTransferForPlainText as e,$getHtmlContent as t}from"@lexical/clipboard";import{DragonExtension as n}from"@lexical/dragon";import{$shouldOverrideDefaultCharacterSelection as r,$moveCharacter as o}from"@lexical/selection";import{mergeRegister as i,objectKlassEquals as a}from"@lexical/utils";import{defineExtension as s,DELETE_CHARACTER_COMMAND as d,$getSelection as m,$isRangeSelection as u,COMMAND_PRIORITY_EDITOR as l,DELETE_WORD_COMMAND as c,DELETE_LINE_COMMAND as g,CONTROLLED_TEXT_INSERTION_COMMAND as f,REMOVE_TEXT_COMMAND as p,INSERT_LINE_BREAK_COMMAND as C,INSERT_PARAGRAPH_COMMAND as v,KEY_ARROW_LEFT_COMMAND as x,KEY_ARROW_RIGHT_COMMAND as w,KEY_BACKSPACE_COMMAND as D,KEY_DELETE_COMMAND as h,KEY_ENTER_COMMAND as T,SELECT_ALL_COMMAND as b,$selectAll as P,COPY_COMMAND as y,CUT_COMMAND as A,PASTE_COMMAND as E,DROP_COMMAND as K,DRAGSTART_COMMAND as M,PASTE_TAG as k}from"lexical";const L="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,S=L&&"documentMode"in document?document.documentMode:null,W=L&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),B=!(!L||!("InputEvent"in window)||S)&&"getTargetRanges"in new window.InputEvent("input"),I=L&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),R=L&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,V=L&&/^(?=.*Chrome).*/i.test(navigator.userAgent),j=L&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&W&&!V;function q(e,n){n.update(()=>{if(null!==e){const r=a(e,KeyboardEvent)?null:e.clipboardData,o=m();if(null!==o&&!o.isCollapsed()&&null!=r){e.preventDefault();const i=t(n);null!==i&&r.setData("text/html",i),r.setData("text/plain",o.getTextContent())}}})}function z(t){return i(t.registerCommand(d,e=>{const t=m();return!!u(t)&&(t.deleteCharacter(e),!0)},l),t.registerCommand(c,e=>{const t=m();return!!u(t)&&(t.deleteWord(e),!0)},l),t.registerCommand(g,e=>{const t=m();return!!u(t)&&(t.deleteLine(e),!0)},l),t.registerCommand(f,t=>{const n=m();if(!u(n))return!1;if("string"==typeof t)n.insertText(t);else{const r=t.dataTransfer;if(null!=r)e(r,n);else{const e=t.data;e&&n.insertText(e)}}return!0},l),t.registerCommand(p,()=>{const e=m();return!!u(e)&&(e.removeText(),!0)},l),t.registerCommand(C,e=>{const t=m();return!!u(t)&&(t.insertLineBreak(e),!0)},l),t.registerCommand(v,()=>{const e=m();return!!u(e)&&(e.insertLineBreak(),!0)},l),t.registerCommand(x,e=>{const t=m();if(!u(t))return!1;const n=e,i=n.shiftKey;return!!r(t,!0)&&(n.preventDefault(),o(t,i,!0),!0)},l),t.registerCommand(w,e=>{const t=m();if(!u(t))return!1;const n=e,i=n.shiftKey;return!!r(t,!1)&&(n.preventDefault(),o(t,i,!1),!0)},l),t.registerCommand(D,e=>{const n=m();return!!u(n)&&((!R||"ko-KR"!==navigator.language)&&(e.preventDefault(),t.dispatchCommand(d,!0)))},l),t.registerCommand(h,e=>{const n=m();return!!u(n)&&(e.preventDefault(),t.dispatchCommand(d,!1))},l),t.registerCommand(T,e=>{const n=m();if(!u(n))return!1;if(null!==e){if((R||I||j)&&B)return!1;e.preventDefault()}return t.dispatchCommand(C,!1)},l),t.registerCommand(b,()=>(P(),!0),l),t.registerCommand(y,e=>{const n=m();return!!u(n)&&(q(e,t),!0)},l),t.registerCommand(A,e=>{const n=m();return!!u(n)&&(function(e,t){q(e,t),t.update(()=>{const e=m();u(e)&&e.removeText()})}(e,t),!0)},l),t.registerCommand(E,n=>{const r=m();return!!u(r)&&(function(t,n){t.preventDefault(),n.update(()=>{const n=m(),r=a(t,ClipboardEvent)?t.clipboardData:null;null!=r&&u(n)&&e(r,n)},{tag:k})}(n,t),!0)},l),t.registerCommand(K,e=>{const t=m();return!!u(t)&&(e.preventDefault(),!0)},l),t.registerCommand(M,e=>{const t=m();return!!u(t)&&(e.preventDefault(),!0)},l))}const F=s({conflictsWith:["@lexical/rich-text"],dependencies:[n],name:"@lexical/plain-text",register:z});export{F as PlainTextExtension,z as registerPlainText};
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"plain-text"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "0.36.2
|
|
10
|
+
"version": "0.36.2",
|
|
11
11
|
"main": "LexicalPlainText.js",
|
|
12
12
|
"types": "index.d.ts",
|
|
13
13
|
"repository": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@lexical/clipboard": "0.36.2
|
|
39
|
-
"@lexical/dragon": "0.36.2
|
|
40
|
-
"@lexical/selection": "0.36.2
|
|
41
|
-
"@lexical/utils": "0.36.2
|
|
42
|
-
"lexical": "0.36.2
|
|
38
|
+
"@lexical/clipboard": "0.36.2",
|
|
39
|
+
"@lexical/dragon": "0.36.2",
|
|
40
|
+
"@lexical/selection": "0.36.2",
|
|
41
|
+
"@lexical/utils": "0.36.2",
|
|
42
|
+
"lexical": "0.36.2"
|
|
43
43
|
}
|
|
44
44
|
}
|