build: vendor CodeMirror 5.65.16 for the source editor

This commit is contained in:
2026-11-06 08:23:13 +08:00
parent b2a4fd41ca
commit 8b4d1fa03e
14 changed files with 100 additions and 0 deletions

21
assets/codemirror/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (C) 2017 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,17 @@
# CodeMirror 5.65.16 (vendored)
MIT-licensed source editor used only in edit mode. Nothing here is loaded at
startup: Rust injects the concatenated bundle the first time the page asks for
it (`need-editor` IPC), then calls `window.__mdpOnEditorSource()`.
Files are the minified builds from the cdnjs 5.65.16 package
(`https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.16/`):
- `codemirror.min.js`, `codemirror.min.css`
- `mode/xml/xml.min.js`, `mode/meta.min.js`, `mode/markdown/markdown.min.js`
- `addon/search/searchcursor.min.js`, `addon/search/search.min.js`
- `addon/dialog/dialog.min.js`, `addon/dialog/dialog.css`
- `addon/fold/foldcode.min.js`, `addon/fold/foldgutter.min.js`, `addon/fold/foldgutter.css`
See `LICENSE` for the upstream license. Keep this directory offline-only; do
not point the page at a CDN.

View File

@@ -0,0 +1,32 @@
.CodeMirror-dialog {
position: absolute;
left: 0; right: 0;
background: inherit;
z-index: 15;
padding: .1em .8em;
overflow: hidden;
color: inherit;
}
.CodeMirror-dialog-top {
border-bottom: 1px solid #eee;
top: 0;
}
.CodeMirror-dialog-bottom {
border-top: 1px solid #eee;
bottom: 0;
}
.CodeMirror-dialog input {
border: none;
outline: none;
background: transparent;
width: 20em;
color: inherit;
font-family: monospace;
}
.CodeMirror-dialog button {
font-size: 70%;
}

View File

@@ -0,0 +1 @@
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(s){function f(e,o,n){var e=e.getWrapperElement(),t=e.appendChild(document.createElement("div"));return t.className=n?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof o?t.innerHTML=o:t.appendChild(o),s.addClass(e,"dialog-opened"),t}function p(e,o){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=o}s.defineExtension("openDialog",function(e,o,n){n=n||{},p(this,null);var t=f(this,e,n.bottom),i=!1,r=this;function u(e){"string"==typeof e?l.value=e:i||(i=!0,s.rmClass(t.parentNode,"dialog-opened"),t.parentNode.removeChild(t),r.focus(),n.onClose&&n.onClose(t))}var l=t.getElementsByTagName("input")[0];return l?(l.focus(),n.value&&(l.value=n.value,!1!==n.selectValueOnOpen&&l.select()),n.onInput&&s.on(l,"input",function(e){n.onInput(e,l.value,u)}),n.onKeyUp&&s.on(l,"keyup",function(e){n.onKeyUp(e,l.value,u)}),s.on(l,"keydown",function(e){n&&n.onKeyDown&&n.onKeyDown(e,l.value,u)||((27==e.keyCode||!1!==n.closeOnEnter&&13==e.keyCode)&&(l.blur(),s.e_stop(e),u()),13==e.keyCode&&o(l.value,e))}),!1!==n.closeOnBlur&&s.on(t,"focusout",function(e){null!==e.relatedTarget&&u()})):(e=t.getElementsByTagName("button")[0])&&(s.on(e,"click",function(){u(),r.focus()}),!1!==n.closeOnBlur&&s.on(e,"blur",u),e.focus()),u}),s.defineExtension("openConfirm",function(e,o,n){p(this,null);var t=f(this,e,n&&n.bottom),i=t.getElementsByTagName("button"),r=!1,u=this,l=1;function a(){r||(r=!0,s.rmClass(t.parentNode,"dialog-opened"),t.parentNode.removeChild(t),u.focus())}i[0].focus();for(var c=0;c<i.length;++c){var d=i[c];!function(o){s.on(d,"click",function(e){s.e_preventDefault(e),a(),o&&o(u)})}(o[c]),s.on(d,"blur",function(){--l,setTimeout(function(){l<=0&&a()},200)}),s.on(d,"focus",function(){++l})}}),s.defineExtension("openNotification",function(e,o){p(this,r);var n,t=f(this,e,o&&o.bottom),i=!1,e=o&&void 0!==o.duration?o.duration:5e3;function r(){i||(i=!0,clearTimeout(n),s.rmClass(t.parentNode,"dialog-opened"),t.parentNode.removeChild(t))}return s.on(t,"click",function(e){s.e_preventDefault(e),r()}),e&&(n=setTimeout(r,e)),r})});

