2026-07-12 11:05:53 +00:00
|
|
|
interface RegistryEntry
|
|
|
|
|
{
|
|
|
|
|
suffix: string;
|
|
|
|
|
editor: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class FileEditorRegistry
|
|
|
|
|
{
|
|
|
|
|
static readonly DefaultEntries: RegistryEntry[] =
|
|
|
|
|
[
|
2026-07-16 13:06:33 +00:00
|
|
|
{ suffix: 'rojo', editor: 'RojoSettingsPanel' },
|
page-editor-panel: replace html-editor-panel with structured .page editor
Renames html-editor-panel → page-editor-panel and changes the handled
extension from .html/.htm to .page. The new editor introduces a structured
format (page-header / page-root / page-block / page-area / page-footer),
a block registry with Full Width and Two Columns templates, a two-mode
sidebar (Blocks / Areas), rich-text wrapSelection helper, auto-template
injection for empty files, sandbox="allow-same-origin" on the iframe,
and editor-style injection that is stripped before saving.
Adds a default-roject theme (dark BG, Barlow font, blue headings) embedded
as a <style> block in the page <head>, scoped to [data-theme="default-roject"]
on both <body> and <page-root>. Areas toolbar gains H1, H2, H3 buttons.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-24 19:07:32 +00:00
|
|
|
{ suffix: 'page', editor: 'PageEditorPanel' },
|
2026-07-12 11:05:53 +00:00
|
|
|
{ suffix: 'js', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'ts', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'css', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'json', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'md', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'txt', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'svg', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'xml', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'yaml', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'yml', editor: 'CodePanel' },
|
Editor: auth redirect, targeted file open, Godot file types
- editor-shell: redirect to / if not authenticated on load
- file-tree: open file in first clean matching panel, create new panel if all dirty
- Editor: add openDocumentIn() with targetElement for precise panel targeting
- panels: skip onDocumentOpened if targeted at a different panel
- FileEditorRegistry: add Godot extensions (gd, gdshader, gdshaderinc, gdinclude, glsl, tscn, tres, cs, gdextension)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-17 20:22:42 +00:00
|
|
|
{ suffix: 'sh', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'py', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'cs', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'gd', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'gdshader', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'gdshaderinc', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'gdinclude', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'glsl', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'tscn', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'tres', editor: 'CodePanel' },
|
|
|
|
|
{ suffix: 'gdextension', editor: 'CodePanel' },
|
2026-07-12 11:05:53 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
static readonly EditorTagNames: Record<string, string> =
|
|
|
|
|
{
|
2026-07-16 13:06:33 +00:00
|
|
|
'RojoSettingsPanel': 'rojo-settings-panel',
|
page-editor-panel: replace html-editor-panel with structured .page editor
Renames html-editor-panel → page-editor-panel and changes the handled
extension from .html/.htm to .page. The new editor introduces a structured
format (page-header / page-root / page-block / page-area / page-footer),
a block registry with Full Width and Two Columns templates, a two-mode
sidebar (Blocks / Areas), rich-text wrapSelection helper, auto-template
injection for empty files, sandbox="allow-same-origin" on the iframe,
and editor-style injection that is stripped before saving.
Adds a default-roject theme (dark BG, Barlow font, blue headings) embedded
as a <style> block in the page <head>, scoped to [data-theme="default-roject"]
on both <body> and <page-root>. Areas toolbar gains H1, H2, H3 buttons.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-24 19:07:32 +00:00
|
|
|
'PageEditorPanel': 'page-editor-panel',
|
2026-07-12 11:05:53 +00:00
|
|
|
'CodePanel': 'code-panel',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
projectEntries: RegistryEntry[] | null = null;
|
|
|
|
|
_loaded = false;
|
|
|
|
|
|
|
|
|
|
async load( projectId: string ): Promise<void>
|
|
|
|
|
{
|
|
|
|
|
if ( this._loaded ) return;
|
|
|
|
|
this._loaded = true;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const res = await fetch( `/api/files/${projectId}/workspace/editor/file-editors.json` );
|
|
|
|
|
if ( ! res.ok ) return;
|
|
|
|
|
const data = await res.json();
|
|
|
|
|
if ( Array.isArray( data ) ) this.projectEntries = data;
|
|
|
|
|
}
|
|
|
|
|
catch {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resolve( filePath: string ): string | null
|
|
|
|
|
{
|
|
|
|
|
const filename = filePath.slice( filePath.lastIndexOf( '/' ) + 1 );
|
|
|
|
|
|
|
|
|
|
if ( this.projectEntries !== null )
|
|
|
|
|
{
|
|
|
|
|
const editor = this._matchSuffix( filename, this.projectEntries );
|
|
|
|
|
if ( editor !== null ) return this._resolveTag( editor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const editor = this._matchSuffix( filename, FileEditorRegistry.DefaultEntries );
|
|
|
|
|
if ( editor !== null ) return this._resolveTag( editor );
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_resolveTag( editorName: string ): string
|
|
|
|
|
{
|
|
|
|
|
return FileEditorRegistry.EditorTagNames[ editorName ] ?? editorName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_matchSuffix( filename: string, entries: RegistryEntry[] ): string | null
|
|
|
|
|
{
|
|
|
|
|
for ( const entry of entries )
|
|
|
|
|
{
|
|
|
|
|
if ( filename.endsWith( '.' + entry.suffix ) )
|
|
|
|
|
{
|
|
|
|
|
return entry.editor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|