Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit d882abd

Browse files
committed
Merge pull request #15 from WickedSik/master
Fixing Inline Editor for tag-style directives
2 parents 597b677 + acb865e commit d882abd

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

‎NGUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* https://github.com/adobe/brackets/blob/master/src/language/JSUtils.js */
1+
/* https://github.com/adobe/brackets/blob/master/src/language/JSUtils.js */
22

33
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
44
/*global define, ,ドル brackets, CodeMirror */
@@ -14,6 +14,7 @@ define(function (require, exports, module) {
1414
DocumentManager = brackets.getModule("document/DocumentManager"),
1515
FileUtils = brackets.getModule("file/FileUtils"),
1616
_ = brackets.getModule("thirdparty/lodash"),
17+
CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"),
1718
StringUtils = brackets.getModule("utils/StringUtils");
1819

1920
/**

‎main.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ define(function (require, exports, module) {
1515
var patterns = {
1616
directive: /\.directive\(['"]([a-zA-Z-]+)['"]/g,
1717
controller: /\.controller\(['"](\w+)['"]/g
18-
}
18+
};
1919

2020
/**
2121
* Return the token string that is at the specified position.
@@ -165,30 +165,33 @@ define(function (require, exports, module) {
165165
function provider(hostEditor, pos) {
166166
// Only provide an editor when cursor is in HTML content
167167
if (hostEditor.getModeForSelection() !== "html") {
168+
console.info('AJS: No HTML');
168169
return null;
169170
}
170171

171172
// Only provide an editor if the selection is within a single line
172173
var sel = hostEditor.getSelection();
173174
if (sel.start.line !== sel.end.line) {
175+
console.info('AJS: Multi Selection');
174176
return null;
175177
}
176178

177179
// Always use the selection start for determining the function name. The pos
178180
// parameter is usually the selection end.
179-
var directiveName, controllerName;
180-
181-
if (controllerName = _getControllerName(hostEditor, sel.start)) {
182-
return _createInlineEditor(hostEditor, _getControllerName(hostEditor, sel.start), patterns.controller);
181+
var directiveName = _getDirectiveName(hostEditor, sel.start),
182+
controllerName = _getControllerName(hostEditor, sel.start);
183+
184+
if (controllerName) {
185+
return _createInlineEditor(hostEditor, controllerName, patterns.controller);
183186
}
184187

185-
if (directiveName=_getDirectiveName(hostEditor,sel.start)) {
188+
if (directiveName) {
186189
return _createInlineEditor(hostEditor, directiveName, patterns.directive);
187190
}
188191

189192
return null;
190193
}
191194

192195
// init
193-
EditorManager.registerInlineEditProvider(provider);
194-
});
196+
EditorManager.registerInlineEditProvider(provider,10);
197+
});

‎test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1>Kickass</h1>
3131

3232
<ul ng-controller="Testing">
3333
<li my-directive></li>
34-
34+
<my-directive></my-directive>
3535
</ul>
3636
</body>
3737
</html>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /