@lobehub/editor 1.17.1 → 1.17.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.
|
@@ -130,16 +130,35 @@ export var MarkdownPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
130
130
|
|
|
131
131
|
// If there's no text content, let Lexical handle it
|
|
132
132
|
if (!text) return false;
|
|
133
|
-
|
|
134
|
-
// Check if markdown paste formatting is enabled (default: true)
|
|
135
|
-
var enablePasteMarkdown = (_this2$config$enableP = (_this2$config = _this2.config) === null || _this2$config === void 0 ? void 0 : _this2$config.enablePasteMarkdown) !== null && _this2$config$enableP !== void 0 ? _this2$config$enableP : true;
|
|
136
133
|
_this2.logger.debug('paste content analysis:', {
|
|
137
|
-
|
|
134
|
+
clipboardTypes: Array.from(clipboardData.types || []),
|
|
138
135
|
hasHTML: !!(html && html.trim()),
|
|
139
|
-
|
|
136
|
+
htmlLength: (html === null || html === void 0 ? void 0 : html.length) || 0,
|
|
137
|
+
textLength: text.length
|
|
140
138
|
});
|
|
141
139
|
|
|
142
|
-
//
|
|
140
|
+
// Check if this is likely a rich-text paste from the editor or other rich editor
|
|
141
|
+
// Rich text pastes typically have HTML that's more complex than just wrapping text
|
|
142
|
+
if (html && html.trim()) {
|
|
143
|
+
var htmlDoc = new DOMParser().parseFromString(html, 'text/html');
|
|
144
|
+
var hasRichContent =
|
|
145
|
+
// Has block elements (p, div, h1-h6, etc.)
|
|
146
|
+
htmlDoc.querySelectorAll('p, div, h1, h2, h3, h4, h5, h6, ul, ol, li, table').length > 0 ||
|
|
147
|
+
// Has inline formatting (strong, em, code, etc.)
|
|
148
|
+
htmlDoc.querySelectorAll('strong, em, b, i, u, code, span[style]').length > 0 ||
|
|
149
|
+
// Has data attributes (often used by editors to store metadata)
|
|
150
|
+
htmlDoc.querySelectorAll('[data-lexical-text], [data-lexical-decorator]').length > 0;
|
|
151
|
+
if (hasRichContent) {
|
|
152
|
+
// This looks like rich content from an editor - let Lexical handle it
|
|
153
|
+
_this2.logger.debug('rich content detected, letting Lexical handle paste');
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Check if markdown paste formatting is enabled (default: true)
|
|
159
|
+
var enablePasteMarkdown = (_this2$config$enableP = (_this2$config = _this2.config) === null || _this2$config === void 0 ? void 0 : _this2$config.enablePasteMarkdown) !== null && _this2$config$enableP !== void 0 ? _this2$config$enableP : true;
|
|
160
|
+
|
|
161
|
+
// Force plain text paste for external content
|
|
143
162
|
event.preventDefault();
|
|
144
163
|
event.stopPropagation();
|
|
145
164
|
editor.update(function () {
|
package/package.json
CHANGED