feat: 支持 Node#wrapWith API

This commit is contained in:
力皓 2021-02-03 10:35:33 +08:00
parent 7ec3bf335d
commit 265a84fa6b
4 changed files with 6 additions and 5 deletions

View File

@ -145,7 +145,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
} }
@computed get locale(): string { @computed get locale(): string {
return this.get('locale') || ''; return this.get('locale');
} }
@computed get deviceClassName(): string | undefined { @computed get deviceClassName(): string | undefined {

View File

@ -456,8 +456,8 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
/* istanbul ignore next */ /* istanbul ignore next */
wrapWith(schema: Schema) { wrapWith(schema: Schema) {
// this.replaceWith({ ...schema, children: [this.export()] }); const wrappedNode = this.replaceWith({ ...schema, children: [this.export()] });
// this.children!.get(0)!.select(); return wrappedNode.children!.get(0);
} }
replaceWith(schema: Schema, migrate = false): any { replaceWith(schema: Schema, migrate = false): any {
@ -485,6 +485,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
if (selected) { if (selected) {
this.document.selection.select(newNode.id); this.document.selection.select(newNode.id);
} }
return newNode;
} }
return node; return node;
} }

View File

@ -332,7 +332,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
@computed get device() { @computed get device() {
return this._device; return this._device;
} }
@obx.ref private _locale: string = ''; @obx.ref private _locale: string | undefined = undefined;
@computed get locale() { @computed get locale() {
return this._locale; return this._locale;
} }

View File

@ -53,7 +53,7 @@ export function liveEditingRule(target: EditingTarget) {
} }
const { innerText } = targetElement; const { innerText } = targetElement;
const propTarget = ['title', 'label', 'text', 'content'].find(prop => { const propTarget = ['title', 'label', 'text', 'content', 'children'].find(prop => {
return equalText(getText(node, prop), innerText); return equalText(getText(node, prop), innerText);
}); });