Browse Source

Add options to ExportTemplate command

pull/5017/head
Artur Arseniev 3 years ago
parent
commit
9628fcf93b
  1. 12
      src/commands/view/ExportTemplate.ts
  2. 2
      src/editor/index.ts

12
src/commands/view/ExportTemplate.ts

@ -1,8 +1,14 @@
import { CommandObject } from './CommandAbstract';
import { EditorParam } from '../../editor';
import { $ } from '../../common';
interface ExportTemplateRunOptions {
optsHtml?: EditorParam<'getHtml', 0>;
optsCss?: EditorParam<'getCss', 0>;
}
export default {
run(editor, sender) {
run(editor, sender, opts: ExportTemplateRunOptions = {}) {
sender && sender.set && sender.set('active', 0);
const config = editor.getConfig();
const modal = editor.Modal;
@ -26,8 +32,8 @@ export default {
})
.getModel()
.once('change:open', () => editor.stopCommand(`${this.id}`));
this.htmlEditor.setContent(editor.getHtml());
this.cssEditor.setContent(editor.getCss());
this.htmlEditor.setContent(editor.getHtml(opts.optsHtml));
this.cssEditor.setContent(editor.getCss(opts.optsCss));
},
stop(editor) {

2
src/editor/index.ts

@ -118,6 +118,8 @@ type EditorConfigType = EditorConfig & { pStylePrefix?: string };
type EditorModelParam<T extends keyof EditorModel, N extends number> = Parameters<EditorModel[T]>[N];
export type EditorParam<T extends keyof Editor, N extends number> = Parameters<Editor[T]>[N];
export default class Editor implements IBaseModule<EditorConfig> {
editorView?: EditorView;
editor: EditorModel;

Loading…
Cancel
Save