import { CssProps, RefProps } from 'lupine.web'; import { NotificationColor, NotificationMessage, ModalWindow } from 'lupine.components'; import { DemoStory } from '../../demo/demo-types'; import { HEditor } from './h-editor'; const defaultHtml = `

Welcome to HEditor!

This is a rich text editing component powered by Lupine.js.

`; const HEditorDemoPage = () => { let edt: HEditor | undefined; const ref: RefProps = { onLoad: async () => { // Find the container and initialize the editor with defaultHtml const container = ref.$('.edit-view-box'); if (container) { edt = HEditor.getEditor(container, defaultHtml); } }, }; const css: CssProps = { display: 'flex', flexDirection: 'column', height: '600px', // Set an explicit height for the editor container area padding: '16px', boxSizing: 'border-box', '.h-editor-demo-header': { display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingBottom: '16px', }, '.a-vw-edt-body': { flex: 1, // Take up remaining space border: '1px solid var(--primary-border, #eee)', borderRadius: '8px', overflow: 'hidden', }, // The editor container needs width and height 100% to fill the flex container '.edit-view-box': { width: '100%', height: '100%', }, }; const handleGetHtml = async () => { if (!edt) { NotificationMessage.sendMessage("Editor hasn't initialized yet.", NotificationColor.Error); return; } const htmlContent = edt.getHtml(); // Show output in a modal to clearly see the source code const closeIndex = await ModalWindow.show({ title: 'Current HTML Output', buttons: ['Close'], handleClicked: async (index, close) => { close(); }, children: (
{htmlContent}
), }); }; return (

HTML Editor

{/* The container element for HEditor */}
); }; export const hEditorDemo: DemoStory = { id: 'h-editor-demo', text: 'Rich Text Editor', args: {}, argTypes: {}, render: () => { return ; }, };