react-edit-to-html 1.2.6 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # react-edit-to-html
2
2
 
3
- `react-edit-to-html` is a premium, highly customizable, responsive React drag-and-drop template builder for creating dynamic HTML layouts. It is perfect for generating backend templates (invoices, shipping lists, email templates, billing letters, reports, etc.) that get populated with dynamic data.
3
+ `react-edit-to-html` is a premium, highly customizable, responsive HTML editor and visual template builder for creating dynamic HTML layouts. It is perfect for generating backend templates (invoices, shipping lists, email templates, billing letters, reports, PDF documents, etc.) populated with dynamic data.
4
+
5
+ ---
4
6
 
5
7
  ## 🚀 Live Online Demo
6
8
 
@@ -8,25 +10,40 @@ Click the button below to try out `react-edit-to-html` live on CodeSandbox:
8
10
 
9
11
  [![Edit react-edit-to-html](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/p/devbox/react-edit-to-html-forked-tfsm4n)
10
12
 
11
- The editor allows you to structure tables, images, text, and barcodes, preview them in real time with custom mock values, configure loop templates for multiple template engines (Handlebars, Liquid, Scriban, .NET, C#), and export clean, production-ready HTML files.
13
+ The editor allows you to structure tables, images, text, and barcodes, preview them in real time with custom mock values, configure loop templates for multiple template engines (**TypeScript (`ts`)**, **JavaScript (`js`) ES6 Template Literals**, Handlebars, Liquid, Scriban, .NET, C#/Razor), and export clean, production-ready HTML files.
14
+
15
+ ---
16
+
17
+ ## 🌐 Multi-Framework & TypeScript/JavaScript Support
18
+
19
+ Yes! **`react-edit-to-html` is built with TypeScript (`.ts`/`.tsx`) and supports all JavaScript/TypeScript frameworks**:
20
+ - **React & Next.js** (Native TSX/JSX component)
21
+ - **Vue 3 & Vue 2** (via `mountHtmlEditor` helper)
22
+ - **Angular** (via `mountHtmlEditor` helper)
23
+ - **Svelte & SvelteKit** (via `mountHtmlEditor` helper)
24
+ - **Vanilla JavaScript / TypeScript** (plain HTML, jQuery, PHP, Laravel, Rails, ASP.NET)
25
+
26
+ The package includes full **TypeScript declaration files (`.d.ts`)** and exports `mountHtmlEditor(container, props)` and `unmountHtmlEditor(container)` for non-React or plain JS environments.
12
27
 
13
28
  ---
14
29
 
15
- ## Key Features
30
+ ## 🌟 Key Features & Highlights
16
31
 
17
- - 🛠 **Drag-and-Drop Canvas:** Select element blocks (headings, paragraphs, tables, images, barcodes) from the sidebar and drag them onto the paper canvas.
18
- - 🔄 **Multi-Syntax Loop Templates:** Pick your templating engine (Handlebars, Liquid, Scriban, JS/TS maps, C#/Razor, or Custom tags) for dynamic table looping.
32
+ - 🛠 **Drag-and-Drop Canvas Editor:** Select element blocks (headings, paragraphs, tables, images, barcodes) from the sidebar and drag them onto the paper canvas.
33
+ - 🔷 **Full TypeScript & JavaScript Flexibility:** Built in TypeScript with full type definitions (`.d.ts`) + `mountHtmlEditor` helper for Vue, Angular, Svelte, and Vanilla JS.
34
+ - 🟨 **JS/TS ES6 Template Literals (`js` / `ts`):** Dynamic map looping (`${items.map(item => \`...\`).join('')}`) alongside Handlebars, Liquid, Scriban, and C#/Razor syntaxes.
35
+ - 🔄 **Multi-Syntax Loop Templates:** Toggle template engines (`templatingLanguage="js"`, `"ts"`, `"handlebars"`, `"liquid"`, `"scriban"`, `"csharp"`, `"dotnet"`) for dynamic table looping.
36
+ - 🖼 **Image Alignment & Position Controls:** Visual alignment controls (Left, Center, Right) for images and barcodes in both live canvas and exported HTML markup.
19
37
  - 📊 **Dynamic Mock Visualizer:** View variables substituted instantly with mock data. Edit mock values for placeholders and raw JSON rows directly in the sidebar.
20
- - 🎨 **Advanced Styles & Custom CSS:** Customize padding, margin, sizing, and colors. Write custom inline CSS styles (e.g. `border-radius: 8px; border: 1px dashed slate;`) for a WYSIWYG editing experience.
21
- - 🔤 **Custom Typography:** Register custom font sizes and Google Fonts directly in the panel.
22
- - 🖼 **Custom Image Types & Neutral SVGs:** Register custom graphic categories (e.g., Signature, Thumbnail) on the fly, with standard clean base64 image placeholders.
23
- - 📱 **Fully Responsive Layout:** Automatically stacks vertically on smaller screens and side-by-side on larger desktop screens.
38
+ - 🎨 **Advanced Styles & Layouts:** Customize padding, margin, block widths, element sizing, and colors for a true WYSIWYG editing experience.
39
+ - 🔤 **Custom Typography:** Register custom font sizes, weights, and Google Fonts directly in the panel.
40
+ - 🖼 **Custom Image Types & SVG Barcodes:** Register custom graphic categories (e.g., Signature, Logo, Banner, Watermark, Barcode) on the fly with clean SVG base64 image placeholders.
41
+ - 📱 **Fully Responsive Layout:** Automatically stacks vertically on smaller screens and side-by-side on desktop screens.
24
42
  - ⚡ **PDF & HTML Importing:** Import existing HTML templates or parse digital PDF text layers directly into editable canvas blocks.
25
- - 💾 **Silent Callbacks:** Custom handlers for block changes and template exports instead of intrusive alerts.
26
43
 
27
44
  ---
28
45
 
29
- ## Installation
46
+ ## 📦 Installation
30
47
 
31
48
  Install the package via npm:
32
49
 
@@ -34,7 +51,7 @@ Install the package via npm:
34
51
  npm install react-edit-to-html
35
52
  ```
36
53
 
37
- Make sure to import the CSS stylesheet in your main React application entry point (e.g. `App.tsx` or `main.tsx`) so that the editor displays correctly:
54
+ Make sure to import the CSS stylesheet in your application:
38
55
 
39
56
  ```typescript
40
57
  import 'react-edit-to-html/dist/react-edit-to-html.css';
@@ -42,50 +59,36 @@ import 'react-edit-to-html/dist/react-edit-to-html.css';
42
59
 
43
60
  ---
44
61
 
45
- ## Usage
62
+ ## 💻 Integration Examples Across Frameworks
46
63
 
47
- Here is a basic example of how to embed `react-edit-to-html` in a React application:
64
+ ### 1. React / Next.js Example (TypeScript & JavaScript)
48
65
 
49
66
  ```tsx
50
67
  import React from 'react';
51
68
  import HtmlEditor from 'react-edit-to-html';
69
+ import type { TableSchemaInfo, PlaceholderItem } from 'react-edit-to-html';
52
70
  import 'react-edit-to-html/dist/react-edit-to-html.css';
53
71
 
54
- export default function MyBuilderPage() {
55
- const customTables = [
72
+ export default function ReactTemplateEditor() {
73
+ const customTables: TableSchemaInfo[] = [
56
74
  {
57
75
  tableName: 'order_items',
58
76
  columns: [
59
- { columnName: 'Item Name', placeholder: '{{item.name}}', enabled: true },
60
- { columnName: 'SKU', placeholder: '{{item.sku}}', enabled: true },
61
- { columnName: 'Price', placeholder: '{{item.price}}', enabled: true }
77
+ { columnName: 'Item Name', placeholder: '${item.name}', enabled: true },
78
+ { columnName: 'SKU', placeholder: '${item.sku}', enabled: true },
79
+ { columnName: 'Price', placeholder: '${item.price}', enabled: true }
62
80
  ],
63
- loop: true,
64
- isNestable: false,
65
- parentPath: 'order',
66
- maxNestingDepth: 5,
67
- nestingPrefix: ' ',
68
- showNestingLevel: false
81
+ loop: true
69
82
  }
70
83
  ];
71
84
 
72
- const customPlaceholders = [
73
- { label: 'Invoice ID', placeholder: '{{invoice_id}}', category: 'General', mockValue: 'INV-2026-9021' },
74
- { label: 'Customer Name', placeholder: '{{customer_name}}', category: 'General', mockValue: 'Sophia Mueller' }
75
- ];
76
-
77
-
78
-
79
85
  return (
80
86
  <div style={{ height: '100vh', width: '100vw' }}>
81
87
  <HtmlEditor
82
- headerTitle="Custom Document Designer"
83
- headerSubtitle="Build invoices & export dynamic templates"
88
+ headerTitle="React Document Builder"
84
89
  tableSchemas={customTables}
85
- placeholders={customPlaceholders}
86
- templatingLanguage="csharp"
87
- loopSyntax="each"
88
-
90
+ templatingLanguage="ts"
91
+ onExport={(html: string) => console.log('Exported HTML:', html)}
89
92
  />
90
93
  </div>
91
94
  );
@@ -94,15 +97,135 @@ export default function MyBuilderPage() {
94
97
 
95
98
  ---
96
99
 
97
- ## Props Reference
100
+ ### 2. Vue 3 Example (Using `mountHtmlEditor`)
101
+
102
+ ```vue
103
+ <template>
104
+ <div ref="editorRef" style="height: 100vh; width: 100vw;"></div>
105
+ </template>
106
+
107
+ <script setup lang="ts">
108
+ import { ref, onMounted, onUnmounted } from 'vue';
109
+ import { mountHtmlEditor, unmountHtmlEditor } from 'react-edit-to-html';
110
+ import 'react-edit-to-html/dist/react-edit-to-html.css';
111
+
112
+ const editorRef = ref<HTMLDivElement | null>(null);
113
+
114
+ onMounted(() => {
115
+ if (editorRef.value) {
116
+ mountHtmlEditor(editorRef.value, {
117
+ headerTitle: 'Vue 3 Template Designer',
118
+ templatingLanguage: 'js',
119
+ onExport: (html: string) => console.log('Exported HTML from Vue:', html)
120
+ });
121
+ }
122
+ });
123
+
124
+ onUnmounted(() => {
125
+ if (editorRef.value) unmountHtmlEditor(editorRef.value);
126
+ });
127
+ </script>
128
+ ```
129
+
130
+ ---
131
+
132
+ ### 3. Angular Example (Using `mountHtmlEditor`)
133
+
134
+ ```typescript
135
+ import { Component, ElementRef, ViewChild, AfterViewInit, OnDestroy } from '@angular/core';
136
+ import { mountHtmlEditor, unmountHtmlEditor } from 'react-edit-to-html';
137
+ import 'react-edit-to-html/dist/react-edit-to-html.css';
138
+
139
+ @Component({
140
+ selector: 'app-html-editor',
141
+ template: `<div #editorContainer style="height: 100vh; width: 100vw;"></div>`
142
+ })
143
+ export class HtmlEditorComponent implements AfterViewInit, OnDestroy {
144
+ @ViewChild('editorContainer') container!: ElementRef<HTMLDivElement>;
145
+
146
+ ngAfterViewInit() {
147
+ mountHtmlEditor(this.container.nativeElement, {
148
+ headerTitle: 'Angular Template Designer',
149
+ templatingLanguage: 'ts',
150
+ onExport: (html: string) => console.log('Exported HTML from Angular:', html)
151
+ });
152
+ }
153
+
154
+ ngOnDestroy() {
155
+ unmountHtmlEditor(this.container.nativeElement);
156
+ }
157
+ }
158
+ ```
159
+
160
+ ---
161
+
162
+ ### 4. Svelte Example (Using `mountHtmlEditor`)
163
+
164
+ ```svelte
165
+ <script lang="ts">
166
+ import { onMounted, onDestroy } from 'svelte';
167
+ import { mountHtmlEditor, unmountHtmlEditor } from 'react-edit-to-html';
168
+ import 'react-edit-to-html/dist/react-edit-to-html.css';
169
+
170
+ let container: HTMLDivElement;
171
+
172
+ onMounted(() => {
173
+ mountHtmlEditor(container, {
174
+ headerTitle: 'Svelte Document Builder',
175
+ templatingLanguage: 'js',
176
+ onExport: (html: string) => console.log('Exported HTML from Svelte:', html)
177
+ });
178
+ });
179
+
180
+ onDestroy(() => {
181
+ if (container) unmountHtmlEditor(container);
182
+ });
183
+ </script>
184
+
185
+ <div bind:this={container} style="height: 100vh; width: 100vw;"></div>
186
+ ```
187
+
188
+ ---
189
+
190
+ ### 5. Vanilla JavaScript / Plain HTML Example
191
+
192
+ ```html
193
+ <!DOCTYPE html>
194
+ <html lang="en">
195
+ <head>
196
+ <meta charset="UTF-8">
197
+ <title>Vanilla JS HTML Editor</title>
198
+ <link rel="stylesheet" href="node_modules/react-edit-to-html/dist/react-edit-to-html.css">
199
+ </head>
200
+ <body style="margin: 0;">
201
+ <div id="editor-root" style="height: 100vh; width: 100vw;"></div>
202
+
203
+ <script type="module">
204
+ import { mountHtmlEditor } from './node_modules/react-edit-to-html/dist/index.js';
205
+
206
+ mountHtmlEditor(document.getElementById('editor-root'), {
207
+ headerTitle: 'Vanilla JavaScript Editor',
208
+ templatingLanguage: 'js',
209
+ onExport: function(html) {
210
+ console.log('Exported HTML:', html);
211
+ }
212
+ });
213
+ </script>
214
+ </body>
215
+ </html>
216
+ ```
217
+
218
+ ---
219
+
220
+ ## 📋 Props Reference
98
221
 
99
222
  ```ts
100
223
  type TableColumn = {
101
224
  columnName: string;
102
225
  placeholder: string;
103
226
  enabled?: boolean;
104
- loop?: boolean; // Set to true to make column a nested sub-table loop
105
- columns?: TableColumn[]; // Sub-table column definitions when loop is true
227
+ loop?: boolean;
228
+ columns?: TableColumn[];
106
229
  };
107
230
 
108
231
  type TableSchemaInfo = {
@@ -133,7 +256,7 @@ interface HtmlEditorProps {
133
256
  headerTitle?: string;
134
257
  headerSubtitle?: string;
135
258
  headerLogo?: React.ReactNode;
136
- templatingLanguage?: 'handlebars' | 'liquid' | 'scriban' | 'dotnet' | 'js' | 'csharp' | 'custom';
259
+ templatingLanguage?: 'js' | 'ts' | 'handlebars' | 'liquid' | 'scriban' | 'dotnet' | 'csharp' | 'custom';
137
260
  loopSyntax?: 'for' | 'foreach' | 'each';
138
261
  onChange?: (blocks: CanvasBlock[]) => void;
139
262
  onExport?: (html: string) => void;
@@ -146,11 +269,10 @@ interface HtmlEditorProps {
146
269
  showPreview?: boolean;
147
270
  showExport?: boolean;
148
271
  showExportPdf?: boolean;
149
- /** Allows passing custom CSS inline style properties dynamically to any of the header actions (importHtml, importPdf, clearCanvas, preview, export) */
272
+ /** Position of the sidebar panel ('left' | 'right'). Defaults to 'left' */
273
+ sidebarPosition?: 'left' | 'right';
150
274
  customButtonStyles?: Record<string, React.CSSProperties>;
151
- /** Allows passing custom CSS class names dynamically to customize/override button class sheets for header actions */
152
275
  customButtonClassNames?: Record<string, string>;
153
- /** Allows passing completely custom React components for header actions. Receives an onClick prop to trigger the action. */
154
276
  customActionComponents?: {
155
277
  importHtml?: (props: { onClick: () => void }) => React.ReactNode;
156
278
  importPdf?: (props: { onClick: () => void }) => React.ReactNode;
@@ -163,117 +285,90 @@ interface HtmlEditorProps {
163
285
 
164
286
  | Prop | Type | Default | Details |
165
287
  | :--- | :--- | :--- | :--- |
166
- | `tableSchemas` | `TableSchemaInfo[]` | `[]` | Configures dynamic table schemas. Supports top-level loop tables and nested sub-tables (`loop: true` with `columns`).<br/>**Example:** `tableSchemas={[{ tableName: 'items', loop: true, columns: [{ columnName: 'SKU', placeholder: '{{item.sku}}' }] }]}` |
167
- | `placeholders` | `PlaceholderItem[]` | `[]` | Controls variables shown in the Placeholders tab. Left empty by default until passed as a prop.<br/>**Example:** `placeholders={[{ label: 'User Name', placeholder: '{{user.name}}' }]}` |
168
- | `defaultLogo` | `string` | Neutral SVG placeholder | Default image source when inserting/selecting `logo` image blocks. Accepts URL or base64 data URI.<br/>**Example:** `defaultLogo="https://example.com/logo.png"` |
169
- | `defaultBanner` | `string` | Neutral SVG placeholder | Default image source when inserting/selecting `banner` image blocks. Accepts URL or base64 data URI.<br/>**Example:** `defaultBanner="https://example.com/banner.png"` |
170
- | `headerTitle` | `string` | `'Layout Designer'` | Header title text displayed at the top of the editor.<br/>**Example:** `headerTitle="Invoice Template Builder"` |
171
- | `headerSubtitle` | `string` | `'Interactive Document HTML Builder'` | Header subtitle text displayed below the title.<br/>**Example:** `headerSubtitle="Customize & Export Invoices"` |
172
- | `headerLogo` | `React.ReactNode` | Sparkles icon badge | Custom header logo node. If omitted, the built-in orange Sparkles badge is rendered.<br/>**Example:** `headerLogo={<img src="/logo.png" className="h-6 w-6" />}` |
173
- | `typographySizes` | `Array<{ label: string; value: string }>` | Standard px list | Custom list of font sizes available in the formatting panel dropdown.<br/>**Example:** `typographySizes={[{ label: '14px', value: '14px' }, { label: '20px', value: '20px' }]}` |
174
- | `typographyWeights` | `Array<{ label: string; value: string }>` | Standard weights list | Custom list of font weights available in the formatting panel dropdown.<br/>**Example:** `typographyWeights={[{ label: 'Normal', value: '400' }, { label: 'Bold', value: '700' }]}` |
175
- | `typographyFonts` | `Array<{ label: string; value: string }>` | Default fonts list | Custom list of font families available in the typography font selector dropdown.<br/>**Example:** `typographyFonts={[{ label: 'Inter', value: 'Inter, sans-serif' }]}` |
176
- | `templatingLanguage` | `'handlebars' \| 'liquid' \| 'scriban' \| ...` | `'handlebars'` | Sets initial loop-tag generation mode for table export.<br/>**Example:** `templatingLanguage="liquid"` |
177
- | `loopSyntax` | `'for' \| 'foreach' \| 'each'` | `'each'` | Sets initial mapping keyword used by the loop-tag generator.<br/>**Example:** `loopSyntax="foreach"` |
178
- | `onChange` | `(blocks: CanvasBlock[]) => void` | `undefined` | Fired whenever canvas blocks state changes.<br/>**Example:** `onChange={(blocks) => console.log('Blocks:', blocks)}` |
179
- | `onExport` | `(html: string) => void` | `undefined` | Called when user clicks Export Template. If omitted, it automatically downloads `template.html`.<br/>**Example:** `onExport={(html) => saveTemplate(html)}` |
180
- | `onExportPdf` | `(html: string) => void` | `undefined` | Called when user clicks Download PDF. If omitted, it defaults to triggering `window.print()` for a native PDF preview.<br/>**Example:** `onExportPdf={(html) => downloadPdfFile(html)}` |
181
- | `initialBlocks` | `CanvasBlock[]` | `[]` | Pass preloaded blocks to initialize the layout canvas.<br/>**Example:** `initialBlocks={[{ id: 'b1', type: 'h1', content: 'Title', style: { fontSize: '24px' } }]}` |
182
- | `defaultStyles` | `Record<string, Partial<TextStyle>>` | `{}` | Key-value dictionary providing pre-defined styling configurations for elements dropped or created in the canvas.<br/>**Example:** `defaultStyles={{ h1: { fontSize: '24px', fontWeight: 'bold' } }}` |
183
- | `showHeader` | `boolean` | `true` | Show or hide the top header bar branding. Visible by default (`true`).<br/>**Example:** `showHeader={false}` |
184
- | `isTablesLoading` | `boolean` | `false` | Displays an animated skeleton loader inside the Dynamic Tables sidebar tab.<br/>**Example:** `isTablesLoading={true}` |
185
- | `isPlaceholdersLoading` | `boolean` | `false` | Displays an animated skeleton loader inside the Variables Palette sidebar tab.<br/>**Example:** `isPlaceholdersLoading={true}` |
186
- | `showImportHtml` | `boolean` | `true` | Show/hide the "Import HTML" action button in the toolbar.<br/>**Example:** `showImportHtml={true}` |
187
- | `showImportPdf` | `boolean` | `true` | Show/hide the "Import PDF" action button in the toolbar.<br/>**Example:** `showImportPdf={false}` |
188
- | `showClearCanvas` | `boolean` | `true` | Show/hide the "Clear Canvas" utility button in the canvas toolbar.<br/>**Example:** `showClearCanvas={true}` |
189
- | `showPreview` | `boolean` | `true` | Show/hide the "Live Preview" action button in the toolbar.<br/>**Example:** `showPreview={true}` |
190
- | `showExport` | `boolean` | `true` | Show/hide the "Export Template" action button in the toolbar.<br/>**Example:** `showExport={true}` |
191
- | `showExportPdf` | `boolean` | `true` | Show/hide the "Download PDF" action button in the toolbar.<br/>**Example:** `showExportPdf={true}` |
192
- | `customButtonStyles` | `object` | `{}` | Allows passing custom CSS inline style properties dynamically to any of the header/toolbar actions.<br/>**Example:** `customButtonStyles={{ export: { backgroundColor: '#10b981' } }}` |
193
- | `customButtonClassNames` | `object` | `{}` | Allows passing custom CSS Tailwind class names dynamically to customize/override button class sheets.<br/>**Example:** `customButtonClassNames={{ export: 'bg-emerald-600 hover:bg-emerald-700' }}` |
194
- | `customActionComponents` | `object` | `undefined` | Pass custom React components for toolbar actions (`importHtml`, `importPdf`, `preview`, `exportPdf`, `export`). Render prop receives `{ onClick }`.<br/>**Example:** `customActionComponents={{ export: ({ onClick }) => <button onClick={onClick}>Save</button> }}` |
195
-
196
- ### Notes on Table & Sub-Table Types
197
-
198
- - `TableSchemaInfo` and `TableColumn` are exported from the package (`export * from './types'`).
199
- - **Sub-Tables:** Define `loop: true` and specify a `columns: TableColumn[]` array on any column item. In both editor canvas and exported HTML, sub-tables render with nested headers (`<thead>`) and body rows (`<tbody>`).
200
- - **Column & Sub-Column Management:** In the Formatting Panel (**Styles Tab**), click the Pencil (`Edit`) icon next to any column or sub-column to edit header names and placeholders inline, add new sub-columns, or delete sub-columns.
288
+ | `sidebarPosition` | `'left' \| 'right'` | `'left'` | Controls the sidebar panel position. Defaults to `'left'` (sidebar on left, canvas on right). Set to `'right'` to position the sidebar on the right side. |
289
+ | `templatingLanguage` | `'js' \| 'ts' \| 'handlebars' \| 'liquid' \| 'scriban' \| 'dotnet' \| 'csharp' \| 'custom'` | `'js'` | Configures loop-tag syntax mode for exported HTML tables. Supports JavaScript/TypeScript Template Literals (`js`/`ts`), Handlebars (`handlebars`), Liquid (`liquid`), Scriban (`scriban`), and C# Razor (`csharp`). |
290
+ | `tableSchemas` | `TableSchemaInfo[]` | `[]` | Configures dynamic table schemas. Supports top-level loop tables and nested sub-tables. |
291
+ | `placeholders` | `PlaceholderItem[]` | `[]` | Controls variables shown in the Placeholders tab. |
292
+ | `defaultLogo` | `string` | Neutral SVG | Default image source for logo blocks. |
293
+ | `defaultBanner` | `string` | Neutral SVG | Default image source for banner blocks. |
294
+ | `headerTitle` | `string` | `'Layout Designer'` | Header title text displayed at top of editor. |
295
+ | `headerSubtitle` | `string` | `'Interactive Document HTML Builder'` | Header subtitle text. |
296
+ | `onExport` | `(html: string) => void` | `undefined` | Called when user exports template. |
297
+ | `onExportPdf` | `(html: string) => void` | `undefined` | Called when user downloads PDF. |
298
+
299
+ | Exported Helper Function | Parameters | Description |
300
+ | :--- | :--- | :--- |
301
+ | `mountHtmlEditor` | `(container: HTMLElement, props?: HtmlEditorProps)` | Mounts the full editor into any DOM element container. Perfect for Vue, Angular, Svelte, and Vanilla JS applications. |
302
+ | `unmountHtmlEditor` | `(container: HTMLElement)` | Unmounts the editor component and cleans up internal DOM nodes. |
201
303
 
202
304
  ---
203
305
 
204
- ## Editing & Managing Sections
205
-
206
- The sidebar contains 4 main tabs for configuring elements and settings:
207
-
208
- ### 1. Typography Elements (Text Tab)
209
- Contains Heading styles, Paragraphs, Titles, and Captions.
210
- - **How to add:** Drag any element block onto the canvas or click "Insert at End".
211
- - **How to edit:** Click directly on the text block on the canvas to type text. Highlight text to trigger the inline **Rich Text Selection Bubble** (bold, italics, underline, or colors).
212
-
213
- ### 2. Dynamic Tables (Tables Tab)
214
- Loads your configured table schemas.
215
- - **How to add:** Drag a table card from the sidebar onto the canvas or click "Insert at End" to append.
216
- - **Toggling Columns:** Click checkboxes in the sidebar schema card to enable/disable columns.
217
- - **Custom Tables:** Input a Table Name, choose loop start/end tags, and click "Add Custom Loop Table" to dynamically register new tables.
218
-
219
- ### 3. Image & Barcode Elements (Images Tab)
220
- - **Logos & Banners:** Drag logos or banners onto the canvas. Upload custom files (converted to base64) under settings properties.
221
- - **Dynamic Barcodes:** Drag a barcode block. Change the mock value (e.g. `SHIP-99201`) or backend template tag (e.g. `{{barcode}}`) in block settings configurations.
222
- - **Custom Image Types:** Register custom graphics categories (e.g., Signature) by typing a label and clicking "Add Image Type".
223
-
224
- ### 4. Variables Palette (Placeholders Tab)
225
- - **Inserting Placeholders:** Highlight any text block or table cell and drag a placeholder variable chip onto it. Alternatively, select a block, and click a variable in the palette to insert it at the cursor position.
226
- - **Custom Mock Values:** Next to each variable in the palette, type a mock value. This will instantly replace placeholders in the canvas for layout testing.
227
-
228
- ### 5. Formatting Styles Panel (Styles Tab)
229
- Applies when a canvas block is selected:
230
- - **Typography & Layout:** Adjust alignment, font size, font family, and font weight.
231
- - **Visual Colors:** Adjust text color and background color using interactive selectors.
232
- - **Sizing & Spacing:** Control block margins, padding, widths, and heights using range sliders.
233
- - **Typography Variants:** Register custom sizes (e.g. `17px`) and Google fonts dynamically.
234
- - **Table Columns Editor:** Add columns, delete columns, or edit raw JSON records for tables.
235
- - **Global template settings:** Choose template syntaxes (Handlebars, Liquid, Scriban, Razor) and toggle HTML comment wraps.
306
+ ## Templating Language Output Comparison
236
307
 
237
- ---
238
-
239
- ## Customizing Element Styling
240
-
241
- `react-edit-to-html` provides a rich visual formatting panel to easily customize fonts, weights, sizes, margins, padding, and alignments:
242
- - **Style Customization:** End users can control text alignment, colors, padding, margins, block widths, and heights directly from the sidebar.
243
- - **Layout-Safe:** The raw custom inline CSS styles textarea has been removed from the formatting panel options to ensure design consistency and prevent layout breaks.
244
- - **Developer Default Styles:** Pass styling presets via the `defaultStyles` prop to auto-configure initial properties on drops or insertions.
245
-
246
- ---
247
-
248
- ## Export HTML Structure
249
-
250
- When exporting the template layout, `react-edit-to-html` packages the final output into a clean HTML format. Tables are exported using the exact inline styles and template comments matching the selected engine:
308
+ ### TypeScript / JavaScript ES6 Template Literals (`templatingLanguage="ts"` or `"js"`)
309
+ ```html
310
+ <table>
311
+ <thead>
312
+ <tr>
313
+ <th>SKU</th>
314
+ <th>Product Name</th>
315
+ <th>Price</th>
316
+ </tr>
317
+ </thead>
318
+ <tbody>
319
+ <!-- ${items.map(item => ` --><tr>
320
+ <td>${item.sku}</td>
321
+ <td>${item.name}</td>
322
+ <td>${item.price}</td>
323
+ </tr><!-- `).join('')} -->
324
+ </tbody>
325
+ </table>
326
+ ```
251
327
 
328
+ ### Handlebars / Mustache (`templatingLanguage="handlebars"`)
252
329
  ```html
253
- <table style="font-size: 10px; color: #334155; text-align: left; font-weight: 400;">
330
+ <table>
254
331
  <thead>
255
332
  <tr>
256
- <th>Weight</th>
257
- <th>Package Code</th>
258
- <th>Package Net Weight</th>
259
- <th>Package Gross Weight</th>
260
- <th>Package Content</th>
333
+ <th>SKU</th>
334
+ <th>Product Name</th>
335
+ <th>Price</th>
261
336
  </tr>
262
337
  </thead>
263
338
  <tbody>
264
- <!-- {{#each shipment.packages}} --><tr>
265
- <td>{{gross_weight}}</td>
266
- <td>{{package_code}}</td>
267
- <td>{{package.net_weight}}</td>
268
- <td>{{package.gross_weight}}</td>
269
- <td>{{package_content}}</td>
339
+ <!-- {{#each items}} --><tr>
340
+ <td>{{sku}}</td>
341
+ <td>{{name}}</td>
342
+ <td>{{price}}</td>
270
343
  </tr><!-- {{/each}} -->
271
344
  </tbody>
272
345
  </table>
273
346
  ```
274
347
 
275
- ## License
348
+ ### C# / Razor (`templatingLanguage="csharp"`)
349
+ ```html
350
+ <table>
351
+ <thead>
352
+ <tr>
353
+ <th>SKU</th>
354
+ <th>Product Name</th>
355
+ <th>Price</th>
356
+ </tr>
357
+ </thead>
358
+ <tbody>
359
+ <!-- @foreach (var item in items) { --><tr>
360
+ <td>@item.Sku</td>
361
+ <td>@item.Name</td>
362
+ <td>@item.Price</td>
363
+ </tr><!-- } -->
364
+ </tbody>
365
+ </table>
366
+ ```
367
+
368
+ ---
369
+
370
+ ## 📄 License
276
371
 
277
- Proprietary & Commercial License © 2026 [BEO Software Pvt. Ltd.](https://beo-software.in/)
372
+ Proprietary &amp; Commercial License © 2026 [BEO Software Pvt. Ltd.](https://beo-software.in/)
278
373
 
279
374
  All rights reserved. Unauthorized copying, distribution, or commercial use is strictly prohibited. For licensing inquiries, please visit [beo-software.in](https://beo-software.in/).