|
|
@ -2,14 +2,21 @@ import { Model } from '../../common'; |
|
|
import Component from '../../dom_components/model/Component'; |
|
|
import Component from '../../dom_components/model/Component'; |
|
|
import EditorModel from '../../editor/model/Editor'; |
|
|
import EditorModel from '../../editor/model/Editor'; |
|
|
|
|
|
|
|
|
type HTMLGeneratorBuildOptions = { |
|
|
export type HTMLGeneratorBuildOptions = { |
|
|
em?: EditorModel; |
|
|
/** |
|
|
|
|
|
* Remove unnecessary IDs (eg. those created automatically). |
|
|
|
|
|
*/ |
|
|
cleanId?: boolean; |
|
|
cleanId?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* You can pass an object of custom attributes to replace with the current ones |
|
|
|
|
|
* or you can even pass a function to generate attributes dynamically. |
|
|
|
|
|
*/ |
|
|
attributes?: Record<string, any> | ((component: Component, attr: Record<string, any>) => Record<string, any>); |
|
|
attributes?: Record<string, any> | ((component: Component, attr: Record<string, any>) => Record<string, any>); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export default class HTMLGenerator extends Model { |
|
|
export default class HTMLGenerator extends Model { |
|
|
build(model: Component, opts: HTMLGeneratorBuildOptions = {}) { |
|
|
build(model: Component, opts: HTMLGeneratorBuildOptions & { em?: EditorModel } = {}) { |
|
|
const { em, ...restOpts } = opts; |
|
|
const { em, ...restOpts } = opts; |
|
|
const htmlOpts = restOpts; |
|
|
const htmlOpts = restOpts; |
|
|
|
|
|
|
|
|
|