Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Enable JS inline edit (& comment/uncomment) in HTML script blocks #923

Merged
merged 4 commits into from
May 24, 2012

Conversation

peterflynn
Copy link
Member

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:

  • 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.

…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.
@peterflynn
Copy link
Member Author

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.

@peterflynn
Copy link
Member Author

@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.
@ghost ghost assigned gruehle May 23, 2012
* 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}
Copy link
Member

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).

Copy link
Member Author

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.

@gruehle
Copy link
Member

gruehle commented May 23, 2012

Initial review complete.


// Mode for range - mix of modes
myEditor.setSelection({line: 2, ch: 4}, {line: 3, ch: 7});
expect(myEditor.getModeForSelection()).toBeNull();
Copy link
Member

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.
@gruehle
Copy link
Member

gruehle commented May 24, 2012

Looks good! Merging.

gruehle added a commit that referenced this pull request May 24, 2012
Enable JS inline edit (& comment/uncomment) in HTML script blocks
@gruehle gruehle merged commit e12f91f into master May 24, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants