Every Archify page can show its file's YAML in place. Diagrams get Diagram | Graph | Source (Graph only inside a model), main.archify Model | Graph | Source, registry and decision pages View | Source, and the Graph page a Source segment. 2D | 3D moves left of that switch and hides while Source shows. The YAML opens in a CodeMirror editor inside the page (dist/source.js, loaded on first use), themed with the page's colours. Edits go to the VS Code document as WorkspaceEdits; outside changes come back to the page. Undo and redo are the editor's own, since VS Code sends ⌘Z in a focused webview to the webview; save and find stay VS Code's. Problems come from the host only (what the Problems panel holds for the file) and are counted on the Source segment; completion and hover come from the schema, folded into one draft-07 document per diagram type. The host now checks .archify files against the extension's schema with ajv on the YAML as written, before archify validate, and checks .archify-registry files against the registry schema for the first time. Registry and decision pages become text editor providers. While Source shows, new renders wait and appear when the picture comes back. Show Source switches the page to Source; Open in Text Editor (the editor title button) opens the text beside it, as Show Source did. The decision schema is no longer given to the YAML extension. Fixed: YAML errors in registry and decision files were reported on line 1; "Webview is disposed" when a diagram closed mid-render; the model heading under the toolbar in narrow editors.
26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
import * as vscode from 'vscode';
|
|
|
|
/** Folder of the bundled webview scripts; webviews may load files from it. */
|
|
export function viewerRoots(extensionUri: vscode.Uri): vscode.Uri[] {
|
|
return [vscode.Uri.joinPath(extensionUri, 'dist')];
|
|
}
|
|
|
|
/** Page option that adds the 3D viewer to an Archify page. */
|
|
export function viewer3dOption(webview: vscode.Webview, extensionUri: vscode.Uri): { scriptUri: string; defaultView: '2d' | '3d' } {
|
|
const defaultView = vscode.workspace.getConfiguration('archify').get<string>('defaultView', '2d') === '3d' ? '3d' : '2d';
|
|
return {
|
|
scriptUri: webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, 'dist', 'viewer3d.js')).toString(),
|
|
defaultView,
|
|
};
|
|
}
|
|
|
|
/** The Graph page script (a webview URI). */
|
|
export function graphScriptUri(webview: vscode.Webview, extensionUri: vscode.Uri): string {
|
|
return webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, 'dist', 'graph.js')).toString();
|
|
}
|
|
|
|
/** The Source view script (a webview URI), loaded by the page the first time Source is chosen. */
|
|
export function sourceScriptUri(webview: vscode.Webview, extensionUri: vscode.Uri): string {
|
|
return webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, 'dist', 'source.js')).toString();
|
|
}
|