-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor.html
279 lines (259 loc) · 9.25 KB
/
editor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<html lang="en">
<head>
<meta charset="utf-8">
<title>ChordPro Song Editor, an Ace Editor Extension for Ukulele Music by UkeGeeks</title>
<link rel="stylesheet" href="src/styles/yuiReset.css">
<link rel="stylesheet" href="src/styles/ugs-ace-hdr.css">
<link rel="stylesheet" href="src/styles/ugs-ace-editor.css">
<link rel="stylesheet" href="src/styles/ugs-ace-help.css">
</head>
<body class="diagramsOnSide pageWidth_letter theme-normal">
<main>
<header id="aceHeader" class="ugs-ace-hdr">
<button id="aceHeaderHamburgerBtn" class="ugs-ace-hdr__hamburger-btn" title="Show options & help"><span></span><span></span><span></span></button>
<h1>ChordPro Song Editor</h1>
</header>
<section id="aceEditor" class="ugs-ace-editor"></section>
<aside id="aceHelp" class="ugs-ace-help__wrap">
<div class="ugs-ace-help__content">
<h3>Keyboard Shortcuts</h3>
<table>
<thead>
<tr>
<th>Shortcut</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ugs-ace-help__td-key">
<code class="ugs-ace-help__key">CTRL</code> + <code class="ugs-ace-help__key">F</code>
</td>
<td>Find</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<code class="ugs-ace-help__key">CTRL</code> + <code class="ugs-ace-help__key">H</code>
</td>
<td>Search & Replace</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<code class="ugs-ace-help__key">ESCAPE</code>
</td>
<td>Close Find or Chord window</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<code class="ugs-ace-help__key">CTRL</code> + <code class="ugs-ace-help__key">SPACEBAR</code>
</td>
<td>
Lists your song's chords. Use <code class="ugs-ace-help__key">DOWNARROW</code> & <code class="ugs-ace-help__key">UPARROW</code> to
choose one, or type a few letters of the chord name to narrow suggestions. Press <code class="ugs-ace-help__key">ENTER</code> to add it to your song.
</td>
</tr>
</tbody>
</table>
<h3>Snippets</h3>
<p>
Snippets are bits of ChordPro markup that you may add to your song by just typing a few letters and then pressing
the <code class="ugs-ace-help__key">TAB</code> key.
</p>
<table>
<thead>
<tr>
<th>Snippet</th>
<th>ChordPro Markup</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ugs-ace-help__td-key">
<strong>t</strong> or <strong>title</strong>
</td>
<td>
<code class="snip">{title: <em>TITLE</em>}</code>
</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<strong>st</strong> or <strong>subtitle</strong>
</td>
<td>
<code class="snip">{subtitle: <em>TITLE</em>}</code>
</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<strong>a</strong> or <strong>artist</strong>
</td>
<td>
<code class="snip">{artist: <em>NAME</em>}</code>
</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<strong>al</strong> or <strong>album</strong>
</td>
<td>
<code class="snip">{album: <em>TITLE</em>}</code>
</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<strong>c</strong> or <strong>comment</strong>
</td>
<td>
<code class="snip">{comment: <em>DESCRIPTION</em>}</code>
</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<strong>col</strong> or <strong>column</strong>
</td>
<td>
<code class="snip">{column_break}</code>
</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<strong>chorus</strong>
</td>
<td>
Adds complete chorus block, beginning with <code class="snip">{start_of_chorus}</code>
</td>
</tr>
<tr>
<td class="ugs-ace-help__td-key">
<strong>tab</strong>
</td>
<td>
Adds complete tablature block, beginning with <code class="snip">{start_of_tab}</code>
</td>
</tr>
</tbody>
</table>
<p>
Others: <code>soc</code> & <code>eoc</code> (mark <em>chorus</em> block) and <code>sot</code> &
<code>eot</code> (mark <em>tab</em> block). <code>d</code> adds <code>{define:...}</code> tag.
</p>
<p>
TIP: When a snippet's added some “placeholder text” may be highlighted -- just type whatever you wish
to replace this. If more than one placeholder is available pressing <code class="ugs-ace-help__key">TAB</code> again will cycle
through them.
</p>
</div>
</aside>
<textarea id="chordProSource" wrap="off">
# ---------------------------------------------------
# This sample song shows how to markup your tune in
# ChordPro format. Click the "hamburger" to show
# useful help tips.
#
# First, lines beginning with # are ignored, these
# are hidden notes, memos to yourself; they won't be
# displayed in the final song.
# ---------------------------------------------------
{title: My Little Grass Shack in Kealakekua}
{artist: Lyrics & Music: B.Cogswell, T.Harrison and J.Noble (1933)}
{comment: Verse 1}
I want to go [G]back to my little grass shack
In Kealakekua, [A7]Hawaii
I want to [D7]be with all the kanes and wahines
That I used to [G]know... so long ago
I can [B7]hear the old guitars a-playing[E7]
On the beach at Honaunau
I can [A7]hear the old Hawaiians saying
"Komo [D7]mai no kaua i ka hale welakahau"
# ---------------------------------------------------
# Try an auto-complete "snippet". Place the cursor
# on a blank line, press "t" followed by the tab key.
# ---------------------------------------------------
{comment: Verse 2}
It won't be [G]long till my ship will be sailing
Back to [A7]Kona
A [D7]grand old place
That's always fair to [B7]see... you're telling me
# ---------------------------------------------------
# Now let's quickly add a chord that's already been
# used in this song. Position the cursor anywhere
# in this song and hold the {Control} key while
# pressing the {Spacebar}: use arrows or keyboard
# to choose from the list of chords in use and add
# at this location.
#
# Tip: a space is required between a word and
# inserting a chord
# ---------------------------------------------------
I'm [E7]just a little Hawaiian and a homesick island boy
I [A7]want to go back to my fish and poi
{start_of_chorus}
{comment: Chorus}
I want to go [G]back to my little grass shack
In Kealakekua, [A7]Hawaii
Where the [D7]humu-humu nuku-nuku a pua'a
Go swimming [G]by
{end_of_chorus}
{comment: Outro}
Where the [D7]humu-humu nuku-nuku a pua'a
Go swimming [G]by
</textarea>
</main>
<!-- setup Ace -->
<script src="src/ace/ace.js"></script>
<script src="src/ace/ext-language_tools.js"></script>
<script src="src/ace/ext-inline_autocomplete.js"></script>
<script src="src/ace/ext-searchbox.js"></script>
<script>
(() => {
const Ids = {
EDITOR: 'aceEditor',
};
const Selectors = {
EDITOR: `#${Ids.EDITOR}`,
HAMBURGER_BTN: '#aceHeaderHamburgerBtn',
HELP_WRAP: '#aceHelp',
SOURCE: '#chordProSource',
};
const Styles = {
OPEN: 'ugs-ace-help__wrap--open',
EDITOR_HELP_VISIBLE: 'ugs-ace-editor--help-open',
};
let isHelpOpen = false;
function showHelp() {
isHelpOpen = !isHelpOpen;
document
.querySelector(Selectors.HELP_WRAP)
.classList
.toggle(Styles.OPEN, isHelpOpen);
document
.querySelector(Selectors.EDITOR)
.classList
.toggle(Styles.EDITOR_HELP_VISIBLE, isHelpOpen);
}
function init() {
// attach our show/hide help sidebar to the "hamburger" button
document.querySelector(Selectors.HAMBURGER_BTN).addEventListener('click', showHelp);
// in this example I'm preserving the original CPM Markup, so we'll not
// have Ace replace the element
const songText = document.querySelector(Selectors.SOURCE).value;
// Setup the editor
const editor = window.ace.edit(Ids.EDITOR);
// Choose our color theme
editor.setTheme('ace/theme/idle_fingers');
// tell Ace to treat our text as CPM
editor.session.setMode('ace/mode/chordpro');
editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
});
// Load Ace with our song source (raw CPM)
editor.setValue(songText);
// last, let's put the cursor on the first line, to get things started.
editor.gotoLine(1);
}
init();
})();
</script>
</body>
</html>