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 {
return this.get('locale') || '';
return this.get('locale');
}
@computed get deviceClassName(): string | undefined {

View File

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

View File

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

View File

@ -53,7 +53,7 @@ export function liveEditingRule(target: EditingTarget) {
}
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);
});