From b6e8b6fc641f12f09dbab9c73254bd2b47554b35 Mon Sep 17 00:00:00 2001 From: yanmao <55792257+yanmao-cc@users.noreply.github.com> Date: Fri, 21 Jan 2022 13:37:28 +0800 Subject: [PATCH] =?UTF-8?q?update:=20parser=20=E8=A7=A3=E6=9E=90html?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=20isEngine=20=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/engine/src/change/index.ts | 2 +- plugins/file/src/index.ts | 1 - plugins/math/src/index.ts | 1 - plugins/mention/src/index.ts | 12 ++++++------ plugins/status/src/index.ts | 1 - plugins/table/src/index.ts | 7 ++----- plugins/video/src/index.ts | 1 - 7 files changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/engine/src/change/index.ts b/packages/engine/src/change/index.ts index 46f5bb1c..574ca776 100644 --- a/packages/engine/src/change/index.ts +++ b/packages/engine/src/change/index.ts @@ -9,7 +9,7 @@ import { RangeInterface, RangePath } from '../types/range'; import ChangeEvent from './event'; import Parser from '../parser'; import { ANCHOR_SELECTOR, CURSOR_SELECTOR, FOCUS_SELECTOR } from '../constants'; -import { combinText, transformCustomTags } from '../utils'; +import { combinText } from '../utils'; import { TRIGGER_CARD_ID } from '../constants/card'; import { DATA_ID, EDITABLE_SELECTOR, UI_SELECTOR } from '../constants/root'; import { SelectionInterface } from '../types/selection'; diff --git a/plugins/file/src/index.ts b/plugins/file/src/index.ts index 5c2a7526..269fc4c2 100644 --- a/plugins/file/src/index.ts +++ b/plugins/file/src/index.ts @@ -25,7 +25,6 @@ export default class extends Plugin { init() { this.editor.language.add(locales); - if (!isEngine(this.editor)) return; this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:schema', (schema: SchemaInterface) => diff --git a/plugins/math/src/index.ts b/plugins/math/src/index.ts index 08a9c796..0b064319 100644 --- a/plugins/math/src/index.ts +++ b/plugins/math/src/index.ts @@ -55,7 +55,6 @@ export default class Math< init() { this.editor.language.add(locales); - if (!isEngine(this.editor)) return; this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:schema', (schema: SchemaInterface) => diff --git a/plugins/mention/src/index.ts b/plugins/mention/src/index.ts index 90824e19..1917252d 100644 --- a/plugins/mention/src/index.ts +++ b/plugins/mention/src/index.ts @@ -24,14 +24,14 @@ class MentionPlugin< } init() { + this.editor.on('parse:value', (node) => this.paserValue(node)); + this.editor.on('parse:html', (node) => this.parseHtml(node)); + this.editor.on('paste:each', (child) => this.pasteHtml(child)); + this.editor.on('paste:schema', (schema: SchemaInterface) => + this.pasteSchema(schema), + ); if (isEngine(this.editor)) { this.editor.on('keydown:at', (event) => this.onAt(event)); - this.editor.on('parse:value', (node) => this.paserValue(node)); - this.editor.on('parse:html', (node) => this.parseHtml(node)); - this.editor.on('paste:each', (child) => this.pasteHtml(child)); - this.editor.on('paste:schema', (schema: SchemaInterface) => - this.pasteSchema(schema), - ); } this.editor.language.add(locales); } diff --git a/plugins/status/src/index.ts b/plugins/status/src/index.ts index 17256f36..d4a8d220 100644 --- a/plugins/status/src/index.ts +++ b/plugins/status/src/index.ts @@ -23,7 +23,6 @@ export default class< init() { this.editor.language.add(locales); - if (!isEngine(this.editor)) return; this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:schema', (schema: SchemaInterface) => diff --git a/plugins/table/src/index.ts b/plugins/table/src/index.ts index 1b9ef844..0676a692 100644 --- a/plugins/table/src/index.ts +++ b/plugins/table/src/index.ts @@ -13,13 +13,13 @@ import { CARD_VALUE_KEY, CARD_SELECTOR, transformCustomTags, + READY_CARD_SELECTOR, } from '@aomao/engine'; import TableComponent, { Template, Helper } from './component'; import locales from './locale'; import { TableInterface, TableOptions, TableValue } from './types'; import './index.css'; import { DATA_ID } from '@aomao/engine'; -import { CardInterface } from '@aomao/engine'; class Table extends Plugin { static get pluginName() { return 'table'; @@ -493,10 +493,7 @@ class Table extends Plugin { node.remove(); return; } else { - const cards = table.find(CARD_SELECTOR).toArray(); - cards.forEach((componentNode) => { - this.editor.trigger('parse:html', componentNode); - }); + this.editor.trigger('parse:html', table); } } const width = table.attributes('width') || table.css('width'); diff --git a/plugins/video/src/index.ts b/plugins/video/src/index.ts index 11abf74f..0d9213f9 100644 --- a/plugins/video/src/index.ts +++ b/plugins/video/src/index.ts @@ -31,7 +31,6 @@ export default class VideoPlugin< init() { this.editor.language.add(locales); - if (!isEngine(this.editor)) return; this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:schema', (schema: SchemaInterface) =>