diff --git a/src/sql/azdata.proposed.d.ts b/src/sql/azdata.proposed.d.ts index 74fa06aa02..aa194f2393 100644 --- a/src/sql/azdata.proposed.d.ts +++ b/src/sql/azdata.proposed.d.ts @@ -574,6 +574,19 @@ declare module 'azdata' { onInput: vscode.Event; } + /** + * The heading levels an HTML heading element can be. + */ + export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6; + + export interface TextComponentProperties { + /** + * The heading level for this component - if set the text component will be created as an h# + * HTML element with this value being the #. + */ + headingLevel?: HeadingLevel; + } + export namespace nb { /** * An event that is emitted when the active Notebook editor is changed. diff --git a/src/sql/workbench/api/common/extHostModelView.ts b/src/sql/workbench/api/common/extHostModelView.ts index 957617174b..89287e4663 100644 --- a/src/sql/workbench/api/common/extHostModelView.ts +++ b/src/sql/workbench/api/common/extHostModelView.ts @@ -1370,6 +1370,13 @@ class TextComponentWrapper extends ComponentWrapper implements azdata.TextCompon public set requiredIndicator(requiredIndicator: boolean) { this.setProperty('requiredIndicator', requiredIndicator); } + + public get headingLevel(): azdata.HeadingLevel | undefined { + return this.properties['headingLevel']; + } + public set headingLevel(headingLevel: azdata.HeadingLevel | undefined) { + this.setProperty('headingLevel', headingLevel); + } } class ImageComponentWrapper extends ComponentWithIconWrapper implements azdata.ImageComponentProperties { diff --git a/src/sql/workbench/browser/modelComponents/media/text.css b/src/sql/workbench/browser/modelComponents/media/text.css index 23f032ce4b..b6407ac2a0 100644 --- a/src/sql/workbench/browser/modelComponents/media/text.css +++ b/src/sql/workbench/browser/modelComponents/media/text.css @@ -3,6 +3,11 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +modelview-text div#textContainer { + margin-block-start: 1em; + margin-block-end: 1em; +} + .modelview-text-tooltip { background-size: 12px 12px; background-repeat: no-repeat; @@ -42,7 +47,3 @@ .modelview-text-tooltip:focus .modelview-text-tooltip-content, .modelview-text-tooltip:hover .modelview-text-tooltip-content { visibility: visible; } - -.modelview-text-link { - text-decoration: underline !important; -} diff --git a/src/sql/workbench/browser/modelComponents/text.component.ts b/src/sql/workbench/browser/modelComponents/text.component.ts index ca42069a68..f3a15be186 100644 --- a/src/sql/workbench/browser/modelComponents/text.component.ts +++ b/src/sql/workbench/browser/modelComponents/text.component.ts @@ -24,17 +24,15 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; selector: 'modelview-text', template: `
-

- -

*

+

+
+ *
-

- -

+
` }) export default class TextComponent extends TitledComponent implements IComponent, OnDestroy, AfterViewInit { @@ -91,6 +89,14 @@ export default class TextComponent extends TitledComponent((props) => props.requiredIndicator, false); } + public get headingLevel(): azdata.HeadingLevel | undefined { + return this.getPropertyOrDefault(props => props.headingLevel, undefined); + } + + public set headingLevel(newValue: azdata.HeadingLevel | undefined) { + this.setPropertyFromUI((properties, value) => { properties.headingLevel = value; }, newValue); + } + public override setProperties(properties: { [key: string]: any; }): void { super.setProperties(properties); this.updateText(); @@ -113,9 +119,9 @@ export default class TextComponent extends TitledComponentthis.textContainer.nativeElement).appendChild(textSpan); + const textElement = this.createTextElement(); + textElement.innerText = text.slice(0, placeholderIndex); + (this.textContainer.nativeElement).appendChild(textElement); } // Now insert the link element @@ -140,13 +146,31 @@ export default class TextComponent extends TitledComponentthis.textContainer.nativeElement).appendChild(textSpan); + const textElement = this.createTextElement(); + textElement.innerText = text; + (this.textContainer.nativeElement).appendChild(textElement); } } public get showDiv(): boolean { return this.requiredIndicator || !!this.description; } + + /** + * Creates the appropriate text element based on the type of text component (regular or header) this is + * @returns The text element + */ + private createTextElement(): HTMLElement { + let headingLevel = this.headingLevel; + let element: HTMLElement; + if (!headingLevel) { // Undefined or 0 + element = DOM.$('span'); + } else { + element = DOM.$(`h${headingLevel}`); + } + // Manually set the font-size and font-weight since that is set by the base style sheets which may not be what the user wants + element.style.fontSize = this.CSSStyles['font-size']?.toString(); + element.style.fontWeight = this.CSSStyles['font-weight']?.toString(); + return element; + } }