Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

224 changes: 223 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@
"customEditorOutline"
],
"contributes": {
"submenus": [
{
"id": "designer.outline.editSubmenu",
"label": "Edit"
},
{
"id": "designer.outline.modifySubmenu",
"label": "Modify"
},
{
"id": "designer.outline.viewSubmenu",
"label": "View"
}
],
"menus": {
"editor/title": [
{
Expand All @@ -39,6 +53,114 @@
"when": "true",
"group": "navigation"
}
],
"customEditor/outline/toolbar": [
{
"command": "designer.outline.lock",
"group": "inline@1",
"when": "customEditorOutlineItem =~ /^(?!.*:locked)/"
},
{
"command": "designer.outline.unlock",
"group": "inline@1",
"when": "customEditorOutlineItem =~ /:locked/"
},
{
"command": "designer.outline.hideInDesigner",
"group": "inline@2",
"when": "customEditorOutlineItem =~ /^(?!.*:hideDesign)/"
},
{
"command": "designer.outline.showInDesigner",
"group": "inline@2",
"when": "customEditorOutlineItem =~ /:hideDesign/"
},
{
"command": "designer.outline.hideAtRuntime",
"group": "inline@3",
"when": "customEditorOutlineItem =~ /^(?!.*:hideRuntime)/"
},
{
"command": "designer.outline.showAtRuntime",
"group": "inline@3",
"when": "customEditorOutlineItem =~ /:hideRuntime/"
}
],
"customEditor/outline/context": [
{
"submenu": "designer.outline.editSubmenu",
"group": "1_edit"
},
{
"submenu": "designer.outline.modifySubmenu",
"group": "2_modify"
},
{
"submenu": "designer.outline.viewSubmenu",
"group": "3_view"
},
{
"command": "designer.outline.expandChildren",
"group": "4_expandCollapse@1"
},
{
"command": "designer.outline.collapseChildren",
"group": "4_expandCollapse@2"
}
],
"designer.outline.editSubmenu": [
{
"command": "designer.outline.copy",
"group": "1_clipboard@1"
},
{
"command": "designer.outline.cut",
"group": "1_clipboard@2"
},
{
"command": "designer.outline.paste",
"group": "1_clipboard@3"
},
{
"command": "designer.outline.delete",
"group": "2_delete@1"
}
],
"designer.outline.modifySubmenu": [
{
"command": "designer.outline.rotateLeft",
"group": "1_rotate@1"
},
{
"command": "designer.outline.rotateRight",
"group": "1_rotate@2"
},
{
"command": "designer.outline.toFront",
"group": "2_order@1"
},
{
"command": "designer.outline.moveForward",
"group": "2_order@2"
},
{
"command": "designer.outline.moveBackward",
"group": "2_order@3"
},
{
"command": "designer.outline.toBack",
"group": "2_order@4"
}
],
"designer.outline.viewSubmenu": [
{
"command": "designer.outline.moveTo",
"group": "1_navigation@1"
},
{
"command": "designer.outline.jumpTo",
"group": "1_navigation@2"
}
]
},
"commands": [
Expand All @@ -49,6 +171,106 @@
"light": "resources/light/editor.svg",
"dark": "resources/dark/editor.svg"
}
},
{
"command": "designer.outline.lock",
"title": "Lock",
"icon": "$(unlock)"
},
{
"command": "designer.outline.unlock",
"title": "Unlock",
"icon": "$(lock)"
},
{
"command": "designer.outline.hideInDesigner",
"title": "Hide in Designer",
"icon": "$(eye)"
},
{
"command": "designer.outline.showInDesigner",
"title": "Show in Designer",
"icon": "$(eye-closed)"
},
{
"command": "designer.outline.hideAtRuntime",
"title": "Hide at Runtime",
"icon": "$(eye)"
},
{
"command": "designer.outline.showAtRuntime",
"title": "Show at Runtime",
"icon": "$(eye-closed)"
},
{
"command": "designer.outline.copy",
"title": "Copy",
"icon": "$(copy)"
},
{
"command": "designer.outline.cut",
"title": "Cut",
"icon": "$(scissors)"
},
{
"command": "designer.outline.paste",
"title": "Paste",
"icon": "$(clippy)"
},
{
"command": "designer.outline.delete",
"title": "Delete",
"icon": "$(trash)"
},
{
"command": "designer.outline.rotateLeft",
"title": "Rotate Left",
"icon": "$(debug-reverse-continue)"
},
{
"command": "designer.outline.rotateRight",
"title": "Rotate Right",
"icon": "$(debug-continue)"
},
{
"command": "designer.outline.toFront",
"title": "To Front",
"icon": "$(arrow-circle-up)"
},
{
"command": "designer.outline.moveForward",
"title": "Move Forward",
"icon": "$(arrow-up)"
},
{
"command": "designer.outline.moveBackward",
"title": "Move Backward",
"icon": "$(arrow-down)"
},
{
"command": "designer.outline.toBack",
"title": "To Back",
"icon": "$(arrow-circle-down)"
},
{
"command": "designer.outline.moveTo",
"title": "Move To",
"icon": "$(move)"
},
{
"command": "designer.outline.jumpTo",
"title": "Jump To",
"icon": "$(search)"
},
{
"command": "designer.outline.expandChildren",
"title": "Expand Children",
"icon": "$(expand-all)"
},
{
"command": "designer.outline.collapseChildren",
"title": "Collapse Children",
"icon": "$(collapse-all)"
}
],
"customEditors": [
Expand Down Expand Up @@ -112,7 +334,7 @@
"@node-projects/css-parser": "^5.2.0",
"@node-projects/lean-he-esm": "^3.4.1",
"@node-projects/node-html-parser-esm": "^6.4.1",
"@node-projects/web-component-designer": "^0.1.339",
"@node-projects/web-component-designer": "^0.1.340",
"@node-projects/web-component-designer-htmlparserservice-base-custom-webcomponent": "^0.1.5",
"@node-projects/web-component-designer-htmlparserservice-nodehtmlparser": "^0.1.12",
"@node-projects/web-component-designer-stylesheetservice-css-parser": "^0.1.4",
Expand Down
73 changes: 73 additions & 0 deletions src/vscode/DesignerOutlineProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import * as vscode from 'vscode';

export interface SerializedOutlineItem {
id: string;
label: string;
detail?: string;
icon?: string;
contextValue?: string;
children?: SerializedOutlineItem[];
}

function convertItems(items: SerializedOutlineItem[]): vscode.CustomEditorOutlineItem[] {
return items.map(item => ({
id: item.id,
label: item.label,
detail: item.detail,
icon: item.icon ? new vscode.ThemeIcon(item.icon) : undefined,
contextValue: item.contextValue,
children: item.children ? convertItems(item.children) : undefined,
}));
}

interface ResourceState {
items: vscode.CustomEditorOutlineItem[];
webview: vscode.Webview;
}

export class DesignerOutlineProvider implements vscode.CustomEditorOutlineProvider {
private readonly _onDidChangeOutline = new vscode.EventEmitter<vscode.Uri>();
readonly onDidChangeOutline = this._onDidChangeOutline.event;

private readonly _onDidChangeActiveItem = new vscode.EventEmitter<{ uri: vscode.Uri; itemId: string | undefined }>();
readonly onDidChangeActiveItem = this._onDidChangeActiveItem.event;

private readonly _resources = new Map<string, ResourceState>();

setWebview(resource: vscode.Uri, webview: vscode.Webview): void {
const state = this._resources.get(resource.toString());
if (state) {
state.webview = webview;
} else {
this._resources.set(resource.toString(), { items: [], webview });
}
}

removeResource(resource: vscode.Uri): void {
this._resources.delete(resource.toString());
}

updateFromWebview(resource: vscode.Uri, serializedItems: SerializedOutlineItem[]): void {
const state = this._resources.get(resource.toString());
if (state) {
state.items = convertItems(serializedItems);
}
this._onDidChangeOutline.fire(resource);
}

setActive(resource: vscode.Uri, itemId: string | undefined): void {
this._onDidChangeActiveItem.fire({ uri: resource, itemId });
}

provideOutline(resource: vscode.Uri, _token: vscode.CancellationToken): vscode.CustomEditorOutlineItem[] {
return this._resources.get(resource.toString())?.items ?? [];
}

revealItem(resource: vscode.Uri, itemId: string): void {
this._resources.get(resource.toString())?.webview?.postMessage({ type: 'reveal', id: itemId });
}

sendCommand(resource: vscode.Uri, command: string, itemId?: string): void {
this._resources.get(resource.toString())?.webview?.postMessage({ type: 'outlineCommand', command, id: itemId });
}
}
Loading