update: parser 解析html移除 isEngine 限制

This commit is contained in:
yanmao 2022-01-21 13:37:28 +08:00
parent c12a1f4d19
commit b6e8b6fc64
7 changed files with 9 additions and 16 deletions

View File

@ -9,7 +9,7 @@ import { RangeInterface, RangePath } from '../types/range';
import ChangeEvent from './event'; import ChangeEvent from './event';
import Parser from '../parser'; import Parser from '../parser';
import { ANCHOR_SELECTOR, CURSOR_SELECTOR, FOCUS_SELECTOR } from '../constants'; 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 { TRIGGER_CARD_ID } from '../constants/card';
import { DATA_ID, EDITABLE_SELECTOR, UI_SELECTOR } from '../constants/root'; import { DATA_ID, EDITABLE_SELECTOR, UI_SELECTOR } from '../constants/root';
import { SelectionInterface } from '../types/selection'; import { SelectionInterface } from '../types/selection';

View File

@ -25,7 +25,6 @@ export default class<T extends FileOptions = FileOptions> extends Plugin<T> {
init() { init() {
this.editor.language.add(locales); this.editor.language.add(locales);
if (!isEngine(this.editor)) return;
this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('parse:html', (node) => this.parseHtml(node));
this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:each', (child) => this.pasteHtml(child));
this.editor.on('paste:schema', (schema: SchemaInterface) => this.editor.on('paste:schema', (schema: SchemaInterface) =>

View File

@ -55,7 +55,6 @@ export default class Math<
init() { init() {
this.editor.language.add(locales); this.editor.language.add(locales);
if (!isEngine(this.editor)) return;
this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('parse:html', (node) => this.parseHtml(node));
this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:each', (child) => this.pasteHtml(child));
this.editor.on('paste:schema', (schema: SchemaInterface) => this.editor.on('paste:schema', (schema: SchemaInterface) =>

View File

@ -24,14 +24,14 @@ class MentionPlugin<
} }
init() { init() {
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:value', (node) => this.paserValue(node));
this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('parse:html', (node) => this.parseHtml(node));
this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:each', (child) => this.pasteHtml(child));
this.editor.on('paste:schema', (schema: SchemaInterface) => this.editor.on('paste:schema', (schema: SchemaInterface) =>
this.pasteSchema(schema), this.pasteSchema(schema),
); );
if (isEngine(this.editor)) {
this.editor.on('keydown:at', (event) => this.onAt(event));
} }
this.editor.language.add(locales); this.editor.language.add(locales);
} }

View File

@ -23,7 +23,6 @@ export default class<
init() { init() {
this.editor.language.add(locales); this.editor.language.add(locales);
if (!isEngine(this.editor)) return;
this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('parse:html', (node) => this.parseHtml(node));
this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:each', (child) => this.pasteHtml(child));
this.editor.on('paste:schema', (schema: SchemaInterface) => this.editor.on('paste:schema', (schema: SchemaInterface) =>

View File

@ -13,13 +13,13 @@ import {
CARD_VALUE_KEY, CARD_VALUE_KEY,
CARD_SELECTOR, CARD_SELECTOR,
transformCustomTags, transformCustomTags,
READY_CARD_SELECTOR,
} from '@aomao/engine'; } from '@aomao/engine';
import TableComponent, { Template, Helper } from './component'; import TableComponent, { Template, Helper } from './component';
import locales from './locale'; import locales from './locale';
import { TableInterface, TableOptions, TableValue } from './types'; import { TableInterface, TableOptions, TableValue } from './types';
import './index.css'; import './index.css';
import { DATA_ID } from '@aomao/engine'; import { DATA_ID } from '@aomao/engine';
import { CardInterface } from '@aomao/engine';
class Table<T extends TableOptions = TableOptions> extends Plugin<T> { class Table<T extends TableOptions = TableOptions> extends Plugin<T> {
static get pluginName() { static get pluginName() {
return 'table'; return 'table';
@ -493,10 +493,7 @@ class Table<T extends TableOptions = TableOptions> extends Plugin<T> {
node.remove(); node.remove();
return; return;
} else { } else {
const cards = table.find(CARD_SELECTOR).toArray(); this.editor.trigger('parse:html', table);
cards.forEach((componentNode) => {
this.editor.trigger('parse:html', componentNode);
});
} }
} }
const width = table.attributes('width') || table.css('width'); const width = table.attributes('width') || table.css('width');

View File

@ -31,7 +31,6 @@ export default class VideoPlugin<
init() { init() {
this.editor.language.add(locales); this.editor.language.add(locales);
if (!isEngine(this.editor)) return;
this.editor.on('parse:html', (node) => this.parseHtml(node)); this.editor.on('parse:html', (node) => this.parseHtml(node));
this.editor.on('paste:each', (child) => this.pasteHtml(child)); this.editor.on('paste:each', (child) => this.pasteHtml(child));
this.editor.on('paste:schema', (schema: SchemaInterface) => this.editor.on('paste:schema', (schema: SchemaInterface) =>