Skip to content

Commit ecd1206

Browse files
committed
fix: 🐛 Code selection in case AllowScript
1 parent e312213 commit ecd1206

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-web-visual-editor",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"displayName": "Web Visual Editor",
55
"description": "Edit HTML files visually.",
66
"categories": [

src/visualEditor.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,15 @@ export class VisualEditorProvider implements vscode.CustomTextEditorProvider {
285285
}
286286
}
287287
nameToRemove.forEach(name => el.removeAttribute(name));
288-
// Add source code location information to all elements in body
289-
const location = dom.nodeLocation(el);
290-
if (!location) { throw Error(`Failed to get nodeLocation of element ${el}`); }
291-
el.setAttribute('data-wve-code-start', location.startOffset.toString());
292-
el.setAttribute('data-wve-code-end', location.endOffset.toString());
293288
});
294289
}
290+
document.querySelectorAll('body *, body').forEach(el => {
291+
// Add source code location information to all elements in body
292+
const location = dom.nodeLocation(el);
293+
if (!location) { throw Error(`Failed to get nodeLocation of element ${el}`); }
294+
el.setAttribute('data-wve-code-start', location.startOffset.toString());
295+
el.setAttribute('data-wve-code-end', location.endOffset.toString());
296+
});
295297
// Disable links and file selection inputs
296298
document.body.querySelectorAll('a[href]').forEach(
297299
el => el.setAttribute('onclick', 'event.preventDefault(), event.stopPropagation()')

0 commit comments

Comments
 (0)