UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

1 lines 1.87 kB
import{PanelUtils}from"../utils/utils.js";import{StylePropertyTreeElement}from"./StylePropertyTreeElement.js";export class StylePropertyHighlighter{styleSidebarPane;constructor(e){this.styleSidebarPane=e}highlightProperty(e){for(const e of this.styleSidebarPane.allSections())for(let t=e.propertiesTreeOutline.firstChild();t;t=t.nextSibling)t.onpopulate();const{treeElement:t,section:n}=this.findTreeElementAndSection((t=>t.property===e));t&&(t.parent&&t.parent.expand(),this.scrollAndHighlightTreeElement(t),n&&n.element.focus())}findAndHighlightSectionBlock(e){const t=this.styleSidebarPane.getSectionBlockByName(e);if(!t||0===t.sections.length)return;const[n]=t.sections;n.showAllItems(),PanelUtils.highlightElement(t.titleElement())}findAndHighlightSection(e,t){const n=this.styleSidebarPane.getSectionBlockByName(t),i=n?.sections.find((t=>t.headerText()===e));i&&n&&(n.expand(!0),i.showAllItems(),PanelUtils.highlightElement(i.element))}findAndHighlightPropertyName(e,t,n){const i=n?this.styleSidebarPane.getSectionBlockByName(n):void 0,l=i?.sections??this.styleSidebarPane.allSections();if(!l)return!1;for(const n of l){if(t&&n.headerText()!==t)continue;if(!n.style().hasActiveProperty(e))continue;i?.expand(!0),n.showAllItems();const l=this.findTreeElementFromSection((t=>t.property.name===e&&!t.overloaded()),n);if(l)return this.scrollAndHighlightTreeElement(l),n.element.focus(),!0}return!1}findTreeElementAndSection(e){for(const t of this.styleSidebarPane.allSections()){const n=this.findTreeElementFromSection(e,t);if(n)return{treeElement:n,section:t}}return{treeElement:null,section:null}}findTreeElementFromSection(e,t){let n=t.propertiesTreeOutline.firstChild();for(;n&&n instanceof StylePropertyTreeElement;){if(e(n))return n;n=n.traverseNextTreeElement(!1,null,!0)}return null}scrollAndHighlightTreeElement(e){PanelUtils.highlightElement(e.listItemElement)}}