-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Added HtmlSpecialCharsCodeHints as default extension #3237
Added HtmlSpecialCharsCodeHints as default extension #3237
Conversation
This looks great. I have a few suggestions:
|
@TomMalbran Character entity references are case-sensitive. For example, &dagger and &Dagger are different characters. |
@@ -0,0 +1,104 @@ | |||
[ | |||
"&lsquo", "&rsquo", "&sbquo", "&ldquo", "&rdquo", "&bdquo", |
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 think it will be easier to manage this list if it's a single column sorted alphabetically
I know, what I mean is that it would be better if for example [Randy] Sorry, I read you comment wrong. |
// Register code hint providers | ||
var specialCharHints = new SpecialCharHints(); | ||
|
||
CodeHintManager.registerHintProvider(specialCharHints, ["html"], 0); |
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'm seeing a weird problem in this case:
- Start with a paragraph:
<p></p>
- Place cursor between the open and closing tags and type "&"
- The entity hint list is displayed as expected
- Press Esc to dismiss list
- Press Ctrl-space to re-invoke the hints list
Results:
Hints list is displayed, but it's a list of HTML Tags!
It might have something to do with using a priority of 0 to register these hints, which is the default priority. On the other hand, there should be no conflicts with the HTML hints, so not really sure.
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.
actually it the problem is, that the HTML tags hint provider can also provide hints for those and gets called before the specialCharHints, but when i changed the priority to one plus a few other tweaks in the has hints function it worked.
So fixed.
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.
That problem is fixed, but I'm seeing another problem I think it related. Code hints work correctly inside of a tag, but if I type a "raw" & I don't get the hints. For example:
<body>
&
</body>
I'm seeing the entity hints displayed if I type an ampersand inside an attribute value string. For example: |
this.currentQuery = query = this._getQuery(); | ||
result = $.map(specialChars, function (value, index) { | ||
if (value.indexOf(query) === 0) { | ||
return value + " <span style=\"float: right;\">" + value + ";</span>"; |
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.
Create a class and apply class to span tag, instead of inline css.
Also, the code looks cleaner if you nest single-quotes inside of double-quotes:
return value + " <span class='entity-display-char'>" + value + ";</span>";
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.
fixed.
should i add the style to the brackets.less file?
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.
No, you should create a CSS file in your extension directory and load it with ExtensionUtils.loadStyleSheet(module, "styles.css");
on AppInit.htmlReady
.
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 added that.
Done with initial review. |
I found some more entities listed here: http://www.w3.org/TR/html4/sgml/entities.html |
@redmunds i adressed the issues you remarked. |
The trailing |
The numerical entities should be ordered by numerical value, not string value. For example, I see (skipping some values fro brevity):
But it should be:
|
Thanks for adding he other entities I found. There are typos: |
I think the name of this extension is too long. Please rename to: HtmlEntityCodeHints |
return query !== null; | ||
} else { | ||
return implicitChar === "&" || query !== null; | ||
} |
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.
You don't need else
, and removing it makes it easier to see that something is returned in all cases:
if (implicitChar === null) {
return query !== null;
}
return implicitChar === "&" || query !== null;
Done with second code review. |
@redmunds all issues adressed, ready for another review. |
"&ang", | ||
"å", | ||
"Å", | ||
"&asymp", |
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 guess you didn't see the edit to my previous comment, but ≈
is missing (was a typo).
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.
@redmunds already readded both
} | ||
|
||
return a.localeCompare(b); | ||
}); |
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.
Move this code to a named function that you can pass to the sort() method.
This looks great. One last comment! |
@redmunds calling for another review (hopefully the last) |
Looks good. Merging. |
Added HtmlSpecialCharsCodeHints as default extension
I added CodeCompletition for HtmlSpecialChars as requested in https://trello.com/card/code-completion-for-special-characters/4f90a6d98f77505d7940ce88/826