|
6 | 6 | <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/search/search.js"></script> |
7 | 7 | <script data-relocate="true">window.define.amd = window.__require_define_amd;</script> |
8 | 8 | <script data-relocate="true"> |
9 | | - ['{@$__wcf->getPath()}js/3rdParty/codemirror-mc/codemirror.css', '{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/dialog/dialog.css'].forEach((href) => { |
| 9 | + [ |
| 10 | + '{@$__wcf->getPath()}js/3rdParty/codemirror-mc/codemirror.css', |
| 11 | + '{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/dialog/dialog.css', |
| 12 | + '{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/fold/foldgutter.css', |
| 13 | + '{@$__wcf->getPath()}js/3rdParty/codemirror-mc/theme/{CODEMIRROR_THEME}.css', |
| 14 | + ].forEach((href) => { |
10 | 15 | const link = document.createElement('link'); |
11 | 16 | link.rel = 'stylesheet'; |
12 | 17 | link.href = href; |
|
19 | 24 | {if $codemirrorMode != 'smartymixed'} |
20 | 25 | <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/mode/{if $codemirrorMode == 'text/x-less'}css/css{else}{$codemirrorMode}/{$codemirrorMode}{/if}.js"></script> |
21 | 26 | {/if} |
22 | | - |
| 27 | + |
| 28 | + <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/fold/foldcode.js"></script> |
| 29 | + <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/fold/foldgutter.js"></script> |
| 30 | + <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/fold/brace-fold.js"></script> |
| 31 | + <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/fold/indent-fold.js"></script> |
| 32 | + <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/fold/comment-fold.js"></script> |
| 33 | + |
23 | 34 | {if $codemirrorMode == 'htmlmixed' || $codemirrorMode == 'smartymixed' || $codemirrorMode == 'php'} |
24 | 35 | {if $codemirrorMode == 'smartymixed'} |
25 | 36 | <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/mode/htmlmixed/htmlmixed.js"></script> |
|
32 | 43 | <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/mode/css/css.js"></script> |
33 | 44 | <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/mode/javascript/javascript.js"></script> |
34 | 45 | <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/mode/xml/xml.js"></script> |
| 46 | + <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/fold/xml-fold.js"></script> |
| 47 | + {/if} |
| 48 | + {if $codemirrorMode === 'markdown'} |
| 49 | + <script data-relocate="true" src="{@$__wcf->getPath()}js/3rdParty/codemirror-mc/addon/fold/markdown-fold.js"></script> |
35 | 50 | {/if} |
36 | 51 | <script data-relocate="true">window.define.amd = window.__require_define_amd;</script> |
37 | 52 | {assign var='codemirrorLoaded' value=true} |
|
57 | 72 | indentWithTabs: true, |
58 | 73 | lineNumbers: true, |
59 | 74 | indentUnit: 4, |
60 | | - readOnly: {if !$editable|isset || $editable}false{else}true{/if} |
| 75 | + readOnly: {if !$editable|isset || $editable}false{else}true{/if}, |
| 76 | + theme: '{CODEMIRROR_THEME}', |
| 77 | + foldGutter: true, |
| 78 | + gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], |
| 79 | + extraKeys: { "Ctrl-Q": (cm) => { cm.foldCode(cm.getCursor()); } }, |
61 | 80 | }; |
62 | 81 | |
63 | 82 | elements.forEach((element) => { |
|
72 | 91 | } |
73 | 92 | else { |
74 | 93 | element.codemirror = CodeMirror.fromTextArea(element, config); |
| 94 | + element.codemirror.foldCode(CodeMirror.Pos(13, 0)); |
75 | 95 | const oldToTextArea = element.codemirror.toTextArea; |
76 | 96 | element.codemirror.toTextArea = () => { |
77 | 97 | oldToTextArea(); |
|
0 commit comments