Mercurial
comparison .cms/lib/codemirror/addon/edit/trailingspace.js @ 0:78edf6b517a0 draft
24.10
author | Coffee CMS <info@coffee-cms.ru> |
---|---|
date | Fri, 11 Oct 2024 22:40:23 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78edf6b517a0 |
---|---|
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others | |
2 // Distributed under an MIT license: https://codemirror.net/5/LICENSE | |
3 | |
4 (function(mod) { | |
5 if (typeof exports == "object" && typeof module == "object") // CommonJS | |
6 mod(require("../../lib/codemirror")); | |
7 else if (typeof define == "function" && define.amd) // AMD | |
8 define(["../../lib/codemirror"], mod); | |
9 else // Plain browser env | |
10 mod(CodeMirror); | |
11 })(function(CodeMirror) { | |
12 CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) { | |
13 if (prev == CodeMirror.Init) prev = false; | |
14 if (prev && !val) | |
15 cm.removeOverlay("trailingspace"); | |
16 else if (!prev && val) | |
17 cm.addOverlay({ | |
18 token: function(stream) { | |
19 for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {} | |
20 if (i > stream.pos) { stream.pos = i; return null; } | |
21 stream.pos = l; | |
22 return "trailingspace"; | |
23 }, | |
24 name: "trailingspace" | |
25 }); | |
26 }); | |
27 }); |