feat(editor): Add wysiwyg editor
This commit is contained in:
@ -561,4 +561,54 @@ export class DeesInputWysiwyg extends DeesInputBase<string> {
|
||||
this.changeSubject.next(this.value);
|
||||
this.requestUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the editor content as raw blocks (lossless)
|
||||
*/
|
||||
public exportBlocks(): IBlock[] {
|
||||
return JSON.parse(JSON.stringify(this.blocks));
|
||||
}
|
||||
|
||||
/**
|
||||
* Import raw blocks (lossless)
|
||||
*/
|
||||
public importBlocks(blocks: IBlock[]): void {
|
||||
this.blocks = JSON.parse(JSON.stringify(blocks));
|
||||
this.updateValue();
|
||||
this.requestUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Export content as HTML regardless of outputFormat setting
|
||||
*/
|
||||
public exportAsHtml(): string {
|
||||
return WysiwygConverters.getHtmlOutput(this.blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export content as Markdown regardless of outputFormat setting
|
||||
*/
|
||||
public exportAsMarkdown(): string {
|
||||
return WysiwygConverters.getMarkdownOutput(this.blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a JSON representation of the editor state (for saving)
|
||||
*/
|
||||
public exportState(): { blocks: IBlock[], outputFormat: OutputFormat } {
|
||||
return {
|
||||
blocks: this.exportBlocks(),
|
||||
outputFormat: this.outputFormat
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore editor state from JSON
|
||||
*/
|
||||
public importState(state: { blocks: IBlock[], outputFormat?: OutputFormat }): void {
|
||||
if (state.outputFormat) {
|
||||
this.outputFormat = state.outputFormat;
|
||||
}
|
||||
this.importBlocks(state.blocks);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user