-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Enable JS inline edit (& comment/uncomment) in HTML script blocks #923
Conversation
…ic location in the document (in some formats like HTML, mode may vary depending on position due to nested languages). Useful utility for many text-edit commands. Only supports "htmlmixed" and "php" mixed modes currently (see TODO in code). Improves several parts of Brackets: - CSSInlineEditor: simplifies code - EditorCommandHandlers: comment/uncomment now supports JS in HTML script blocks (in both HTML & PHP files) - JavaScriptInlineEditor: now supports JS in HTML script blocks (in both HTML & PHP files) Also includes two small docs cleanups in InlineWidget.
Note: the next pull request will be to move JS quick edit from /disabled into /default. At that point we'd like to code review the whole implementation of the feature (see Trello task). For this pull request, I'd like to just get the immediate diff reviewed. |
@gruehle, since we've talked about getModeForSelection() a bit in the past would you like to review? |
…-test creates Editors so individual testcases have more control over their initialization.
* Gets the syntax-highlighting mode for the current selection or cursor position. (The mode may | ||
* vary within one file due to embedded languages, e.g. JS embedded in an HTML script block). | ||
* Returns null if the mode is not consistent across the whole selection. | ||
* @return {?string} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should mention that the return values correspond with mode names from CodeMirror (or, alternatively, if we want to support a subset we should mention that set here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a link to EditorUtils.getModeFromFileExtension(), which is essentially how we currently document the Editor constructor's mode
argument too.
Initial review complete. |
|
||
// Mode for range - mix of modes | ||
myEditor.setSelection({line: 2, ch: 4}, {line: 3, ch: 7}); | ||
expect(myEditor.getModeForSelection()).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a unit test that selects all text and then calls getModeForSelection()? With the current implementation, this should return "html".
…on range the exposes the limitations of only looking at start & end of range.
Looks good! Merging. |
Enable JS inline edit (& comment/uncomment) in HTML script blocks
Add Editor.getModeForSelection() API for getting the mode at a specific location in the document (in some formats like HTML, mode may vary depending on position due to nested languages). Useful utility for many text-edit commands. Only supports "htmlmixed" and "php" mixed modes currently (see TODO in code, linked to #921).
Improves several parts of Brackets:
Also includes two small docs cleanups in InlineWidget.