Skip to content

Commit 1578f60

Browse files
committed
feat(yasgui): drop the snippets bar setting
The snippets are in the Insert menu and the Ctrl+K search, so the editor settings no longer offer the snippets bar and a value saved by that checkbox is ignored. Embedders can still show the bar with showSnippetsBar: true.
1 parent c1fb065 commit 1578f60

4 files changed

Lines changed: 8 additions & 64 deletions

File tree

‎docs/developer-guide.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ interface Config {
705705
endpointDescribe: EndpointDescribeConfig;
706706

707707
// Show the snippets bar above the editor. The snippets are always available
708-
// in the Insert menu of the query bar; a user's saved choice takes precedence
708+
// in the Insert menu of the editor and in the Ctrl+K search
709709
showSnippetsBar?: boolean; // default: false
710710

711711
// Page opened by the help button of the top bar; false hides the button

‎docs/user-guide.md‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ Type a URL and press `Enter` to use an endpoint that is not in the list. Press `
410410

411411
Use the arrow keys to move through the menu and `Esc` to close it.
412412

413-
The snippets bar above the editor, which earlier versions showed by default, is now hidden by default. Turn it back on with **Show code snippets bar** in Settings → Editor if you prefer one-click snippet buttons.
413+
You can also find a snippet with the [search](#search) (`Ctrl+K`). The snippets bar that earlier versions showed above the editor is gone, unless the site that embeds MatGUI turns it on.
414414

415415
### Side Panel
416416

@@ -621,22 +621,21 @@ WHERE {
621621

622622
### Code Snippets
623623

624-
Quickly insert common SPARQL patterns and query types with the **Insert** menu of the editor toolbar (see [Insert Menu](#insert-menu)) or, when you turn it on, the code snippets bar above the editor.
624+
Quickly insert common SPARQL patterns and query types with the **Insert** menu of the editor toolbar (see [Insert Menu](#insert-menu)) or the [search](#search) (`Ctrl+K`).
625625

626626
**Features:**
627627

628628
- **Insert menu**: All snippets in one searchable menu, grouped by their group name
629-
- **Snippets bar (optional)**: Hidden by default. Turn it on with **Show code snippets bar** in Settings → Editor to get one button per snippet above the editor
629+
- **Search**: Type part of a snippet's name, group or code in the `Ctrl+K` search and pick it
630630
- **Quick insertion**: Click a snippet to insert code at your cursor position
631631
- **Default snippets**: Includes 5 useful SPARQL snippets (SELECT, CONSTRUCT, ASK, FILTER, OPTIONAL)
632632
- **Dropdown grouping**: When more than 10 snippets are configured, they are grouped in dropdown menus
633633
- **Customizable**: Developers can configure custom snippets
634-
- **Visibility toggle**: Show or hide the snippets bar based on preference
635634

636635
**How to Use:**
637636

638637
1. Position your cursor where you want to insert code
639-
2. Click **Insert** in the editor toolbar and pick a snippet (or click a snippet button in the snippets bar, when it is shown)
638+
2. Click **Insert** in the editor toolbar and pick a snippet, or press `Ctrl+K` and search for it
640639
3. The code is inserted at your cursor position
641640
4. Continue editing as needed
642641

@@ -657,7 +656,7 @@ When more than 10 snippets are configured, they are organized into dropdown menu
657656

658657
**Configuration:**
659658

660-
- Snippets bar visibility is saved in user preferences. It is off by default; a choice you made earlier is kept
659+
- The snippets bar above the editor only shows when the site that embeds MatGUI turns it on (`showSnippetsBar: true`)
661660
- Developers can configure custom snippets with label, code, and group properties
662661
- The bar is hidden automatically when no snippets are configured
663662

‎packages/yasgui/src/TabSettingsModal.ts‎

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -665,38 +665,6 @@ export default class TabSettingsModal {
665665
constructValidationSection.appendChild(constructValidationCheckboxContainer);
666666
constructValidationSection.appendChild(constructValidationHelp);
667667
container.appendChild(constructValidationSection);
668-
669-
// Code Snippets Bar Visibility Section
670-
const snippetsBarSection = document.createElement("div");
671-
addClass(snippetsBarSection, "settingsSection");
672-
673-
const snippetsBarCheckboxContainer = document.createElement("div");
674-
addClass(snippetsBarCheckboxContainer, "checkboxContainer");
675-
676-
const snippetsBarCheckbox = document.createElement("input");
677-
snippetsBarCheckbox.type = "checkbox";
678-
snippetsBarCheckbox.id = "showSnippetsBar";
679-
// Read from global config
680-
const persistedValue = this.tab.yasgui.persistentConfig.getShowSnippetsBar();
681-
snippetsBarCheckbox.checked =
682-
persistedValue !== undefined ? persistedValue : this.tab.yasgui.config.showSnippetsBar === true;
683-
684-
const snippetsBarLabel = document.createElement("label");
685-
snippetsBarLabel.htmlFor = "showSnippetsBar";
686-
snippetsBarLabel.textContent = "Show code snippets bar";
687-
688-
const snippetsBarHelp = document.createElement("div");
689-
snippetsBarHelp.textContent =
690-
"Display the code snippets bar above the editor for quick insertion of common SPARQL patterns. The same snippets are always available from the Insert menu of the query bar.";
691-
addClass(snippetsBarHelp, "settingsHelp");
692-
snippetsBarHelp.style.marginTop = "5px";
693-
694-
snippetsBarCheckboxContainer.appendChild(snippetsBarCheckbox);
695-
snippetsBarCheckboxContainer.appendChild(snippetsBarLabel);
696-
697-
snippetsBarSection.appendChild(snippetsBarCheckboxContainer);
698-
snippetsBarSection.appendChild(snippetsBarHelp);
699-
container.appendChild(snippetsBarSection);
700668
}
701669

702670
private drawEndpointsSettings(container: HTMLElement) {
@@ -1717,26 +1685,6 @@ export default class TabSettingsModal {
17171685
if (constructValidationCheckbox) {
17181686
yasqe.setCheckConstructVariables(constructValidationCheckbox.checked);
17191687
}
1720-
const snippetsBarCheckbox = document.getElementById("showSnippetsBar") as HTMLInputElement;
1721-
if (snippetsBarCheckbox) {
1722-
// Save globally to config and persistent storage
1723-
this.tab.yasgui.config.showSnippetsBar = snippetsBarCheckbox.checked;
1724-
this.tab.yasgui.persistentConfig.setShowSnippetsBar(snippetsBarCheckbox.checked);
1725-
1726-
// Apply to all tabs by updating each Yasqe instance's config and refreshing
1727-
this.tab.yasgui.persistentConfig.getTabs().forEach((tabId: string) => {
1728-
const tab = this.tab.yasgui.getTab(tabId);
1729-
if (tab) {
1730-
const tabYasqe = tab.getYasqe();
1731-
if (tabYasqe) {
1732-
// Update the individual Yasqe instance's config
1733-
tabYasqe.config.showSnippetsBar = snippetsBarCheckbox.checked;
1734-
// Refresh the snippets bar to reflect the change
1735-
tabYasqe.refreshSnippetsBar();
1736-
}
1737-
}
1738-
});
1739-
}
17401688
yasqe.saveQuery();
17411689
}
17421690

‎packages/yasgui/src/index.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,8 @@ export class Yasgui extends EventEmitter {
208208
// Set persistentConfig reference in ThemeManager so it can access CodeMirror theme preference
209209
this.themeManager.setPersistentConfig(this.persistentConfig);
210210

211-
// Load persisted showSnippetsBar if available
212-
const persistedShowSnippetsBar = this.persistentConfig.getShowSnippetsBar();
213-
if (persistedShowSnippetsBar !== undefined) {
214-
this.config.showSnippetsBar = persistedShowSnippetsBar;
215-
}
211+
// The snippets bar only shows when the embedder turns it on with `showSnippetsBar: true`; the snippets
212+
// are in the Insert menu and the Ctrl+K search. A value saved by the former settings checkbox is ignored.
216213

217214
// Load persisted orientation if available
218215
const persistedOrientation = this.persistentConfig.getOrientation();

0 commit comments

Comments
 (0)