mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 09:35:38 -05:00
Merge from vscode ad407028575a77ea387eb7cc219b323dc017b686
This commit is contained in:
committed by
Anthony Dresser
parent
404260b8a0
commit
4ad73d381c
@@ -23,6 +23,9 @@ export function clearNode(node: HTMLElement): void {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use `node.remove()` instead
|
||||
*/
|
||||
export function removeNode(node: HTMLElement): void {
|
||||
if (node.parentNode) {
|
||||
node.parentNode.removeChild(node);
|
||||
@@ -1004,7 +1007,7 @@ export function prepend<T extends Node>(parent: HTMLElement, child: T): T {
|
||||
return child;
|
||||
}
|
||||
|
||||
const SELECTOR_REGEX = /([\w\-]+)?(#([\w\-]+))?((.([\w\-]+))*)/;
|
||||
const SELECTOR_REGEX = /([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;
|
||||
|
||||
export enum Namespace {
|
||||
HTML = 'http://www.w3.org/1999/xhtml',
|
||||
|
||||
@@ -17,6 +17,7 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { renderCodicons, markdownEscapeEscapedCodicons } from 'vs/base/common/codicons';
|
||||
import { resolvePath } from 'vs/base/common/resources';
|
||||
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
|
||||
export interface MarkedOptions extends marked.MarkedOptions {
|
||||
baseUrl?: never;
|
||||
@@ -185,25 +186,32 @@ export function renderMarkdown(markdown: IMarkdownString, options: MarkdownRende
|
||||
|
||||
const actionHandler = options.actionHandler;
|
||||
if (actionHandler) {
|
||||
actionHandler.disposeables.add(DOM.addStandardDisposableListener(element, 'click', event => {
|
||||
let target: HTMLElement | null = event.target;
|
||||
if (target.tagName !== 'A') {
|
||||
target = target.parentElement;
|
||||
if (!target || target.tagName !== 'A') {
|
||||
[DOM.EventType.CLICK, DOM.EventType.AUXCLICK].forEach(event => {
|
||||
actionHandler.disposeables.add(DOM.addDisposableListener(element, event, (e: MouseEvent) => {
|
||||
const mouseEvent = new StandardMouseEvent(e);
|
||||
if (!mouseEvent.leftButton && !mouseEvent.middleButton) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
const href = target.dataset['href'];
|
||||
if (href) {
|
||||
actionHandler.callback(href, event);
|
||||
|
||||
let target: HTMLElement | null = mouseEvent.target;
|
||||
if (target.tagName !== 'A') {
|
||||
target = target.parentElement;
|
||||
if (!target || target.tagName !== 'A') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
onUnexpectedError(err);
|
||||
} finally {
|
||||
event.preventDefault();
|
||||
}
|
||||
}));
|
||||
try {
|
||||
const href = target.dataset['href'];
|
||||
if (href) {
|
||||
actionHandler.callback(href, mouseEvent);
|
||||
}
|
||||
} catch (err) {
|
||||
onUnexpectedError(err);
|
||||
} finally {
|
||||
mouseEvent.preventDefault();
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
// Use our own sanitizer so that we can let through only spans.
|
||||
|
||||
@@ -285,6 +285,10 @@ export class ActionBar extends Disposable implements IActionRunner {
|
||||
index++;
|
||||
}
|
||||
});
|
||||
if (this.focusedItem) {
|
||||
// After a clear actions might be re-added to simply toggle some actions. We should preserve focus #97128
|
||||
this.focus(this.focusedItem);
|
||||
}
|
||||
}
|
||||
|
||||
getWidth(index: number): number {
|
||||
|
||||
@@ -187,14 +187,14 @@ class Label {
|
||||
|
||||
if (typeof label === 'string') {
|
||||
if (!this.singleLabel) {
|
||||
this.container.innerHTML = '';
|
||||
this.container.innerText = '';
|
||||
dom.removeClass(this.container, 'multiple');
|
||||
this.singleLabel = dom.append(this.container, dom.$('a.label-name', { id: options?.domId }));
|
||||
}
|
||||
|
||||
this.singleLabel.textContent = label;
|
||||
} else {
|
||||
this.container.innerHTML = '';
|
||||
this.container.innerText = '';
|
||||
dom.addClass(this.container, 'multiple');
|
||||
this.singleLabel = undefined;
|
||||
|
||||
@@ -250,7 +250,7 @@ class LabelWithHighlights {
|
||||
|
||||
if (typeof label === 'string') {
|
||||
if (!this.singleLabel) {
|
||||
this.container.innerHTML = '';
|
||||
this.container.innerText = '';
|
||||
dom.removeClass(this.container, 'multiple');
|
||||
this.singleLabel = new HighlightedLabel(dom.append(this.container, dom.$('a.label-name', { id: options?.domId })), this.supportCodicons);
|
||||
}
|
||||
@@ -258,7 +258,7 @@ class LabelWithHighlights {
|
||||
this.singleLabel.set(label, options?.matches, options?.title, options?.labelEscapeNewLines);
|
||||
} else {
|
||||
|
||||
this.container.innerHTML = '';
|
||||
this.container.innerText = '';
|
||||
dom.addClass(this.container, 'multiple');
|
||||
this.singleLabel = undefined;
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ export class InputBox extends Widget {
|
||||
this.maxHeight = typeof this.options.flexibleMaxHeight === 'number' ? this.options.flexibleMaxHeight : Number.POSITIVE_INFINITY;
|
||||
|
||||
this.mirror = dom.append(wrapper, $('div.mirror'));
|
||||
this.mirror.innerHTML = ' ';
|
||||
this.mirror.innerText = '\u00a0';
|
||||
|
||||
this.scrollableElement = new ScrollableElement(this.element, { vertical: ScrollbarVisibility.Auto });
|
||||
|
||||
@@ -563,7 +563,7 @@ export class InputBox extends Widget {
|
||||
if (mirrorTextContent) {
|
||||
this.mirror.textContent = value + suffix;
|
||||
} else {
|
||||
this.mirror.innerHTML = ' ';
|
||||
this.mirror.innerText = '\u00a0';
|
||||
}
|
||||
|
||||
this.layout();
|
||||
|
||||
@@ -602,6 +602,10 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
|
||||
return this.items[index].element;
|
||||
}
|
||||
|
||||
indexOf(element: T): number {
|
||||
return this.items.findIndex(item => item.element === element);
|
||||
}
|
||||
|
||||
domElement(index: number): HTMLElement | null {
|
||||
const row = this.items[index].row;
|
||||
return row && row.domNode;
|
||||
|
||||
@@ -1323,6 +1323,10 @@ export class List<T> implements ISpliceable<T>, IThemable, IDisposable {
|
||||
return this.view.element(index);
|
||||
}
|
||||
|
||||
indexOf(element: T): number {
|
||||
return this.view.indexOf(element);
|
||||
}
|
||||
|
||||
get length(): number {
|
||||
return this.view.length;
|
||||
}
|
||||
|
||||
@@ -324,8 +324,7 @@ export class Menu extends ActionBar {
|
||||
if (action instanceof Separator) {
|
||||
return new MenuSeparatorActionViewItem(options.context, action, { icon: true });
|
||||
} else if (action instanceof SubmenuAction) {
|
||||
const actions = Array.isArray(action.actions) ? action.actions : action.actions();
|
||||
const menuActionViewItem = new SubmenuMenuActionViewItem(action, actions, parentData, { ...options, submenuIds: new Set([...(options.submenuIds || []), action.id]) });
|
||||
const menuActionViewItem = new SubmenuMenuActionViewItem(action, action.actions, parentData, { ...options, submenuIds: new Set([...(options.submenuIds || []), action.id]) });
|
||||
|
||||
if (options.enableMnemonics) {
|
||||
const mnemonic = menuActionViewItem.getMnemonic();
|
||||
@@ -791,7 +790,12 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
|
||||
|
||||
private cleanupExistingSubmenu(force: boolean): void {
|
||||
if (this.parentData.submenu && (force || (this.parentData.submenu !== this.mysubmenu))) {
|
||||
this.parentData.submenu.dispose();
|
||||
|
||||
// disposal may throw if the submenu has already been removed
|
||||
try {
|
||||
this.parentData.submenu.dispose();
|
||||
} catch { }
|
||||
|
||||
this.parentData.submenu = undefined;
|
||||
this.updateAriaExpanded('false');
|
||||
if (this.submenuContainer) {
|
||||
@@ -835,7 +839,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
|
||||
|
||||
if (!this.parentData.submenu) {
|
||||
this.updateAriaExpanded('true');
|
||||
this.submenuContainer = document.createElement('div.monaco-submenu');
|
||||
this.submenuContainer = append(this.element, $('div.monaco-submenu'));
|
||||
addClasses(this.submenuContainer, 'menubar-menu-items-holder', 'context-view');
|
||||
|
||||
// Set the top value of the menu container before construction
|
||||
@@ -853,8 +857,6 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
|
||||
this.parentData.submenu.style(this.menuStyle);
|
||||
}
|
||||
|
||||
this.element.appendChild(this.submenuContainer);
|
||||
|
||||
// layout submenu
|
||||
const entryBox = this.element.getBoundingClientRect();
|
||||
const entryBoxUpdated = {
|
||||
|
||||
@@ -217,8 +217,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
|
||||
|
||||
// Intercept keyboard handling
|
||||
|
||||
// React on KEY_UP since the actionBar also reacts on KEY_UP so that appropriate events get canceled
|
||||
this._register(dom.addDisposableListener(this.selectElement, dom.EventType.KEY_UP, (e: KeyboardEvent) => {
|
||||
this._register(dom.addDisposableListener(this.selectElement, dom.EventType.KEY_DOWN, (e: KeyboardEvent) => {
|
||||
const event = new StandardKeyboardEvent(e);
|
||||
let showDropDown = false;
|
||||
|
||||
@@ -235,7 +234,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
|
||||
|
||||
if (showDropDown) {
|
||||
this.showSelectDropDown();
|
||||
dom.EventHelper.stop(e, true);
|
||||
dom.EventHelper.stop(e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export interface IToolBarOptions {
|
||||
actionRunner?: IActionRunner;
|
||||
toggleMenuTitle?: string;
|
||||
anchorAlignmentProvider?: () => AnchorAlignment;
|
||||
renderDropdownAsChildElement?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,6 +40,7 @@ export class ToolBar extends Disposable {
|
||||
private submenuActionViewItems: DropdownMenuActionViewItem[] = [];
|
||||
private hasSecondaryActions: boolean = false;
|
||||
private lookupKeybindings: boolean;
|
||||
private element: HTMLElement;
|
||||
|
||||
private _onDidChangeDropdownVisibility = this._register(new EventMultiplexer<boolean>());
|
||||
readonly onDidChangeDropdownVisibility = this._onDidChangeDropdownVisibility.event;
|
||||
@@ -52,11 +54,11 @@ export class ToolBar extends Disposable {
|
||||
|
||||
this.toggleMenuAction = this._register(new ToggleMenuAction(() => this.toggleMenuActionViewItem?.show(), options.toggleMenuTitle));
|
||||
|
||||
let element = document.createElement('div');
|
||||
element.className = 'monaco-toolbar';
|
||||
container.appendChild(element);
|
||||
this.element = document.createElement('div');
|
||||
this.element.className = 'monaco-toolbar';
|
||||
container.appendChild(this.element);
|
||||
|
||||
this.actionBar = this._register(new ActionBar(element, {
|
||||
this.actionBar = this._register(new ActionBar(this.element, {
|
||||
orientation: options.orientation,
|
||||
ariaLabel: options.ariaLabel,
|
||||
actionRunner: options.actionRunner,
|
||||
@@ -72,7 +74,7 @@ export class ToolBar extends Disposable {
|
||||
keybindingProvider: this.options.getKeyBinding,
|
||||
classNames: toolBarMoreIcon.classNames,
|
||||
anchorAlignmentProvider: this.options.anchorAlignmentProvider,
|
||||
menuAsChild: true
|
||||
menuAsChild: !!this.options.renderDropdownAsChildElement
|
||||
}
|
||||
);
|
||||
this.toggleMenuActionViewItem.setActionContext(this.actionBar.context);
|
||||
@@ -90,10 +92,9 @@ export class ToolBar extends Disposable {
|
||||
}
|
||||
|
||||
if (action instanceof SubmenuAction) {
|
||||
const actions = Array.isArray(action.actions) ? action.actions : action.actions();
|
||||
const result = new DropdownMenuActionViewItem(
|
||||
action,
|
||||
actions,
|
||||
action.actions,
|
||||
contextMenuProvider,
|
||||
{
|
||||
actionViewItemProvider: this.options.actionViewItemProvider,
|
||||
@@ -134,8 +135,8 @@ export class ToolBar extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
getContainer(): HTMLElement {
|
||||
return this.actionBar.getContainer();
|
||||
getElement(): HTMLElement {
|
||||
return this.element;
|
||||
}
|
||||
|
||||
getItemsWidth(): number {
|
||||
|
||||
@@ -881,7 +881,7 @@ class TypeFilterController<T, TFilterData> implements IDisposable {
|
||||
this.messageDomNode.textContent = localize('empty', "No elements found");
|
||||
this._empty = true;
|
||||
} else {
|
||||
this.messageDomNode.innerHTML = '';
|
||||
this.messageDomNode.innerText = '';
|
||||
this._empty = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user