Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
304 changes: 300 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,61 @@
"title": "List highlighted annotations",
"category": "TODO-Highlight",
"command": "todohighlight.listAnnotations"
},
{
"title": "Style 1",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle1"
},
{
"title": "Style 2",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle2"
},
{
"title": "Style 3",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle3"
},
{
"title": "Style 4",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle4"
},
{
"title": "Style 5",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle5"
},
{
"title": "Style 6",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle6"
},
{
"title": "Style 7",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle7"
},
{
"title": "Style 8",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle8"
},
{
"title": "Style 9",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle9"
},
{
"title": "Style 10",
"category": "TODO-Highlight",
"command": "todohighlight.applyStyle10"
},
{
"title": "Clear Style",
"category": "TODO-Highlight",
"command": "todohighlight.clearStyle"
}
],
"configuration": {
Expand All @@ -109,7 +164,7 @@
"scope": "language-overridable",
"markdownDescription": "An array of keywords, and their CSS to customise how they look. See all available properties in the [VSCode doc on DecorationRenderOptions](https://code.visualstudio.com/api/references/vscode-api#DecorationRenderOptions) section.",
"items": {
"anyOf": [
"oneOf": [
{
"type": "string"
},
Expand Down Expand Up @@ -158,7 +213,34 @@
},
"required": [
"text"
]
],
"not": {
"required": [
"styleId"
]
}
},
{
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "Custom text to be highlighted."
},
"styleId": {
"type": "number",
"markdownDescription": "The style ID from the `#todohighlight.styles#`."
}
},
"required": [
"text",
"styleId"
],
"not": {
"required": [
"regex"
]
}
}
]
},
Expand Down Expand Up @@ -265,9 +347,223 @@
"type": "number",
"default": 5120,
"description": "Max files for searching"
},
"todohighlight.styles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"default": true,
"description": "Enable or disable this style from the UI."
},
"id": {
"type": "number",
"minimum": 1,
"maximum": 10
},
"backgroundColor": {
"type": "string",
"description": "The text background color."
},
"border": {
"type": "string",
"description": "The border style for the highlight, as a CSS string."
},
"color": {
"type": "string",
"description": "The text color. "
},
"cursor": {
"type": "string",
"description": "The style for the cursor shown over the highlight, as a CSS property."
},
"isWholeLine": {
"type": "boolean",
"default": false,
"description": "If true, then the whole line is highlighted, not just the matching text."
},
"overviewRulerColor": {
"type": "string",
"description": "The color of the ruler mark on the scroll bar."
}
},
"required": [
"id"
]
},
"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"
}
]
Comment on lines +396 to +447
Copy link
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)

}
}
}
},
"menus": {
"commandPalette": [
{
"command": "todohighlight.applyStyle1",
"when": "false"
},
{
"command": "todohighlight.applyStyle2",
"when": "false"
},
{
"command": "todohighlight.applyStyle3",
"when": "false"
},
{
"command": "todohighlight.applyStyle4",
"when": "false"
},
{
"command": "todohighlight.applyStyle5",
"when": "false"
},
{
"command": "todohighlight.applyStyle6",
"when": "false"
},
{
"command": "todohighlight.applyStyle7",
"when": "false"
},
{
"command": "todohighlight.applyStyle8",
"when": "false"
},
{
"command": "todohighlight.applyStyle9",
"when": "false"
},
{
"command": "todohighlight.applyStyle10",
"when": "false"
},
{
"command": "todohighlight.clearStyle",
"when": "false"
}
],
"editor/context": [
{
"submenu": "todohighlight.editorMenu"
}
],
"todohighlight.editorMenu": [
{
"command": "todohighlight.toggleHighlight"
},
{
"submenu": "todohighlight.applyStyleMenu"
},
{
"command": "todohighlight.clearStyle"
}
],
"todohighlight.applyStyleMenu": [
{
"command": "todohighlight.applyStyle1",
"when": "todohighlight.styleContextKey1"
},
{
"command": "todohighlight.applyStyle2",
"when": "todohighlight.styleContextKey2"
},
{
"command": "todohighlight.applyStyle3",
"when": "todohighlight.styleContextKey3"
},
{
"command": "todohighlight.applyStyle4",
"when": "todohighlight.styleContextKey4"
},
{
"command": "todohighlight.applyStyle5",
"when": "todohighlight.styleContextKey5"
},
{
"command": "todohighlight.applyStyle6",
"when": "todohighlight.styleContextKey6"
},
{
"command": "todohighlight.applyStyle7",
"when": "todohighlight.styleContextKey7"
},
{
"command": "todohighlight.applyStyle8",
"when": "todohighlight.styleContextKey8"
},
{
"command": "todohighlight.applyStyle9",
"when": "todohighlight.styleContextKey9"
},
{
"command": "todohighlight.applyStyle10",
"when": "todohighlight.styleContextKey10"
}
]
},
"submenus": [
{
"id": "todohighlight.editorMenu",
"label": "Todo Highlight"
},
{
"id": "todohighlight.applyStyleMenu",
"label": "Apply Style"
}
]
},
"devDependencies": {
"@types/mocha": "^2.2.32",
Expand All @@ -289,4 +585,4 @@
"vsce": "^1.77.0",
"webpack": "^5.52.0"
}
}
}
Loading