View File

@@ -0,0 +1 @@
!function(n){"object"==typeof exports&&"object"==typeof module?n(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(c){"use strict";function t(t,i,n,f){n&&n.call?(l=n,n=null):l=a(t,n,"rangeFinder"),"number"==typeof i&&(i=c.Pos(i,0));var l,d=a(t,n,"minFoldSize");function o(n){var o=l(t,i);if(!o||o.to.line-o.from.line<d)return null;if("fold"===f)return o;for(var e=t.findMarksAt(o.from),r=0;r<e.length;++r)if(e[r].__isFold){if(!n)return null;o.cleared=!0,e[r].clear()}return o}var e,r,u=o(!0);if(a(t,n,"scanUp"))for(;!u&&i.line>t.firstLine();)i=c.Pos(i.line-1,0),u=o(!1);u&&!u.cleared&&"unfold"!==f&&(e=function(n,o,e){n=a(n,o,"widget");"function"==typeof n&&(n=n(e.from,e.to));"string"==typeof n?(o=document.createTextNode(n),(n=document.createElement("span")).appendChild(o),n.className="CodeMirror-foldmarker"):n=n&&n.cloneNode(!0);return n}(t,n,u),c.on(e,"mousedown",function(n){r.clear(),c.e_preventDefault(n)}),(r=t.markText(u.from,u.to,{replacedWith:e,clearOnEnter:a(t,n,"clearOnEnter"),__isFold:!0})).on("clear",function(n,o){c.signal(t,"unfold",t,n,o)}),c.signal(t,"fold",t,u.from,u.to))}c.newFoldFunction=function(e,r){return function(n,o){t(n,o,{rangeFinder:e,widget:r})}},c.defineExtension("foldCode",function(n,o,e){t(this,n,o,e)}),c.defineExtension("isFolded",function(n){for(var o=this.findMarksAt(n),e=0;e<o.length;++e)if(o[e].__isFold)return!0}),c.commands.toggleFold=function(n){n.foldCode(n.getCursor())},c.commands.fold=function(n){n.foldCode(n.getCursor(),null,"fold")},c.commands.unfold=function(n){n.foldCode(n.getCursor(),{scanUp:!1},"unfold")},c.commands.foldAll=function(e){e.operation(function(){for(var n=e.firstLine(),o=e.lastLine();n<=o;n++)e.foldCode(c.Pos(n,0),{scanUp:!1},"fold")})},c.commands.unfoldAll=function(e){e.operation(function(){for(var n=e.firstLine(),o=e.lastLine();n<=o;n++)e.foldCode(c.Pos(n,0),{scanUp:!1},"unfold")})},c.registerHelper("fold","combine",function(){var t=Array.prototype.slice.call(arguments,0);return function(n,o){for(var e=0;e<t.length;++e){var r=t[e](n,o);if(r)return r}}}),c.registerHelper("fold","auto",function(n,o){for(var e=n.getHelpers(o,"fold"),r=0;r<e.length;r++){var t=e[r](n,o);if(t)return t}});var r={rangeFinder:c.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1,clearOnEnter:!0};function a(n,o,e){if(o&&void 0!==o[e])return o[e];o=n.options.foldOptions;return(o&&void 0!==o[e]?o:r)[e]}c.defineOption("foldOptions",null),c.defineExtension("foldOption",function(n,o){return a(this,n,o)})});

View File

@@ -0,0 +1,20 @@
.CodeMirror-foldmarker {
color: blue;
text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
font-family: arial;
line-height: .3;
cursor: pointer;
}
.CodeMirror-foldgutter {
width: .7em;
}
.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
cursor: pointer;
}
.CodeMirror-foldgutter-open:after {
content: "\25BE";
}
.CodeMirror-foldgutter-folded:after {
content: "\25B8";
}

