@ouestfrance/sipa-bms-ui 8.44.0 → 8.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/form/bms-input-code.linters.d.ts +0 -14
- package/dist/sipa-bms-ui.es.js +16 -3
- package/dist/sipa-bms-ui.es.js.map +1 -1
- package/dist/sipa-bms-ui.umd.js +16 -3
- package/dist/sipa-bms-ui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/form/bms-input-code.linters.spec.ts +14 -3
- package/src/components/form/bms-input-code.linters.ts +23 -3
package/dist/sipa-bms-ui.umd.js
CHANGED
|
@@ -112762,12 +112762,25 @@
|
|
|
112762
112762
|
* Limitation : le parser XML est plus strict que le parser HTML du navigateur.
|
|
112763
112763
|
* Les balises void HTML5 non fermées (`<br>`, `<img>`) sont considérées invalides.
|
|
112764
112764
|
*/
|
|
112765
|
+
var ROOT_TAG = "<root>";
|
|
112766
|
+
var htmlErrorOffset = (errorText, code) => {
|
|
112767
|
+
const match = errorText.match(/error on line (\d+) at column (\d+)/i);
|
|
112768
|
+
if (!match) return 0;
|
|
112769
|
+
const line = parseInt(match[1]);
|
|
112770
|
+
const col = parseInt(match[2]) - (line === 1 ? 6 : 0);
|
|
112771
|
+
const lines = code.split("\n");
|
|
112772
|
+
let offset = 0;
|
|
112773
|
+
for (let i = 0; i < line - 1 && i < lines.length; i++) offset += lines[i].length + 1;
|
|
112774
|
+
return Math.min(Math.max(0, offset + col - 1), code.length);
|
|
112775
|
+
};
|
|
112765
112776
|
var htmlDiagnostics = (code) => {
|
|
112766
112777
|
if (!code.trim()) return [];
|
|
112767
|
-
|
|
112778
|
+
const parserError = new DOMParser().parseFromString(`${ROOT_TAG}${code}</root>`, "text/xml").querySelector("parsererror");
|
|
112779
|
+
if (!parserError) return [];
|
|
112780
|
+
const from = htmlErrorOffset(parserError.textContent ?? "", code);
|
|
112768
112781
|
return [{
|
|
112769
|
-
from
|
|
112770
|
-
to: code.length,
|
|
112782
|
+
from,
|
|
112783
|
+
to: Math.min(from + 1, code.length),
|
|
112771
112784
|
severity: "error",
|
|
112772
112785
|
message: "HTML invalide : balise mal formée ou non fermée"
|
|
112773
112786
|
}];
|