mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-07 23:47:53 +08:00
902c993098
* Fix horizontal scrollbar on smaller screens * Apply navigation shortcuts without an additional roundtrip * Shorten the data element selector * Fix URL in changelog * Return reference from handle_intellisense
62 lines
1.5 KiB
JavaScript
62 lines
1.5 KiB
JavaScript
import LiveEditor from "./cell_editor/live_editor";
|
|
import { getAttributeOrThrow } from "../lib/attribute";
|
|
|
|
const CellEditor = {
|
|
mounted() {
|
|
this.props = this.getProps();
|
|
|
|
this.handleEvent(
|
|
`cell_editor_init:${this.props.cellId}:${this.props.tag}`,
|
|
({ source_view, language, intellisense, read_only }) => {
|
|
const editorContainer = this.el.querySelector(
|
|
`[data-el-editor-container]`
|
|
);
|
|
|
|
// Remove the content placeholder
|
|
editorContainer.firstElementChild.remove();
|
|
const editorEl = document.createElement("div");
|
|
editorContainer.appendChild(editorEl);
|
|
|
|
this.liveEditor = new LiveEditor(
|
|
this,
|
|
editorEl,
|
|
this.props.cellId,
|
|
this.props.tag,
|
|
source_view.source,
|
|
source_view.revision,
|
|
language,
|
|
intellisense,
|
|
read_only
|
|
);
|
|
|
|
this.el.dispatchEvent(
|
|
new CustomEvent("lb:cell:editor_created", {
|
|
detail: { tag: this.props.tag, liveEditor: this.liveEditor },
|
|
bubbles: true,
|
|
})
|
|
);
|
|
}
|
|
);
|
|
},
|
|
|
|
destroyed() {
|
|
if (this.liveEditor) {
|
|
this.el.dispatchEvent(
|
|
new CustomEvent("lb:cell:editor_removed", {
|
|
detail: { tag: this.props.tag },
|
|
bubbles: true,
|
|
})
|
|
);
|
|
this.liveEditor.dispose();
|
|
}
|
|
},
|
|
|
|
getProps() {
|
|
return {
|
|
cellId: getAttributeOrThrow(this.el, "data-cell-id"),
|
|
tag: getAttributeOrThrow(this.el, "data-tag"),
|
|
};
|
|
},
|
|
};
|
|
|
|
export default CellEditor;
|