Enable HTML Source
Use /cms/optional with editingModes: ['wysiwyg', 'source']. Keep WYSIWYG as the initial mode. Source downloads and initializes when the user first enters Source or a Source split view.
Trigger setWorkspaceView from an explicit user action. Merely showing the Source button should not fetch its runtime. Await the switch before interacting with the new surface.
Repair invalid Source according to the displayed feedback; do not overwrite it from the visual DOM. Try Source switching.
Checked code
ts
export async function source(host: HTMLElement) {
const editor = await createOptionalEditor(host, {
editingModes: ['wysiwyg', 'source'],
initialEditingMode: 'wysiwyg',
});
// Call in response to an explicit user action.
await editor.setWorkspaceView('source');
return editor;
}Checked against the published types; see imports and types for imports.