@lobehub/editor 1.20.1 → 1.20.3

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<{
@@ -258,28 +258,36 @@ export var MarkdownPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
258
258
  // No markdown detected - plain text is already inserted
259
259
  _this2.logger.debug('no markdown patterns detected, keeping as plain text');
260
260
  }
261
- if (clipboardData.types.includes('text/html') && clipboardData.types.includes('text/rtf')) {
262
- // Code detected - insert as code block
263
- _this2.logger.debug("code like, inserting as code block");
264
- event.preventDefault();
265
- event.stopPropagation();
266
- editor.update(function () {
267
- var selection = $getSelection();
268
- if (!$isRangeSelection(selection)) return;
269
-
270
- // Create code block node with detected language
271
- var codeNode = $createCodeNode('plaintext');
272
- selection.insertNodes([codeNode]);
273
261
 
274
- // Insert the code text into the code block
275
- codeNode.select();
276
- var codeSelection = $getSelection();
277
- if ($isRangeSelection(codeSelection)) {
278
- codeSelection.insertText(text);
279
- }
280
- });
281
- return true; // Command handled
282
- }
262
+ // word 一类富文本编辑器会同时包含 text/html text/rtf 类型的内容
263
+ // if (
264
+ // clipboardData.types.includes('text/html') &&
265
+ // clipboardData.types.includes('text/rtf')
266
+ // ) {
267
+ // // Code detected - insert as code block
268
+ // this.logger.debug(`code like, inserting as code block`);
269
+ //
270
+ // event.preventDefault();
271
+ // event.stopPropagation();
272
+ //
273
+ // editor.update(() => {
274
+ // const selection = $getSelection();
275
+ // if (!$isRangeSelection(selection)) return;
276
+ //
277
+ // // Create code block node with detected language
278
+ // const codeNode = $createCodeNode('plaintext');
279
+ // selection.insertNodes([codeNode]);
280
+ //
281
+ // // Insert the code text into the code block
282
+ // codeNode.select();
283
+ // const codeSelection = $getSelection();
284
+ // if ($isRangeSelection(codeSelection)) {
285
+ // codeSelection.insertText(text);
286
+ // }
287
+ // });
288
+ //
289
+ // return true; // Command handled
290
+ // }
283
291
 
284
292
  // Force plain text paste for external content
285
293
  event.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "1.20.1",
3
+ "version": "1.20.3",
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",