差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| javascript:ace [2019/08/20 14:32] – ともやん | javascript:ace [2020/06/15 19:46] (現在) – ↷ 移動操作に合わせてリンクを書き換えました。 非ログインユーザー | ||
|---|---|---|---|
| 行 15: | 行 15: | ||
| < | < | ||
| jQuery(function($) { | jQuery(function($) { | ||
| - | | + | |
| editor.setTheme(" | editor.setTheme(" | ||
| editor.session.setMode(" | editor.session.setMode(" | ||
| + | editor.setValue(editor.getValue().trim(), | ||
| + | const lines = editor.getSession().getDocument().getLength(); | ||
| + | editor.setOptions({maxLines: | ||
| }); | }); | ||
| </ | </ | ||
| < | < | ||
| #ace_editor { | #ace_editor { | ||
| - | | + | |
| } | } | ||
| </ | </ | ||
| 行 33: | 行 36: | ||
| ===== エディタデモ ===== | ===== エディタデモ ===== | ||
| - | <WRAP prewrap 100%> | + | <WRAP prewrap 100% #ace_editor> |
| - | < | + | %%/** |
| - | <pre id='ace_editor'> | + | |
| - | /** | + | |
| * In fact, you're looking at ACE right now. Go ahead and play with it! | * In fact, you're looking at ACE right now. Go ahead and play with it! | ||
| * | * | ||
| 行 50: | 行 51: | ||
| var addResult = add(3, 2); | var addResult = add(3, 2); | ||
| - | console.log(addResult); | + | console.log(addResult); |
| - | </ | + | |
| - | </ | + | |
| </ | </ | ||
| + | <code html> | ||
| + | <script src='/ | ||
| + | <script src="/ | ||
| + | <!--[if lt IE 9]> | ||
| + | <script src="/ | ||
| + | < | ||
| + | <script src="/ | ||
| + | <script src="/ | ||
| + | <script src="/ | ||
| + | <script src="/ | ||
| + | <script src="/ | ||
| + | <script src="/ | ||
| + | <script src="/ | ||
| + | <script src="/ | ||
| + | < | ||
| + | jQuery(function($) { | ||
| + | const editor = ace.edit(" | ||
| + | editor.setTheme(" | ||
| + | editor.session.setMode(" | ||
| + | const lines = editors[i].getSession().getDocument().getLength(); | ||
| + | editor.setOptions({maxLines: | ||
| + | }); | ||
| + | </ | ||
| + | </ | ||
| ===== インストール ===== | ===== インストール ===== | ||
| 行 64: | 行 87: | ||
| ==== ソースコードからのインストール ==== | ==== ソースコードからのインストール ==== | ||
| - | Ace をソースからビルドするには [[javascript: | + | Ace をソースからビルドするには [[javascript: |
| \\ | \\ | ||
| ソースを取得する。 | ソースを取得する。 | ||
| 行 91: | 行 114: | ||
| $ make build | $ make build | ||
| </ | </ | ||
| + | |||
| + | ===== //#region [リージョンの説明] 〜 //# | ||
| + | 実際のデモは以下にある。\\ | ||
| + | [[javascript: | ||
| + | <code javascript> | ||
| + | //#region [Ace Editor fold all region] | ||
| + | isCommentFold = (line) => { | ||
| + | var isAFold = false; | ||
| + | if (/ | ||
| + | if (/ | ||
| + | return isAFold; | ||
| + | } | ||
| + | ace.EditSession.prototype.foldAllRegion = function(startRow, | ||
| + | if (depth == undefined) | ||
| + | depth = 100000; // JSON.stringify doesn' | ||
| + | var foldWidgets = this.foldWidgets; | ||
| + | if (!foldWidgets) | ||
| + | return; // mode doesn' | ||
| + | endRow = endRow || this.getLength(); | ||
| + | startRow = startRow || 0; | ||
| + | for (var row = startRow; row < endRow; row++) { | ||
| + | if (foldWidgets[row] == null) | ||
| + | foldWidgets[row] = this.getFoldWidget(row); | ||
| + | if (foldWidgets[row] != " | ||
| + | continue; | ||
| + | if (!isCommentFold(this.getLine(row))) continue | ||
| + | var range = this.getFoldWidgetRange(row); | ||
| + | // sometimes range can be incompatible with existing fold | ||
| + | // TODO change addFold to return null istead of throwing | ||
| + | if (range && range.isMultiLine() | ||
| + | && range.end.row <= endRow | ||
| + | && range.start.row >= startRow) { | ||
| + | row = range.end.row; | ||
| + | try { | ||
| + | // addFold can change the range | ||
| + | var fold = this.addFold(" | ||
| + | if (fold) | ||
| + | fold.collapseChildren = depth; | ||
| + | } catch(ex) {} | ||
| + | } | ||
| + | } | ||
| + | }; | ||
| + | //# | ||
| + | | ||
| + | jQuery(function($) { | ||
| + | const editor = ace.edit(" | ||
| + | editor.setTheme(" | ||
| + | editor.session.setMode(" | ||
| + | const lines = editors[i].getSession().getDocument().getLength(); | ||
| + | editor.setOptions({maxLines: | ||
| + | | ||
| + | // #region をデフォルトで折り畳む | ||
| + | editor.session.foldAllRegion(); | ||
| + | }); | ||
| + | </ | ||
| + | |||