Skip to content

Add an editor context menu to apply style to a word/selection#45

Draft
elazarcoh wants to merge 1 commit intojgclark:masterfrom
elazarcoh:apply-style-editor-context-menu
Draft

Add an editor context menu to apply style to a word/selection#45
elazarcoh wants to merge 1 commit intojgclark:masterfrom
elazarcoh:apply-style-editor-context-menu

Conversation

@elazarcoh
Copy link
Copy Markdown
Collaborator

@elazarcoh elazarcoh commented Jan 12, 2022

This PR adds an editor context menu entry for this extension.
It gave you the ability to quickly add/clear style to the selected word(s).
There're up to 10 different styles to choose from. To not make the menu too cluttered, the styles needs to be enabled from the settings. By default, only 3 styles will be enabled.

Due to VSCode limitations, there are some stuff that I would like to have, but they're impossible as far as I know.

  • Since the menus are static, users can't give custom name the styles in the menu. So, currently I called them: Style 3, etc.
    • I can "hack" my way to get this behavior, but it requires VSCode to be restarted after the rename of a style.
  • VSCode menu does not allow any kind of stylization, not even adding an icon. So, the user can't tell how the style looks like without applying it.
    • We might be able to add a TreeView, which will present all available styles, but it might be an overkill.

It's mostly implemented. I need help setting up the default styles. See comment below.

fixes #44

image

Comment thread package.json
Comment on lines +396 to +447
"default": [
{
"id": 1,
"enabled": true,
"backgroundColor": "#ffeb3b"
},
{
"id": 2,
"enabled": true,
"backgroundColor": "#2196f3"
},
{
"id": 3,
"enabled": true,
"backgroundColor": "#ff9800"
},
{
"id": 4,
"enabled": false,
"backgroundColor": "#9c27b0"
},
{
"id": 5,
"enabled": false,
"backgroundColor": "#2e7d32"
},
{
"id": 6,
"enabled": false,
"backgroundColor": "#ff5722"
},
{
"id": 7,
"enabled": false,
"backgroundColor": "#607d8b"
},
{
"id": 8,
"enabled": false,
"backgroundColor": "#795548"
},
{
"id": 9,
"enabled": false,
"backgroundColor": "#ffeb3b"
},
{
"id": 10,
"enabled": false,
"backgroundColor": "#2196f3"
}
]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to edit the default styles.
(I didn't write those, I let copilot generate them for me)

@elazarcoh elazarcoh mentioned this pull request Jan 16, 2022
3 tasks
@jgclark jgclark added the enhancement New feature or request label Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick way to create highlights from editor selection

2 participants