feat: user-managed templates

This commit is contained in:
2026-02-27 20:00:53 +01:00
parent e25a0d85a5
commit f3364999ee
47 changed files with 3664 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
import type { Tab } from '../store/appStore';
import type { SidebarView } from './sidebarViewRegistry';
export type ActivityId = 'posts' | 'pages' | 'media' | 'scripts' | 'tags' | 'chat' | 'import' | 'git' | 'settings';
export type ActivityId = 'posts' | 'pages' | 'media' | 'scripts' | 'templates' | 'tags' | 'chat' | 'import' | 'git' | 'settings';
export interface ActivitySnapshot {
activeView: SidebarView;
@@ -50,6 +50,13 @@ const ACTIVITY_CONFIG: Record<ActivityId, ActivityConfig> = {
activeStrategy: 'sidebar-owner',
clickStrategy: 'sidebar-toggle',
},
templates: {
id: 'templates',
view: 'templates',
labelKey: 'activity.templates',
activeStrategy: 'sidebar-owner',
clickStrategy: 'sidebar-toggle',
},
tags: {
id: 'tags',
view: 'tags',

View File

@@ -16,7 +16,8 @@ export type EditorRoute =
| 'documentation'
| 'api-documentation'
| 'site-validation'
| 'scripts';
| 'scripts'
| 'templates';
export const EDITOR_TAB_ROUTE_REGISTRY: Record<TabType, Exclude<EditorRoute, 'dashboard'>> = {
post: 'post',
@@ -33,6 +34,7 @@ export const EDITOR_TAB_ROUTE_REGISTRY: Record<TabType, Exclude<EditorRoute, 'da
'api-documentation': 'api-documentation',
'site-validation': 'site-validation',
scripts: 'scripts',
templates: 'templates',
};
export interface EditorRouteResolution {

View File

@@ -3,6 +3,7 @@ export const SIDEBAR_VIEW_REGISTRY = [
'pages',
'media',
'scripts',
'templates',
'settings',
'tags',
'chat',

View File

@@ -20,6 +20,7 @@ export interface CanonicalTabSpec {
export type EntityTabType = 'post' | 'media';
export type EntityTabOpenIntent = 'preview' | 'pin';
export type ScriptTabOpenIntent = 'preview' | 'pin';
export type TemplateTabOpenIntent = 'preview' | 'pin';
export type GitDiffResourceOpenIntent = 'preview' | 'pin';
const SINGLETON_TOOL_TAB_REGISTRY: Record<SingletonToolTabKey, CanonicalTabSpec> = {
@@ -112,6 +113,22 @@ export function openScriptTab(
openTab(getScriptTabSpec(scriptId, intent));
}
export function getTemplateTabSpec(templateId: string, intent: TemplateTabOpenIntent): CanonicalTabSpec {
return {
type: 'templates',
id: templateId,
isTransient: intent === 'preview',
};
}
export function openTemplateTab(
openTab: (tab: CanonicalTabSpec) => void,
templateId: string,
intent: TemplateTabOpenIntent,
): void {
openTab(getTemplateTabSpec(templateId, intent));
}
export function getGitDiffFileTabId(filePath: string): string {
return `git-diff:${filePath}`;
}