View File

@@ -0,0 +1 @@
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("./foldcode")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./foldcode"],t):t(CodeMirror)}(function(n){"use strict";n.defineOption("foldGutter",!1,function(t,o,e){e&&e!=n.Init&&(t.clearGutter(t.state.foldGutter.options.gutter),t.state.foldGutter=null,t.off("gutterClick",d),t.off("changes",u),t.off("viewportChange",l),t.off("fold",m),t.off("unfold",m),t.off("swapDoc",u),t.off("optionChange",a)),o&&(t.state.foldGutter=new r(function(t){!0===t&&(t={});null==t.gutter&&(t.gutter="CodeMirror-foldgutter");null==t.indicatorOpen&&(t.indicatorOpen="CodeMirror-foldgutter-open");null==t.indicatorFolded&&(t.indicatorFolded="CodeMirror-foldgutter-folded");return t}(o)),f(t),t.on("gutterClick",d),t.on("changes",u),t.on("viewportChange",l),t.on("fold",m),t.on("unfold",m),t.on("swapDoc",u),t.on("optionChange",a))});var c=n.Pos;function r(t){this.options=t,this.from=this.to=0}function s(t,o){for(var e=t.findMarks(c(o,0),c(o+1,0)),n=0;n<e.length;++n)if(e[n].__isFold){var r=e[n].find(-1);if(r&&r.line===o)return e[n]}}function p(t){var o;return"string"==typeof t?((o=document.createElement("div")).className=t+" CodeMirror-guttermarker-subtle",o):t.cloneNode(!0)}function i(r,t,o){var i=r.state.foldGutter.options,f=t-1,d=r.foldOption(i,"minFoldSize"),a=r.foldOption(i,"rangeFinder"),u="string"==typeof i.indicatorFolded&&e(i.indicatorFolded),l="string"==typeof i.indicatorOpen&&e(i.indicatorOpen);r.eachLine(t,o,function(t){++f;var o=null,e=(e=t.gutterMarkers)&&e[i.gutter];if(s(r,f)){if(u&&e&&u.test(e.className))return;o=p(i.indicatorFolded)}else{var n=c(f,0),n=a&&a(r,n);if(n&&n.to.line-n.from.line>=d){if(l&&e&&l.test(e.className))return;o=p(i.indicatorOpen)}}(o||e)&&r.setGutterMarker(t,i.gutter,o)})}function e(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}function f(t){var o=t.getViewport(),e=t.state.foldGutter;e&&(t.operation(function(){i(t,o.from,o.to)}),e.from=o.from,e.to=o.to)}function d(t,o,e){var n=t.state.foldGutter;!n||e==(e=n.options).gutter&&((n=s(t,o))?n.clear():t.foldCode(c(o,0),e))}function a(t,o){"mode"==o&&u(t)}function u(t){var o,e=t.state.foldGutter;e&&(o=e.options,e.from=e.to=0,clearTimeout(e.changeUpdate),e.changeUpdate=setTimeout(function(){f(t)},o.foldOnChangeTimeSpan||600))}function l(o){var t,e=o.state.foldGutter;e&&(t=e.options,clearTimeout(e.changeUpdate),e.changeUpdate=setTimeout(function(){var t=o.getViewport();e.from==e.to||20<t.from-e.to||20<e.from-t.to?f(o):o.operation(function(){t.from<e.from&&(i(o,t.from,e.from),e.from=t.from),t.to>e.to&&(i(o,e.to,t.to),e.to=t.to)})},t.updateViewportTimeSpan||400))}function m(t,o){var e=t.state.foldGutter;!e||(o=o.line)>=e.from&&o<e.to&&i(t,o,o+1)}});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
assets/codemirror/codemirror.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
assets/codemirror/codemirror.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
assets/codemirror/mode/meta.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
assets/codemirror/mode/xml/xml.min.js vendored Normal file

File diff suppressed because one or more lines are too long