@@ -7,6 +7,7 @@ import { MessageWrapper } from './messages/MessageManager';
77import MessageComponent from './messages/MessageComponent.svelte' ;
88
99import { JsExecution } from './jsEngine/JsExecution' ;
10+ import { ResultRenderer } from './ResultRenderer' ;
1011
1112export class JsMDRC extends MarkdownRenderChild {
1213 plugin : JsEnginePlugin ;
@@ -68,43 +69,48 @@ export class JsMDRC extends MarkdownRenderChild {
6869 async renderResults ( container : HTMLElement ) : Promise < void > {
6970 const args = this . buildExecutionArgs ( container ) ;
7071 const context = this . buildExecutionContext ( ) ;
71- this . jsExecution = await this . tryRun ( args , context ) ;
72- let result = this . jsExecution . result ;
73-
74- if ( ! result ) {
75- return ;
76- }
77-
78- if ( typeof result === 'string' ) {
79- container . innerText = result ;
80- return ;
81- }
82-
83- if ( result instanceof MarkdownBuilder ) {
84- result = result . toMarkdown ( ) ;
85- }
8672
87- if ( result instanceof MarkdownString ) {
88- console . log ( result . content ) ;
89- await result . render ( container , this . ctx . sourcePath , this ) ;
90- return ;
91- }
92-
93- if ( result instanceof HTMLElement ) {
94- container . append ( result ) ;
95- }
96-
97- if ( result instanceof MessageWrapper ) {
98- new MessageComponent ( {
99- target : container ,
100- props : {
101- messageWrapper : result ,
102- messageManager : this . plugin . messageManager ,
103- showDeleteButton : false ,
104- showMessageSource : false ,
105- } ,
106- } ) ;
107- }
73+ this . jsExecution = await this . tryRun ( args , context ) ;
74+ const result = this . jsExecution . result ;
75+
76+ const renderer = new ResultRenderer ( this . plugin , container , this . ctx . sourcePath , this ) ;
77+ await renderer . render ( result ) ;
78+
79+ //
80+ // if (!result) {
81+ // return;
82+ // }
83+ //
84+ // if (typeof result === 'string') {
85+ // container.innerText = result;
86+ // return;
87+ // }
88+ //
89+ // if (result instanceof MarkdownBuilder) {
90+ // result = result.toMarkdown();
91+ // }
92+ //
93+ // if (result instanceof MarkdownString) {
94+ // console.log(result.content);
95+ // await result.render(container, this.ctx.sourcePath, this);
96+ // return;
97+ // }
98+ //
99+ // if (result instanceof HTMLElement) {
100+ // container.append(result);
101+ // }
102+ //
103+ // if (result instanceof MessageWrapper) {
104+ // new MessageComponent({
105+ // target: container,
106+ // props: {
107+ // messageWrapper: result,
108+ // messageManager: this.plugin.messageManager,
109+ // showDeleteButton: false,
110+ // showMessageSource: false,
111+ // },
112+ // });
113+ // }
108114 }
109115
110116 renderExecutionStats ( container : HTMLElement ) : void {
0 commit comments