Files
data-over-audio/Panels/CodePanel.js
2024-05-15 02:05:48 -04:00

24 lines
735 B
JavaScript

import { htmlEncode } from '../converters';
import BasePanel from './BasePanel';
class CodePanel extends BasePanel {
constructor(title) {
super(title);
this.addCode('code');
}
setCode = (html) => this.setHtmlById('code', html);
appendCode = html => {
let current = this.getHtmlById('code');
if(current !== '') current += document.createElement('br').outerHTML;
this.setHtmlById('code', current + html);
this.scrollToBottom('code');
}
appendText = text => {
let current = this.getHtmlById('code');
if(current !== '') current += document.createElement('br').outerHTML;
this.setHtmlById('code', current + htmlEncode(text));
this.scrollToBottom('code');
}
}
export default CodePanel;