Skip to content

Commit

Permalink
Wrap selection in XML element
Browse files Browse the repository at this point in the history
Fixes redhat-developer#794

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Dec 6, 2022
1 parent 6244279 commit 86d5edf
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This VS Code extension provides support for creating and editing XML documents,
| enabled by default | requires additional configuration to enable |

* [RelaxNG (experimental) support](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/RelaxNGFeatures.md#relaxng-features) (since v0.22.0)
* [Surround with Tags,Comments, CDATA](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Refactor.md#refactor) (since v0.23.0)
* Syntax error reporting
* General code completion
* [Auto-close tags](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Features/XMLFeatures.md#xml-tag-auto-close)
Expand Down
23 changes: 23 additions & 0 deletions docs/Refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Refactor

## Surround with Tags (Wrap)

This refactor command gives the capability to select an XML content and surround it with a given tag. To execute this command you can:

* use command palette (`Ctrl+P`) and type `Surround`

![Surround with Tags](images/Refactor/SurroundWithTags.gif)

* use contextual menu

## Surround with Comments

As `Surround with Tags (Wrap)`, you can comments a selected XML content:

![Surround with Tags](images/Refactor/SurroundWithComments.gif)

## Surround with CDATA

As `Surround with Tags (Wrap)`, you can surround with CDATA a selected XML content:

![Surround with Tags](images/Refactor/SurroundWithCDATA.gif)
Binary file added docs/images/Refactor/SurroundWithCDATA.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Refactor/SurroundWithComments.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Refactor/SurroundWithTags.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 46 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -684,17 +684,61 @@
"command": "xml.restart.language.server",
"title": "Restart XML Language Server",
"category": "XML"
},
{
"command": "xml.refactor.surround.with.tags",
"title": "Surround with Tags (Wrap)",
"category": "XML"
},
{
"command": "xml.refactor.surround.with.comments",
"title": "Surround with Comments",
"category": "XML"
},
{
"command": "xml.refactor.surround.with.cdata",
"title": "Surround with CDATA",
"category": "XML"
}
],
"menus": {
"commandPalette": [
{
"command": "xml.validation.current.file",
"when": "editorLangId == xml"
"when": "editorLangId == xml || editorLangId == dtd || editorLangId == xsl || editorLangId == svg"
},
{
"command": "xml.command.bind.grammar",
"when": "resourceFilename =~ /xml/ && editorIsOpen"
},
{
"command": "xml.refactor.surround.with.tags",
"when": "editorLangId == xml || editorLangId == xsl || editorLangId == svg"
},
{
"command": "xml.refactor.surround.with.comments",
"when": "editorLangId == xml || editorLangId == xsl || editorLangId == svg"
},
{
"command": "xml.refactor.surround.with.cdata",
"when": "editorLangId == xml || editorLangId == xsl || editorLangId == svg"
}
],
"editor/context": [
{
"command": "xml.refactor.surround.with.tags",
"when": "editorLangId == xml || editorLangId == xsl || editorLangId == svg",
"group": "1_modification"
},
{
"command": "xml.refactor.surround.with.comments",
"when": "editorLangId == xml || editorLangId == xsl || editorLangId == svg",
"group": "1_modification"
},
{
"command": "xml.refactor.surround.with.cdata",
"when": "editorLangId == xml || editorLangId == xsl || editorLangId == svg",
"group": "1_modification"
}
]
},
Expand All @@ -705,4 +749,4 @@
}
]
}
}
}
11 changes: 10 additions & 1 deletion src/commands/clientCommandConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,13 @@ export const EXECUTE_WORKSPACE_COMMAND = 'xml.workspace.executeCommand';
/**
* Command to restart connection to language server.
*/
export const RESTART_LANGUAGE_SERVER = 'xml.restart.language.server';
export const RESTART_LANGUAGE_SERVER = 'xml.restart.language.server';

/**
* Command to wrap element.
*/
export const REFACTOR_SURROUND_WITH_TAGS = 'xml.refactor.surround.with.tags';

export const REFACTOR_SURROUND_WITH_COMMENTS = 'xml.refactor.surround.with.comments';

export const REFACTOR_SURROUND_WITH_CDATA = 'xml.refactor.surround.with.cdata';
Loading

0 comments on commit 86d5edf

Please sign in to comment.