mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-23 13:02:21 +08:00
refactor(editor): remove inline editor keyboard utils and add markdown property in rich-text (#10375)
This commit is contained in:
@@ -5,9 +5,7 @@ import {
|
||||
type AttributeRenderer,
|
||||
type BaseTextAttributes,
|
||||
baseTextAttributes,
|
||||
createInlineKeyDownHandler,
|
||||
InlineEditor,
|
||||
KEYBOARD_ALLOW_DEFAULT,
|
||||
ZERO_WIDTH_NON_JOINER,
|
||||
} from '@blocksuite/inline';
|
||||
import { effects } from '@blocksuite/inline/effects';
|
||||
@@ -18,8 +16,6 @@ import { styleMap } from 'lit/directives/style-map.js';
|
||||
import * as Y from 'yjs';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { markdownMatches } from './markdown.js';
|
||||
|
||||
effects();
|
||||
|
||||
function inlineTextStyles(
|
||||
@@ -132,30 +128,6 @@ export class TestRichText extends ShadowlessElement {
|
||||
this.style.outline = 'none';
|
||||
this.inlineEditor.mount(this._container, this);
|
||||
|
||||
const keydownHandler = createInlineKeyDownHandler(this.inlineEditor, {
|
||||
inputRule: {
|
||||
key: ' ',
|
||||
handler: context => {
|
||||
const { inlineEditor, prefixText, inlineRange } = context;
|
||||
for (const match of markdownMatches) {
|
||||
const matchedText = prefixText.match(match.pattern);
|
||||
if (matchedText) {
|
||||
return match.action({
|
||||
inlineEditor,
|
||||
prefixText,
|
||||
inlineRange,
|
||||
pattern: match.pattern,
|
||||
undoManager: this.undoManager,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return KEYBOARD_ALLOW_DEFAULT;
|
||||
},
|
||||
},
|
||||
});
|
||||
this.addEventListener('keydown', keydownHandler);
|
||||
|
||||
this.inlineEditor.slots.textChange.on(() => {
|
||||
const el = this.querySelector('.y-text');
|
||||
if (el) {
|
||||
|
||||
Reference in New Issue
Block a user