| 33 | export type EditorSource = {lang: string; source: string}; |
| 34 | |
| 35 | function extractEditorSources(content: any[]): EditorSource[] { |
| 36 | const sources: EditorSource[] = []; |
| 37 | for (const component of content) { |
| 38 | if (component.content) { |
| 39 | const subsources = extractEditorSources(component.content); |
| 40 | if (subsources.length > 0) { |
| 41 | sources.push(...subsources); |
| 42 | } |
| 43 | } else if (component.componentName === 'codeEditor') { |
| 44 | sources.push({ |
| 45 | lang: component.componentState.lang, |
| 46 | source: component.componentState.source, |
| 47 | }); |
| 48 | } |
| 49 | } |
| 50 | return sources; |
| 51 | } |
| 52 | |
| 53 | function list(): HistoryEntry[] { |
| 54 | return JSON.parse(localStorage.get('history', '[]')); |