Model page: Registry panel lists registry files, elements inside each
- one collapsible header per .archify-registry file with its element count and an Open button that opens the registry view; files start collapsed, the Registry panel open - view types moved to views/viewTypes.ts so the diagram page can open a registry without a circular import - 0.7.1
This commit is contained in:
1 parent
4382730343
commit
de1a57e4c6
8 files changed
+57
-22
No files matched your search
@@ -14,9 +14,9 @@ import { handleWebviewMessage, WebviewMessage } from '../webview/messages';
|
||||
import { makeNonce, messagePage, modelPage, prepareDiagramHtml } from '../webview/page';
|
||||
import { viewer3dOption, viewerRoots } from '../webview/viewer3d';
|
||||
|
||||
export const PREVIEW_VIEW_TYPE = 'archify.preview';
|
||||
/** Default editor for .archify files: the rendered diagram. */
|
||||
export const DIAGRAM_EDITOR_VIEW_TYPE = 'archify.diagram';
|
||||
import { DIAGRAM_EDITOR_VIEW_TYPE, PREVIEW_VIEW_TYPE, REGISTRY_VIEW_TYPE } from './viewTypes';
|
||||
|
||||
export { DIAGRAM_EDITOR_VIEW_TYPE, PREVIEW_VIEW_TYPE };
|
||||
|
||||
interface PreviewState {
|
||||
uri: string;
|
||||
@@ -59,7 +59,11 @@ class DiagramPreview implements vscode.Disposable {
|
||||
return;
|
||||
}
|
||||
if (message.type === 'openDiagram') {
|
||||
void this.openLinked(message.path);
|
||||
void this.openLinked(message.path, DIAGRAM_EDITOR_VIEW_TYPE);
|
||||
return;
|
||||
}
|
||||
if (message.type === 'openRegistry') {
|
||||
void this.openLinked(message.file, REGISTRY_VIEW_TYPE);
|
||||
return;
|
||||
}
|
||||
void handleWebviewMessage(message, this.uri, this.panel);
|
||||
@@ -96,7 +100,7 @@ class DiagramPreview implements vscode.Disposable {
|
||||
}
|
||||
|
||||
/** Opens a diagram of the model, given its path relative to the model root. */
|
||||
private async openLinked(relativePath: string): Promise<void> {
|
||||
private async openLinked(relativePath: string, viewType: string): Promise<void> {
|
||||
if (!this.root) return;
|
||||
const target = vscode.Uri.joinPath(this.root, ...relativePath.split('/'));
|
||||
try {
|
||||
@@ -105,7 +109,7 @@ class DiagramPreview implements vscode.Disposable {
|
||||
vscode.window.showWarningMessage(`Archify: ${relativePath} does not exist in this model.`);
|
||||
return;
|
||||
}
|
||||
await vscode.commands.executeCommand('vscode.openWith', target, DIAGRAM_EDITOR_VIEW_TYPE, vscode.ViewColumn.Active);
|
||||
await vscode.commands.executeCommand('vscode.openWith', target, viewType, vscode.ViewColumn.Active);
|
||||
}
|
||||
|
||||
private showModelPage(model: ModelPanel): void {
|
||||
|
||||
@@ -7,10 +7,9 @@ import { readText } from '../util/files';
|
||||
import { log } from '../util/log';
|
||||
import { handleWebviewMessage, WebviewMessage } from '../webview/messages';
|
||||
import { makeNonce, registryPage } from '../webview/page';
|
||||
import { DIAGRAM_EDITOR_VIEW_TYPE } from './diagramView';
|
||||
import { DIAGRAM_EDITOR_VIEW_TYPE, REGISTRY_VIEW_TYPE } from './viewTypes';
|
||||
|
||||
/** Default editor for .archify-registry files: the elements as cards, each with where it is used. */
|
||||
export const REGISTRY_VIEW_TYPE = 'archify.registry';
|
||||
export { REGISTRY_VIEW_TYPE };
|
||||
|
||||
class RegistryDocument implements vscode.CustomDocument {
|
||||
constructor(readonly uri: vscode.Uri) {}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/** Custom editor view types, in one place so views can refer to each other without importing each other. */
|
||||
export const PREVIEW_VIEW_TYPE = 'archify.preview';
|
||||
/** Default editor for .archify files: the rendered diagram. */
|
||||
export const DIAGRAM_EDITOR_VIEW_TYPE = 'archify.diagram';
|
||||
/** Default editor for .archify-registry files: the elements as cards. */
|
||||
export const REGISTRY_VIEW_TYPE = 'archify.registry';
|
||||
Reference in new issue
Block a user