Skip to content

Commit

Permalink
adapter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
revolist committed Feb 5, 2021
1 parent 9e56d43 commit 0d27c04
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions src/vue-editor-adapter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,42 @@ import { VueConstructor } from 'vue/types/umd';
import { vueTemplateConstructor } from './vue-template';

export default class VueEditorAdapter {
public element: Element|null = null;
public editCell: Edition.EditCell|null = null;
private vueEl: Vue|undefined;
public element: Element|null = null;
public editCell: Edition.EditCell|null = null;
private vueEl: Vue|undefined;

constructor(
private VueEditorConstructor: VueConstructor,
public column: RevoGrid.ColumnDataSchemaModel,
private save: Function,
private close: Function
) {}
constructor(
private VueEditorConstructor: VueConstructor,
public column: RevoGrid.ColumnDataSchemaModel,
private save: Function,
private close: Function
) {}

// optional, called after editor rendered
componentDidRender() {}
// optional, called after editor rendered
componentDidRender() {}

// optional, called after editor destroyed
disconnectedCallback() {
this.vueEl?.$destroy();
this.vueEl = undefined;
}
// optional, called after editor destroyed
disconnectedCallback() {
this.vueEl?.$destroy();
this.vueEl = undefined;
}

render(h: RevoGrid.HyperFunc<VNode>) {
return <span ref={(el: HTMLElement) => {
console.log(this.save, this.close);
this.vueEl = vueTemplateConstructor(this.VueEditorConstructor, el, {
...this.editCell,
save: this.save,
close: this.close
})}}/>;
}
render(h: RevoGrid.HyperFunc<VNode>) {
return <span ref={(e: HTMLElement) => this.renderAdapter(e)}/>;
}

private renderAdapter(el?: HTMLElement) {
if (!el) {
return;
}
const template = vueTemplateConstructor(this.VueEditorConstructor, el, {
...this.editCell,
save: this.save,
close: this.close
});
if (!template) {
return;
}
this.vueEl = template;
}
}

0 comments on commit 0d27c04

Please sign in to comment.