@lobehub/editor 1.20.0 → 1.20.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.
@@ -3,7 +3,7 @@ export interface CommonPluginOptions {
3
3
  enableHotkey?: boolean;
4
4
  /**
5
5
  * Enable/disable markdown shortcuts
6
- * @default true - all formats enabled
6
+ * @default true - most formats enabled, but subscript/superscript are disabled by default
7
7
  */
8
8
  markdownOption?: boolean | {
9
9
  bold?: boolean;
@@ -12,6 +12,8 @@ export interface CommonPluginOptions {
12
12
  italic?: boolean;
13
13
  quote?: boolean;
14
14
  strikethrough?: boolean;
15
+ subscript?: boolean;
16
+ superscript?: boolean;
15
17
  underline?: boolean;
16
18
  underlineStrikethrough?: boolean;
17
19
  };
@@ -91,16 +91,21 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
91
91
  header: true,
92
92
  italic: true,
93
93
  quote: true,
94
- strikethrough: true
94
+ strikethrough: true,
95
+ subscript: false,
96
+ // Disabled by default
97
+ superscript: false // Disabled by default
95
98
  // Note: code, underline, underlineStrikethrough are handled by other plugins/writers
96
99
  };
97
100
  if (_typeof(markdownOption) === 'object') {
98
- var _markdownOption$bold, _markdownOption$heade, _markdownOption$itali, _markdownOption$quote, _markdownOption$strik;
101
+ var _markdownOption$bold, _markdownOption$heade, _markdownOption$itali, _markdownOption$quote, _markdownOption$strik, _markdownOption$subsc, _markdownOption$super;
99
102
  formats.bold = (_markdownOption$bold = markdownOption.bold) !== null && _markdownOption$bold !== void 0 ? _markdownOption$bold : true;
100
103
  formats.header = (_markdownOption$heade = markdownOption.header) !== null && _markdownOption$heade !== void 0 ? _markdownOption$heade : true;
101
104
  formats.italic = (_markdownOption$itali = markdownOption.italic) !== null && _markdownOption$itali !== void 0 ? _markdownOption$itali : true;
102
105
  formats.quote = (_markdownOption$quote = markdownOption.quote) !== null && _markdownOption$quote !== void 0 ? _markdownOption$quote : true;
103
106
  formats.strikethrough = (_markdownOption$strik = markdownOption.strikethrough) !== null && _markdownOption$strik !== void 0 ? _markdownOption$strik : true;
107
+ formats.subscript = (_markdownOption$subsc = markdownOption.subscript) !== null && _markdownOption$subsc !== void 0 ? _markdownOption$subsc : false;
108
+ formats.superscript = (_markdownOption$super = markdownOption.superscript) !== null && _markdownOption$super !== void 0 ? _markdownOption$super : false;
104
109
  }
105
110
 
106
111
  // Register quote shortcut if enabled
@@ -175,17 +180,20 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
175
180
  type: 'text-format'
176
181
  });
177
182
  }
178
-
179
- // Always register superscript and subscript (not in options)
180
- textFormatShortcuts.push({
181
- format: ['superscript'],
182
- tag: '^',
183
- type: 'text-format'
184
- }, {
185
- format: ['subscript'],
186
- tag: '~',
187
- type: 'text-format'
188
- });
183
+ if (formats.superscript) {
184
+ textFormatShortcuts.push({
185
+ format: ['superscript'],
186
+ tag: '^',
187
+ type: 'text-format'
188
+ });
189
+ }
190
+ if (formats.subscript) {
191
+ textFormatShortcuts.push({
192
+ format: ['subscript'],
193
+ tag: '~',
194
+ type: 'text-format'
195
+ });
196
+ }
189
197
  if (textFormatShortcuts.length > 0) {
190
198
  markdownService.registerMarkdownShortCuts(textFormatShortcuts);
191
199
  }
@@ -5,6 +5,8 @@ export declare const useThemeStyles: (props?: boolean | {
5
5
  italic?: boolean | undefined;
6
6
  quote?: boolean | undefined;
7
7
  strikethrough?: boolean | undefined;
8
+ subscript?: boolean | undefined;
9
+ superscript?: boolean | undefined;
8
10
  underline?: boolean | undefined;
9
11
  underlineStrikethrough?: boolean | undefined;
10
12
  } | undefined) => import("antd-style").ReturnStyles<{
@@ -1,4 +1,3 @@
1
1
  export * from './command';
2
- export * from './node/link-highlight';
3
2
  export * from './plugin';
4
3
  export * from './react';
@@ -1,5 +1,4 @@
1
1
  export * from "./command";
2
- export * from "./node/link-highlight";
3
2
  export * from "./plugin";
4
3
  export * from "./react";
5
4
  // Note: utils are internal only and not exported to avoid conflicts with other plugins
@@ -142,6 +142,13 @@ export var MarkdownPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
142
142
  textLength: text.length
143
143
  });
144
144
 
145
+ // Check if the pasted content is a pure URL
146
+ // If so, let Link/LinkHighlight plugins handle it
147
+ if (clipboardData.types.length === 1 && clipboardData.types[0] === 'text/plain' && isValidLinkUrl(text)) {
148
+ _this2.logger.debug('pure URL detected, letting Link/LinkHighlight plugins handle');
149
+ return false; // Let other plugins handle URL paste
150
+ }
151
+
145
152
  // Check if cursor is inside code block or inline code
146
153
  // If so, always paste as plain text
147
154
  var isInCodeBlock = editor.read(function () {
@@ -274,13 +281,6 @@ export var MarkdownPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
274
281
  return true; // Command handled
275
282
  }
276
283
 
277
- // Check if the pasted content is a pure URL
278
- // If so, let Link/LinkHighlight plugins handle it
279
- if (clipboardData.types.length === 1 && clipboardData.types[0] === 'text/plain' && isValidLinkUrl(text)) {
280
- _this2.logger.debug('pure URL detected, letting Link/LinkHighlight plugins handle');
281
- return false; // Let other plugins handle URL paste
282
- }
283
-
284
284
  // Force plain text paste for external content
285
285
  event.preventDefault();
286
286
  event.stopPropagation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
5
5
  "keywords": [
6
6
  "lobehub",