@lobehub/editor 1.5.6 → 1.5.8
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.
|
@@ -202,7 +202,7 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
202
202
|
ctx.appendLine('_');
|
|
203
203
|
}
|
|
204
204
|
if (isUnderline) {
|
|
205
|
-
ctx.appendLine('<
|
|
205
|
+
ctx.appendLine('<ins>');
|
|
206
206
|
}
|
|
207
207
|
var textContent = node.getTextContent();
|
|
208
208
|
var res = textContent.match(/\s+$/);
|
|
@@ -214,7 +214,7 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
214
214
|
var lastChar = append.at(-1);
|
|
215
215
|
ctx.appendLine(append);
|
|
216
216
|
if (isUnderline) {
|
|
217
|
-
ctx.appendLine('</
|
|
217
|
+
ctx.appendLine('</ins>');
|
|
218
218
|
}
|
|
219
219
|
if (isItalic) {
|
|
220
220
|
ctx.appendLine('_');
|
|
@@ -15,6 +15,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
15
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
16
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
|
+
import { COMMAND_PRIORITY_EDITOR, KEY_DOWN_COMMAND } from 'lexical';
|
|
18
19
|
import { Children, memo, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
19
20
|
import { LexicalErrorBoundary } from "../../../editor-kernel/react/LexicalErrorBoundary";
|
|
20
21
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
@@ -96,6 +97,29 @@ var ReactPlainText = /*#__PURE__*/memo(function (_ref) {
|
|
|
96
97
|
onChange === null || onChange === void 0 || onChange(editor);
|
|
97
98
|
});
|
|
98
99
|
}, [editor, type, content, onChange, isInitialized]);
|
|
100
|
+
useEffect(function () {
|
|
101
|
+
if (editor && onPressEnter) {
|
|
102
|
+
return editor.registerHighCommand(KEY_DOWN_COMMAND, function (event) {
|
|
103
|
+
if (event.key === 'Enter' && !event.isComposing && onPressEnter({
|
|
104
|
+
editor: editor,
|
|
105
|
+
event: event
|
|
106
|
+
})) {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
return true; // Indicate that the event has been handled
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//
|
|
112
|
+
if (onKeyDown !== null && onKeyDown !== void 0 && onKeyDown({
|
|
113
|
+
editor: editor,
|
|
114
|
+
event: event
|
|
115
|
+
})) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
return true; // Indicate that the event has been handled
|
|
118
|
+
}
|
|
119
|
+
return false; // Allow other handlers to process the event
|
|
120
|
+
}, COMMAND_PRIORITY_EDITOR);
|
|
121
|
+
}
|
|
122
|
+
}, [editor, onPressEnter, onKeyDown]);
|
|
99
123
|
useEffect(function () {
|
|
100
124
|
if (autoFocus && editorContainerRef.current) {
|
|
101
125
|
editorContainerRef.current.focus();
|
|
@@ -131,22 +155,6 @@ var ReactPlainText = /*#__PURE__*/memo(function (_ref) {
|
|
|
131
155
|
event: event
|
|
132
156
|
});
|
|
133
157
|
};
|
|
134
|
-
var handleKeyDown = function handleKeyDown(event) {
|
|
135
|
-
var isComposing = event.nativeEvent.isComposing;
|
|
136
|
-
if (event.key === 'Enter' && !isComposing &&
|
|
137
|
-
// Regular Enter key handling
|
|
138
|
-
onPressEnter) {
|
|
139
|
-
onPressEnter({
|
|
140
|
-
editor: editor,
|
|
141
|
-
event: event
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
// Call the optional onKeyDown handler
|
|
145
|
-
onKeyDown === null || onKeyDown === void 0 || onKeyDown({
|
|
146
|
-
editor: editor,
|
|
147
|
-
event: event
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
158
|
return /*#__PURE__*/_jsxs("div", {
|
|
151
159
|
className: cx(styles.root, styles.variant, className),
|
|
152
160
|
style: style,
|
|
@@ -157,7 +165,6 @@ var ReactPlainText = /*#__PURE__*/memo(function (_ref) {
|
|
|
157
165
|
onCompositionStart: handleCompositionStart,
|
|
158
166
|
onContextMenu: handleContextMenu,
|
|
159
167
|
onFocus: handleFocus,
|
|
160
|
-
onKeyDown: handleKeyDown,
|
|
161
168
|
ref: editorContainerRef,
|
|
162
169
|
style: {
|
|
163
170
|
outline: 'none'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSProperties, CompositionEvent, FocusEvent,
|
|
1
|
+
import type { CSSProperties, CompositionEvent, FocusEvent, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import type { CommonPluginOptions } from "..";
|
|
3
3
|
import type { IEditor } from "../../../types";
|
|
4
4
|
export interface ReactEditorContentProps {
|
|
@@ -33,12 +33,12 @@ export interface ReactPlainTextProps {
|
|
|
33
33
|
}) => void;
|
|
34
34
|
onKeyDown?: (props: {
|
|
35
35
|
editor: IEditor;
|
|
36
|
-
event: KeyboardEvent
|
|
37
|
-
}) => void;
|
|
36
|
+
event: KeyboardEvent;
|
|
37
|
+
}) => boolean | void;
|
|
38
38
|
onPressEnter?: (props: {
|
|
39
39
|
editor: IEditor;
|
|
40
|
-
event: KeyboardEvent
|
|
41
|
-
}) => void;
|
|
40
|
+
event: KeyboardEvent;
|
|
41
|
+
}) => boolean | void;
|
|
42
42
|
style?: CSSProperties;
|
|
43
43
|
theme?: CommonPluginOptions['theme'] & {
|
|
44
44
|
fontSize?: number;
|
package/es/utils/debug.js
CHANGED
|
@@ -147,7 +147,7 @@ export var debugLogger = new DebugLogger();
|
|
|
147
147
|
*/
|
|
148
148
|
if (typeof window !== 'undefined') {
|
|
149
149
|
// Check for server-side DEBUG environment variable (passed through build process)
|
|
150
|
-
var envDebug = process.env.DEBUG;
|
|
150
|
+
var envDebug = typeof process !== 'undefined' ? process.env.DEBUG : undefined;
|
|
151
151
|
|
|
152
152
|
// Simple logic: Environment variable takes precedence, then development mode
|
|
153
153
|
var debugConfig = null;
|
|
@@ -293,7 +293,7 @@ export var browserDebug = {
|
|
|
293
293
|
*/
|
|
294
294
|
getConfig: function getConfig() {
|
|
295
295
|
if (typeof window !== 'undefined') {
|
|
296
|
-
var _envDebug = process.env.DEBUG;
|
|
296
|
+
var _envDebug = typeof process !== 'undefined' ? process.env.DEBUG : undefined;
|
|
297
297
|
var currentDebug = localStorage.getItem('debug');
|
|
298
298
|
if (_envDebug) {
|
|
299
299
|
return {
|
|
@@ -313,7 +313,7 @@ export var browserDebug = {
|
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
return {
|
|
316
|
-
enabled: process.env.DEBUG || false,
|
|
316
|
+
enabled: (typeof process !== 'undefined' ? process.env.DEBUG : undefined) || false,
|
|
317
317
|
source: 'server-side'
|
|
318
318
|
};
|
|
319
319
|
},
|
package/package.json
CHANGED