Skip to content

Commit 43041ce

Browse files
authored
Add ability to customize toolbox titles (#3488) (#3489)
1 parent e2ba309 commit 43041ce

5 files changed

Lines changed: 52 additions & 8 deletions

File tree

source/nodejs/adaptivecards-designer-app/src/app.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ window.onload = function() {
1313
// Uncomment to enabled preview features such as data binding
1414
// ACDesigner.GlobalSettings.previewFeaturesEnabled = true;
1515

16+
// Uncomment to configure default toolbox titles
17+
/*
18+
ACDesigner.Strings.toolboxes.cardEditor.title = "Custom title";
19+
ACDesigner.Strings.toolboxes.cardStructure.title = "Custom title";
20+
ACDesigner.Strings.toolboxes.dataStructure.title = "Custom title";
21+
ACDesigner.Strings.toolboxes.propertySheet.title = "Custom title";
22+
ACDesigner.Strings.toolboxes.sampleDataEditor.title = "Custom title";
23+
ACDesigner.Strings.toolboxes.toolPalette.title = "Custom title";
24+
*/
25+
1626
ACDesigner.CardDesigner.onProcessMarkdown = (text: string, result: { didProcess: boolean, outputHtml: string }) => {
1727
result.outputHtml = new markdownit().render(text);
1828
result.didProcess = true;
@@ -33,6 +43,7 @@ window.onload = function() {
3343
hostContainers.push(new ACDesigner.ToastContainer("Windows Notifications (Preview)", "containers/toast-container.css"));
3444

3545
let designer = new ACDesigner.CardDesigner(hostContainers);
46+
3647
designer.sampleCatalogueUrl = window.location.origin + "/sample-catalogue.json";
3748
designer.attachTo(document.getElementById("designerRootHost"));
3849

source/nodejs/adaptivecards-designer/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ For advanced configuration of the designer use the following APIs.
202202

203203
```js
204204

205+
// Configure toolbox titles
206+
ACDesigner.Strings.toolboxes.cardEditor.title = "Custom card editor title";
207+
ACDesigner.Strings.toolboxes.cardStructure.title = "Custom card structure title";
208+
ACDesigner.Strings.toolboxes.dataStructure.title = "Custom data structure title";
209+
ACDesigner.Strings.toolboxes.propertySheet.title = "Custom property sheet title";
210+
ACDesigner.Strings.toolboxes.sampleDataEditor.title = "Custom sample data editor title";
211+
ACDesigner.Strings.toolboxes.toolPalette.title = "Custom tool palette title";
212+
205213
/* Add the default Microsoft Host Apps */
206214

207215
hostContainers.push(new ACDesigner.WebChatContainer("Bot Framework WebChat", "containers/webchat-container.css"));

source/nodejs/adaptivecards-designer/src/adaptivecards-designer-standalone.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
3+
export * from "./strings";
34
export * from "./shared";
45
export * from "./containers/host-container";
56
export * from "./containers/default/default-container";

source/nodejs/adaptivecards-designer/src/card-designer.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Toolbox, IToolboxCommand } from "./tool-box";
1919
import { FieldDefinition } from "./data";
2020
import { DataTreeItem } from "./data-treeitem";
2121
import { BaseTreeItem } from "./base-tree-item";
22+
import { Strings } from "./strings";
2223
import * as Shared from "./shared";
2324

2425
export class CardDesigner {
@@ -883,7 +884,7 @@ export class CardDesigner {
883884
let toolPaletteHost = document.createElement("div");
884885
toolPaletteHost.className = "acd-dockedPane";
885886

886-
this._toolPaletteToolbox = new Toolbox("toolPalette", "Card Elements");
887+
this._toolPaletteToolbox = new Toolbox("toolPalette", Strings.toolboxes.toolPalette.title);
887888
this._toolPaletteToolbox.content = toolPaletteHost;
888889

889890
let toolPalettePanel = new SidePanel(
@@ -896,10 +897,10 @@ export class CardDesigner {
896897
toolPalettePanel.attachTo(document.getElementById("toolPalettePanel"));
897898

898899
// JSON editors panel
899-
this._cardEditorToolbox = new Toolbox("cardEditor", "Card Payload Editor");
900+
this._cardEditorToolbox = new Toolbox("cardEditor", Strings.toolboxes.cardEditor.title);
900901
this._cardEditorToolbox.content = document.createElement("div");
901902
this._cardEditorToolbox.content.style.padding = "8px";
902-
this._cardEditorToolbox.content.innerText = "Loading editor...";
903+
this._cardEditorToolbox.content.innerText = Strings.loadingEditor;
903904

904905
this._jsonEditorsPanel = new SidePanel(
905906
"jsonEditorPanel",
@@ -918,10 +919,10 @@ export class CardDesigner {
918919
this._jsonEditorsPanel.addToolbox(this._cardEditorToolbox);
919920

920921
if (Shared.GlobalSettings.previewFeaturesEnabled) {
921-
this._sampleDataEditorToolbox = new Toolbox("sampleDataEditor", "Sample Data Editor");
922+
this._sampleDataEditorToolbox = new Toolbox("sampleDataEditor", Strings.toolboxes.sampleDataEditor.title);
922923
this._sampleDataEditorToolbox.content = document.createElement("div");
923924
this._sampleDataEditorToolbox.content.style.padding = "8px";
924-
this._sampleDataEditorToolbox.content.innerText = "Loading editor...";
925+
this._sampleDataEditorToolbox.content.innerText = Strings.loadingEditor;
925926
this._sampleDataEditorToolbox.commands = [
926927
{
927928
title: "Copy the structure of this data into the Data Structure toolbox",
@@ -941,7 +942,7 @@ export class CardDesigner {
941942
let propertySheetHost = document.createElement("div");
942943
propertySheetHost.className = "acd-propertySheet-host";
943944

944-
this._propertySheetToolbox = new Toolbox("propertySheet", "Element Properties");
945+
this._propertySheetToolbox = new Toolbox("propertySheet", Strings.toolboxes.propertySheet.title);
945946
this._propertySheetToolbox.content = propertySheetHost;
946947

947948
let propertySheetPanel = new SidePanel(
@@ -959,7 +960,7 @@ export class CardDesigner {
959960
let treeViewHost = document.createElement("div");
960961
treeViewHost.className = "acd-treeView-host";
961962

962-
this._treeViewToolbox = new Toolbox("treeView", "Card Structure");
963+
this._treeViewToolbox = new Toolbox("treeView", Strings.toolboxes.cardStructure.title);
963964
this._treeViewToolbox.content = treeViewHost;
964965

965966
let treeViewPanel = new SidePanel(
@@ -975,7 +976,7 @@ export class CardDesigner {
975976
let dataExplorerHost = document.createElement("div");
976977
dataExplorerHost.className = "acd-treeView-host";
977978

978-
this._dataToolbox = new Toolbox("data", "Data Structure");
979+
this._dataToolbox = new Toolbox("data", Strings.toolboxes.dataStructure.title);
979980
this._dataToolbox.content = dataExplorerHost;
980981

981982
treeViewPanel.addToolbox(this._dataToolbox);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export class Strings {
2+
static readonly toolboxes = {
3+
toolPalette: {
4+
title: "Card Elements"
5+
},
6+
cardEditor: {
7+
title: "Card Payload Editor"
8+
},
9+
sampleDataEditor: {
10+
title: "Sample Data Editor"
11+
},
12+
propertySheet: {
13+
title: "Element Properties"
14+
},
15+
cardStructure: {
16+
title: "Card Structure"
17+
},
18+
dataStructure: {
19+
title: "Data Structure"
20+
}
21+
};
22+
static loadingEditor = "Loading editor...";
23+
}

0 commit comments

Comments
 (0)