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

Commit 528ef38

Browse files
committed
Merge pull request #7046 from adobe/rlim/php-inside-css
Skip all embedded php code when parsing the style blocks in php documents.
2 parents aa994d0 + fbccf88 commit 528ef38

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

src/language/HTMLUtils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ define(function (require, exports, module) {
485485
currentBlock = null,
486486
inBlock = false,
487487
outerMode = editor._codeMirror.getMode(),
488-
tokenModeName;
488+
tokenModeName,
489+
previousMode;
489490

490491
while (TokenUtils.moveNextToken(ctx, false)) {
491492
tokenModeName = CodeMirror.innerMode(outerMode, ctx.token.state).mode.name;
@@ -495,7 +496,7 @@ define(function (require, exports, module) {
495496
currentBlock.end = currentBlock.start;
496497
}
497498
// Check for end of this block
498-
if (tokenModeName !== modeName) {
499+
if (tokenModeName === previousMode) {
499500
// currentBlock.end is already set to pos of the last token by now
500501
currentBlock.text = editor.document.getRange(currentBlock.start, currentBlock.end);
501502
inBlock = false;
@@ -510,6 +511,8 @@ define(function (require, exports, module) {
510511
};
511512
blocks.push(currentBlock);
512513
inBlock = true;
514+
} else {
515+
previousMode = tokenModeName;
513516
}
514517
// else, random token: ignore
515518
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<style type="text/css">
5+
{{0}} body {
6+
background: url("<?php echo $img; ?>") no-repeat;
7+
background-size: 100% 100%;
8+
color: white;
9+
}
10+
</style>
11+
</head>
12+
13+
<bo{{1}}dy onclick="goHome()"></body>
14+
</html>

test/spec/InlineEditorProviders-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,21 @@ define(function (require, exports, module) {
297297
});
298298

299299

300+
it("should open a type selector and show correct range including the embedded php", function () {
301+
initInlineTest("test1.php", 1);
302+
303+
runs(function () {
304+
var inlineWidget = EditorManager.getCurrentFullEditor().getInlineWidgets()[0];
305+
var inlinePos = inlineWidget.editor.getCursorPos();
306+
307+
// verify cursor position and displayed range in inline editor
308+
expect(inlinePos).toEqual(infos["test1.php"].offsets[0]);
309+
expect(inlineWidget.editor).toHaveInlineEditorRange(toRange(4, 8));
310+
311+
inlineWidget = null;
312+
});
313+
});
314+
300315
it("should open a type selector on opening tag", function () {
301316
initInlineTest("test1.html", 0);
302317

0 commit comments

Comments
 (0)