Skip to content

Commit

Permalink
Support for value labels
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischrischris committed Feb 23, 2025
1 parent 2d240ed commit c7397d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ typings/

.DS_Store
.idea/*
.cursorrules
8 changes: 5 additions & 3 deletions blocks/edit/prose/plugins/slashMenu/keyAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export function processKeyData(data) {
const blocks = itemBlocks.split(',').map((block) => block.trim());

const values = item.values.toLowerCase().split(',').map((v) => {
const val = v.trim();
const [label, val] = v.split('=').map((vb) => vb.trim());

return {
title: val,
command: (state, dispatch) => insertAutocompleteText(state, dispatch, val),
title: label,
value: val || label,
command: (state, dispatch) => insertAutocompleteText(state, dispatch, val || label),
class: 'key-autocomplete',
};
});
Expand Down
4 changes: 2 additions & 2 deletions blocks/edit/prose/plugins/slashMenu/slash-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ export default class SlashMenu extends LitElement {
return html`
<div class="slash-menu-items">
${filteredItems.map((item, index) => {
const isColor = isColorCode(item.title);
const isColor = isColorCode(item.value);
return html`
<div
class="slash-menu-item ${index === this.selectedIndex ? 'selected' : ''}"
@click=${() => this.handleItemClick(item)}
>
${isColor
? createColorSquare(item.title)
? createColorSquare(item.value)
: html`<span class="slash-menu-icon ${item.class || ''}"></span>`}
<span class="slash-menu-label">
${item.title}
Expand Down
2 changes: 2 additions & 0 deletions blocks/edit/prose/plugins/slashMenu/slashMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class SlashMenuView {
this.menu.addEventListener('reset-slashmenu', () => {
// reset menu to default items
this.menu.items = menuItems;
this.menu.left = 0;
this.menu.top = 0;
});
}

Expand Down

0 comments on commit c7397d0

Please sign in to comment.