feat: user-managed templates
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -3,6 +3,7 @@ export const SIDEBAR_VIEW_REGISTRY = [
|
||||
'pages',
|
||||
'media',
|
||||
'scripts',
|
||||
'templates',
|
||||
'settings',
|
||||
'tags',
|
||||
'chat',
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user