File tree 16 files changed +250
-723
lines changed
framework/inline/src/utils
playground/examples/inline
16 files changed +250
-723
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ export class BlockRenderer
127
127
.attributesSchema =${ this . attributesSchema }
128
128
.attributeRenderer=${ this . attributeRenderer }
129
129
.embedChecker=${ this . inlineManager . embedChecker }
130
- .markdownShortcutHandler =${ this . inlineManager . markdownShortcutHandler }
130
+ .markdownMatches =${ this . inlineManager . markdownMatches }
131
131
class="inline-editor"
132
132
> </ rich-text >
133
133
` ;
Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ export class RichTextCell extends BaseRichTextCell {
221
221
.attributesSchema =${ this . attributesSchema }
222
222
.attributeRenderer=${ this . attributeRenderer }
223
223
.embedChecker=${ this . inlineManager ?. embedChecker }
224
- .markdownShortcutHandler =${ this . inlineManager ?. markdownShortcutHandler }
224
+ .markdownMatches =${ this . inlineManager ?. markdownMatches }
225
225
.readonly=${ true }
226
226
class="affine-database-rich-text inline-editor"
227
227
> </ rich-text > `
@@ -525,7 +525,7 @@ export class RichTextCellEditing extends BaseRichTextCell {
525
525
.attributesSchema=${ this . attributesSchema }
526
526
.attributeRenderer=${ this . attributeRenderer }
527
527
.embedChecker=${ this . inlineManager ?. embedChecker }
528
- .markdownShortcutHandler =${ this . inlineManager ?. markdownShortcutHandler }
528
+ .markdownMatches =${ this . inlineManager ?. markdownMatches }
529
529
.verticalScrollContainerGetter=${ ( ) =>
530
530
this . topContenteditableElement ?. host
531
531
? getViewportElement ( this . topContenteditableElement . host )
Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ export class HeaderAreaTextCell extends BaseTextCell {
187
187
.attributesSchema ="${ this . attributesSchema } "
188
188
.attributeRenderer ="${ this . attributeRenderer } "
189
189
.embedChecker ="${ this . inlineManager ?. embedChecker } "
190
- .markdownShortcutHandler ="${ this . inlineManager ?. markdownShortcutHandler } "
190
+ .markdownMatches ="${ this . inlineManager ?. markdownMatches } "
191
191
.readonly ="${ true } "
192
192
class ="data-view-header-area-rich-text "
193
193
> </ rich-text > ` ;
@@ -391,7 +391,7 @@ export class HeaderAreaTextCellEditing extends BaseTextCell {
391
391
.attributesSchema ="${ this . attributesSchema } "
392
392
.attributeRenderer ="${ this . attributeRenderer } "
393
393
.embedChecker ="${ this . inlineManager ?. embedChecker } "
394
- .markdownShortcutHandler ="${ this . inlineManager ?. markdownShortcutHandler } "
394
+ .markdownMatches ="${ this . inlineManager ?. markdownMatches } "
395
395
.readonly ="${ this . readonly } "
396
396
.enableClipboard ="${ false } "
397
397
.verticalScrollContainerGetter ="${ ( ) =>
Original file line number Diff line number Diff line change @@ -85,10 +85,6 @@ export class ListBlockComponent extends CaptionedBlockComponent<ListBlockModel>
85
85
return this . std . get ( DefaultInlineManagerExtension . identifier ) ;
86
86
}
87
87
88
- get markdownShortcutHandler ( ) {
89
- return this . inlineManager . markdownShortcutHandler ;
90
- }
91
-
92
88
override get topContenteditableElement ( ) {
93
89
if ( this . std . get ( DocModeProvider ) . getEditorMode ( ) === 'edgeless' ) {
94
90
return this . closest < BlockComponent > ( NOTE_SELECTOR ) ;
@@ -193,7 +189,7 @@ export class ListBlockComponent extends CaptionedBlockComponent<ListBlockModel>
193
189
.undoManager=${ this . doc . history }
194
190
.attributeRenderer=${ this . attributeRenderer }
195
191
.attributesSchema=${ this . attributesSchema }
196
- .markdownShortcutHandler =${ this . markdownShortcutHandler }
192
+ .markdownMatches =${ this . inlineManager ?. markdownMatches }
197
193
.embedChecker=${ this . embedChecker }
198
194
.readonly=${ this . doc . readonly }
199
195
.inlineRangeProvider=${ this . _inlineRangeProvider }
Original file line number Diff line number Diff line change @@ -90,10 +90,6 @@ export class ParagraphBlockComponent extends CaptionedBlockComponent<
90
90
return this . std . get ( DefaultInlineManagerExtension . identifier ) ;
91
91
}
92
92
93
- get markdownShortcutHandler ( ) {
94
- return this . inlineManager . markdownShortcutHandler ;
95
- }
96
-
97
93
override get topContenteditableElement ( ) {
98
94
if ( this . std . get ( DocModeProvider ) . getEditorMode ( ) === 'edgeless' ) {
99
95
return this . closest < BlockComponent > ( NOTE_SELECTOR ) ;
@@ -294,7 +290,7 @@ export class ParagraphBlockComponent extends CaptionedBlockComponent<
294
290
.undoManager=${ this . doc . history }
295
291
.attributesSchema=${ this . attributesSchema }
296
292
.attributeRenderer=${ this . attributeRenderer }
297
- .markdownShortcutHandler =${ this . markdownShortcutHandler }
293
+ .markdownMatches =${ this . inlineManager ?. markdownMatches }
298
294
.embedChecker=${ this . embedChecker }
299
295
.readonly=${ this . doc . readonly }
300
296
.inlineRangeProvider=${ this . _inlineRangeProvider }
Original file line number Diff line number Diff line change @@ -745,8 +745,7 @@ export class TableCell extends SignalWatcher(
745
745
.attributesSchema="${ this . inlineManager ?. getSchema ( ) } "
746
746
.attributeRenderer="${ this . inlineManager ?. getRenderer ( ) } "
747
747
.embedChecker="${ this . inlineManager ?. embedChecker } "
748
- .markdownShortcutHandler="${ this . inlineManager
749
- ?. markdownShortcutHandler } "
748
+ .markdownMatches="${ this . inlineManager ?. markdownMatches } "
750
749
.readonly="${ this . readonly } "
751
750
.enableClipboard="${ true } "
752
751
.verticalScrollContainerGetter="${ ( ) =>
Original file line number Diff line number Diff line change @@ -9,11 +9,8 @@ import {
9
9
baseTextAttributes ,
10
10
type DeltaInsert ,
11
11
getDefaultAttributeRenderer ,
12
- KEYBOARD_ALLOW_DEFAULT ,
13
- type KeyboardBindingContext ,
14
12
} from '@blocksuite/inline' ;
15
13
import type { ExtensionType } from '@blocksuite/store' ;
16
- import type * as Y from 'yjs' ;
17
14
import { z , type ZodObject , type ZodTypeAny } from 'zod' ;
18
15
19
16
import { MarkdownMatcherIdentifier } from './markdown-matcher.js' ;
@@ -61,27 +58,6 @@ export class InlineManager {
61
58
return schema ;
62
59
} ;
63
60
64
- markdownShortcutHandler = (
65
- context : KeyboardBindingContext < AffineTextAttributes > ,
66
- undoManager : Y . UndoManager
67
- ) => {
68
- const { inlineEditor, prefixText, inlineRange } = context ;
69
- for ( const match of this . markdownMatches ) {
70
- const matchedText = prefixText . match ( match . pattern ) ;
71
- if ( matchedText ) {
72
- return match . action ( {
73
- inlineEditor,
74
- prefixText,
75
- inlineRange,
76
- pattern : match . pattern ,
77
- undoManager,
78
- } ) ;
79
- }
80
- }
81
-
82
- return KEYBOARD_ALLOW_DEFAULT ;
83
- } ;
84
-
85
61
readonly specs : Array < InlineSpecs < AffineTextAttributes > > ;
86
62
87
63
constructor (
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ import type {
4
4
DeltaInsert ,
5
5
InlineEditor ,
6
6
InlineRange ,
7
- KeyboardBindingHandler ,
8
7
} from '@blocksuite/inline' ;
9
8
import type * as Y from 'yjs' ;
10
9
import type { ZodTypeAny } from 'zod' ;
@@ -28,7 +27,7 @@ export type InlineMarkdownMatchAction<
28
27
inlineRange : InlineRange ;
29
28
pattern : RegExp ;
30
29
undoManager : Y . UndoManager ;
31
- } ) => ReturnType < KeyboardBindingHandler > ;
30
+ } ) => void ;
32
31
33
32
export type InlineMarkdownMatch <
34
33
AffineTextAttributes extends BaseTextAttributes = BaseTextAttributes ,
You can’t perform that action at this time.
0 commit comments