Public
Edited
Jan 6, 2024
Insert cell
Insert cell
lexicalHistory = import(
"https://cdn.jsdelivr.net/npm/@lexical/history@0.12.5/+esm"
).then((module) => module.default)
Insert cell
lexicalPlaintext = import(
"https://cdn.jsdelivr.net/npm/@lexical/plain-text@0.12.5/+esm"
).then((module) => module.default)
Insert cell
lexical = import("https://cdn.jsdelivr.net/npm/lexical@0.12.5/+esm").then(
(module) => module.default
)
Insert cell
viewof editor = {
const editor = createEditor();

const style = `
padding: 0 16px;
margin: 0;
border: 1px solid #aaa;
outline-offset: -2px;
`;
const root = html`<div
contentEditable="true"
spellCheck="false"
autoCapitalize="false"
style="${style}"
></div>`;
editor.setRootElement(root);

const historyState = lexicalHistory.createEmptyHistoryState();

lexicalPlaintext.registerPlainText(editor);
lexicalHistory.registerHistory(editor, historyState);

root.value = editor;
return root;
}
Insert cell
createEditor = () => {
const config = {
namespace: "editor",
onError: console.error
};

const editor = lexical.createEditor(config);
return editor;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more