Skip to content

Commit 280c18e

Browse files
author
paulrosen
committed
Prepare v6.5.2 release
1 parent cd64ffc commit 280c18e

File tree

8 files changed

+94
-35
lines changed

8 files changed

+94
-35
lines changed

RELEASE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# Version 6.5.2
2+
3+
## Bugs
4+
5+
* Add test for bug with third ending sequencing
6+
7+
* Fix problem with transposing chords that have spaces in them.
8+
9+
* Fix undefined variables.
10+
11+
* Fix typescript definitions
12+
13+
## Features
14+
15+
* Allow passing selector into the Editor in addition to ID. Add callbacks before and after drawing.
16+
17+
* Expose the tunes array that the Editor has.
18+
119
# Version 6.5.1
220

321
## Bugs

dist/abcjs-basic-min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/abcjs-basic.js

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,11 @@ try {
19881988
// if we aren't in a browser, this code will crash, but it is not needed then either.
19891989
}
19901990
var EditArea = function EditArea(textareaid) {
1991-
if (typeof textareaid === "string") this.textarea = document.getElementById(textareaid);else this.textarea = textareaid;
1991+
this.isEditArea = true;
1992+
if (typeof textareaid === "string") {
1993+
this.textarea = document.getElementById(textareaid);
1994+
if (!this.textarea) this.textarea = document.querySelector(textareaid);
1995+
} else this.textarea = textareaid;
19921996
this.initialText = this.textarea.value;
19931997
this.isDragging = false;
19941998
};
@@ -2156,10 +2160,17 @@ var Editor = function Editor(editarea, params) {
21562160
// Copy all the options that will be passed through
21572161
this.abcjsParams = gatherAbcParams(params);
21582162
if (params.indicate_changed) this.indicate_changed = true;
2163+
2164+
// If a string is passed in then it could either be an element's ID or a selector
2165+
// If an object is passed in then it could either be an EditArea or a textarea.
21592166
if (typeof editarea === "string") {
2167+
// EditArea handles both the ID and the selector
21602168
this.editarea = new EditArea(editarea);
21612169
} else {
2162-
this.editarea = editarea;
2170+
// If an edit area was passed in, just use it
2171+
if (editarea.isEditArea) this.editarea = editarea;else
2172+
// Hopefully we were passed in a textarea or equivalent.
2173+
this.editarea = new EditArea(editarea);
21632174
}
21642175
this.editarea.addSelectionListener(this);
21652176
this.editarea.addChangeListener(this);
@@ -2209,6 +2220,7 @@ var Editor = function Editor(editarea, params) {
22092220
this.div.parentNode.insertBefore(this.warningsdiv, this.div);
22102221
}
22112222
this.onchangeCallback = params.onchange;
2223+
this.redrawCallback = params.redrawCallback;
22122224
this.currentAbc = "";
22132225
this.tunes = [];
22142226
this.bReentry = false;
@@ -2265,12 +2277,14 @@ Editor.prototype.modelChanged = function () {
22652277
this.bReentry = true;
22662278
try {
22672279
this.timerId = null;
2280+
if (this.redrawCallback) this.redrawCallback(true);
22682281
if (this.synth && this.synth.synthControl) this.synth.synthControl.disable(true);
22692282
this.tunes = renderAbc(this.div, this.currentAbc, this.abcjsParams);
22702283
if (this.tunes.length > 0) {
22712284
this.warnings = this.tunes[0].warnings;
22722285
}
22732286
this.redrawMidi();
2287+
if (this.redrawCallback) this.redrawCallback(false);
22742288
} catch (error) {
22752289
console.error("ABCJS error: ", error);
22762290
if (!this.warnings) this.warnings = [];
@@ -2295,6 +2309,9 @@ Editor.prototype.paramChanged = function (engraverParams) {
22952309
this.currentAbc = "";
22962310
this.fireChanged();
22972311
};
2312+
Editor.prototype.getTunes = function () {
2313+
return this.tunes;
2314+
};
22982315
Editor.prototype.synthParamChanged = function (options) {
22992316
if (!this.synth) return;
23002317
this.synth.options = {};
@@ -10052,11 +10069,11 @@ function cleanUpSlursInLine(line, staffNum, voiceNum, currSlur) {
1005210069
}
1005310070
}
1005410071
function wrapMusicLines(lines, barsperstaff) {
10055-
for (i = 0; i < lines.length; i++) {
10072+
for (var i = 0; i < lines.length; i++) {
1005610073
if (lines[i].staff !== undefined) {
10057-
for (s = 0; s < lines[i].staff.length; s++) {
10074+
for (var s = 0; s < lines[i].staff.length; s++) {
1005810075
var permanentItems = [];
10059-
for (v = 0; v < lines[i].staff[s].voices.length; v++) {
10076+
for (var v = 0; v < lines[i].staff[s].voices.length; v++) {
1006010077
var voice = lines[i].staff[s].voices[v];
1006110078
var barNumThisLine = 0;
1006210079
for (var n = 0; n < voice.length; n++) {
@@ -10777,6 +10794,9 @@ module.exports = {
1077710794
\***************************/
1077810795
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1077910796

10797+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
10798+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10799+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1078010800
var keyAccidentals = __webpack_require__(/*! ../const/key-accidentals */ "./src/const/key-accidentals.js");
1078110801
var _require = __webpack_require__(/*! ../const/relative-major */ "./src/const/relative-major.js"),
1078210802
relativeMajor = _require.relativeMajor,
@@ -11073,6 +11093,7 @@ var strTranspose;
1107311093
var regNote = /([_^=]*[A-Ga-g][,']*)(\d*\/*\d*)([\>\<\-\)\.\s\\]*)/;
1107411094
var regOptionalNote = /([_^=]*[A-Ga-g][,']*)?(\d*\/*\d*)?([\>\<\-\)]*)?/;
1107511095
var regSpace = /(\s*)$/;
11096+
var regOptionalSpace = /(\s*)/;
1107611097

1107711098
// This the relationship of the note to the tonic and an octave. So what is returned is a distance in steps from the tonic and the amount of adjustment from
1107811099
// a normal scale. That is - in the key of D an F# is two steps from the tonic and no adjustment. A G# is three steps from the tonic and one half-step higher.
@@ -11101,39 +11122,59 @@ var strTranspose;
1110111122
};
1110211123
}
1110311124
function replaceNote(abc, start, end, newPitch, index) {
11104-
// There may be more than just the note between the start and end - there could be spaces, there could be a chord symbol, there could be a decoration.
11105-
// This could also be a part of a chord. If so, then the particular note needs to be teased out.
1110611125
var note = abc.substring(start, end);
11107-
var match = note.match(new RegExp(regNote.source + regSpace.source), '');
11126+
// Try single note first
11127+
var match = note.match(new RegExp(regNote.source + regSpace.source));
1110811128
if (match) {
11109-
// This will match a single note
1111011129
var noteLen = match[1].length;
1111111130
var trailingLen = match[2].length + match[3].length + match[4].length;
1111211131
var leadingLen = end - start - noteLen - trailingLen;
1111311132
start += leadingLen;
1111411133
end -= trailingLen;
1111511134
} else {
11116-
// I don't know how to capture more than one note, so I'm separating them. There is a limit of the number of notes in a chord depending on the repeats I have here, but it is unlikely to happen in real music.
11135+
// Match chord
1111711136
var regPreBracket = /([^\[]*)/;
1111811137
var regOpenBracket = /\[/;
1111911138
var regCloseBracket = /\-?](\d*\/*\d*)?([\>\<\-\)]*)/;
11120-
match = note.match(new RegExp(regPreBracket.source + regOpenBracket.source + regOptionalNote.source + regOptionalNote.source + regOptionalNote.source + regOptionalNote.source + regOptionalNote.source + regOptionalNote.source + regOptionalNote.source + regOptionalNote.source + regCloseBracket.source + regSpace.source));
11139+
var regChord = new RegExp(regPreBracket.source + regOpenBracket.source + "(?:" + regOptionalNote.source + "\\s*){1,8}" + regCloseBracket.source + regSpace.source);
11140+
match = note.match(regChord);
1112111141
if (match) {
11122-
// This will match a chord
11123-
// Get the number of chars used by the previous notes in this chord
11124-
var count = 1 + match[1].length; // one character for the open bracket
11125-
for (var i = 0; i < index; i++) {
11126-
// index is the iteration through the chord. This function gets called for each one.
11127-
if (match[i * 3 + 2]) count += match[i * 3 + 2].length;
11128-
if (match[i * 3 + 3]) count += match[i * 3 + 3].length;
11129-
if (match[i * 3 + 4]) count += match[i * 3 + 4].length;
11142+
var beforeChordLen = match[1].length + 1; // text before + '['
11143+
var chordBody = note.slice(match[1].length + 1, note.lastIndexOf("]"));
11144+
// Collect notes inside chord
11145+
var chordNotes = [];
11146+
var regNoteWithSpace = new RegExp(regOptionalNote.source + "\\s*", "g");
11147+
var _iterator = _createForOfIteratorHelper(chordBody.matchAll(regNoteWithSpace)),
11148+
_step;
11149+
try {
11150+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
11151+
var m = _step.value;
11152+
var noteText = m[0].trim();
11153+
if (noteText !== "") {
11154+
chordNotes.push({
11155+
text: noteText,
11156+
index: m.index
11157+
});
11158+
}
11159+
}
11160+
} catch (err) {
11161+
_iterator.e(err);
11162+
} finally {
11163+
_iterator.f();
1113011164
}
11131-
start += count;
11132-
var endLen = match[index * 3 + 2] ? match[index * 3 + 2].length : 0;
11133-
// endLen += match[index * 3 + 3] ? match[index * 3 + 3].length : 0
11134-
// endLen += match[index * 3 + 4] ? match[index * 3 + 4].length : 0
11135-
11136-
end = start + endLen;
11165+
if (index >= chordNotes.length) {
11166+
throw new Error("Chord index out of range for chord: " + note);
11167+
}
11168+
var chosen = chordNotes[index];
11169+
// Preserve duration and tie
11170+
var mDurTie = chosen.text.match(/^(.+?)(\d+\/?\d*)?(-)?$/);
11171+
var pitchPart = mDurTie ? mDurTie[1] : chosen.text;
11172+
var durationPart = mDurTie && mDurTie[2] ? mDurTie[2] : "";
11173+
var tiePart = mDurTie && mDurTie[3] ? mDurTie[3] : "";
11174+
// Replace note keeping duration and tie
11175+
newPitch = newPitch + durationPart + tiePart;
11176+
start += beforeChordLen + chosen.index;
11177+
end = start + chosen.text.length;
1113711178
}
1113811179
}
1113911180
return {
@@ -26767,7 +26808,7 @@ module.exports = Svg;
2676726808
\********************/
2676826809
/***/ (function(module) {
2676926810

26770-
var version = '6.5.1';
26811+
var version = '6.5.2';
2677126812
module.exports = version;
2677226813

2677326814
/***/ })

dist/abcjs-basic.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/abcjs-plugin-min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "abcjs",
3-
"version": "6.5.1",
3+
"version": "6.5.2",
44
"description": "Renderer for abc music notation",
55
"main": "index.js",
66
"types": "types/index.d.ts",

version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
var version = '6.5.1';
1+
var version = '6.5.2';
22

33
module.exports = version;

0 commit comments

Comments
 (0)