abcjs 6.2.1 → 6.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abcjs",
3
- "version": "6.2.1",
3
+ "version": "6.2.2",
4
4
  "description": "Renderer for abc music notation",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -13,6 +13,8 @@ var GuitarTablature = require('../tablatures/instruments/guitar/tab-guitar');
13
13
  // Existing tab classes
14
14
  var pluginTab = {
15
15
  'violin': 'ViolinTab',
16
+ 'fiddle': 'ViolinTab',
17
+ 'mandolin': 'ViolinTab',
16
18
  'guitar': 'GuitarTab'
17
19
  };
18
20
 
@@ -227,6 +227,7 @@ TabRenderer.prototype.doLayout = function () {
227
227
  this.tabStaff.voices = [];
228
228
  for (var ii = 0; ii < nbVoices; ii++) {
229
229
  var tabVoice = new VoiceElement(0, 0);
230
+ if (ii > 0) tabVoice.duplicate = true;
230
231
  var nameHeight = buildTabName(this, tabVoice) / spacing.STEP;
231
232
  nameHeight = Math.max(nameHeight, 1) // If there is no label for the tab line, then there needs to be a little padding
232
233
  staffGroup.staffs[this.staffIndex].top += nameHeight;
@@ -7,14 +7,23 @@ function printLine(renderer, x1, x2, y, klass, name, dy) {
7
7
  x2 = roundNumber(x2);
8
8
  var y1 = roundNumber(y - dy);
9
9
  var y2 = roundNumber(y + dy);
10
- // TODO-PER: This fixes a firefox bug where a path needs to go over the 0.5 mark or it isn't displayed
11
- if (renderer.firefox112 && dy < 1) {
12
- var int = Math.floor(y2)
13
- var distToHalf = 0.52 - (y2 - int)
14
- if (distToHalf > 0) {
15
- y1 += distToHalf
16
- y2 += distToHalf
10
+ // TODO-PER: This fixes a firefox bug where it isn't displayed
11
+ if (renderer.firefox112) {
12
+ y += dy / 2; // Because the y coordinate is the edge of where the line goes but the width widens from the middle.
13
+ var attr = {
14
+ x1: x1,
15
+ x2: x2,
16
+ y1: y,
17
+ y2: y,
18
+ stroke: renderer.foregroundColor,
19
+ 'stroke-width': Math.abs(dy*2)
17
20
  }
21
+ if (klass)
22
+ attr['class'] = klass;
23
+ if (name)
24
+ attr['data-name'] = name;
25
+
26
+ return renderer.paper.lineToBack(attr);
18
27
  }
19
28
 
20
29
  var pathString = sprintf("M %f %f L %f %f L %f %f L %f %f z", x1, y1, x2, y1,
@@ -12,15 +12,23 @@ function printStem(renderer, x, dx, y1, y2, klass, name) {
12
12
  }
13
13
  x = roundNumber(x);
14
14
  var x2 = roundNumber(x + dx);
15
- // TODO-PER: This fixes a firefox bug where a path needs to go over the 0.5 mark or it isn't displayed
16
- if (renderer.firefox112 && Math.abs(dx) < 1) {
17
- var higher = Math.max(x,x2)
18
- var int = Math.floor(higher)
19
- var distToHalf = 0.52 - (higher - int)
20
- if (distToHalf > 0) {
21
- x += distToHalf
22
- x2 += distToHalf
15
+ // TODO-PER: This fixes a firefox bug where it isn't displayed
16
+ if (renderer.firefox112) {
17
+ x += dx / 2; // Because the x coordinate is the edge of where the line goes but the width widens from the middle.
18
+ var attr = {
19
+ x1: x,
20
+ x2: x,
21
+ y1: y1,
22
+ y2: y2,
23
+ stroke: renderer.foregroundColor,
24
+ 'stroke-width': Math.abs(dx)
23
25
  }
26
+ if (klass)
27
+ attr['class'] = klass;
28
+ if (name)
29
+ attr['data-name'] = name;
30
+
31
+ return renderer.paper.lineToBack(attr);
24
32
  }
25
33
  var pathArray = [["M", x, y1], ["L", x, y2], ["L", x2, y2], ["L", x2, y1], ["z"]];
26
34
  var attr = { path: "" };
@@ -256,14 +256,14 @@ EngraverController.prototype.engraveTune = function (abcTune, tuneNumber, lineOf
256
256
 
257
257
  if (this.oneSvgPerLine) {
258
258
  var div = this.renderer.paper.svg.parentNode
259
- this.svgs = splitSvgIntoLines(div, abcTune.metaText.title, this.responsive)
259
+ this.svgs = splitSvgIntoLines(this.renderer, div, abcTune.metaText.title, this.responsive)
260
260
  } else {
261
261
  this.svgs = [this.renderer.paper.svg];
262
262
  }
263
263
  setupSelection(this, this.svgs);
264
264
  };
265
265
 
266
- function splitSvgIntoLines(output, title, responsive) {
266
+ function splitSvgIntoLines(renderer, output, title, responsive) {
267
267
  // Each line is a top level <g> in the svg. To split it into separate
268
268
  // svgs iterate through each of those and put them in a new svg. Since
269
269
  // they are placed absolutely, the viewBox needs to be manipulated to
@@ -297,7 +297,9 @@ function splitSvgIntoLines(output, title, responsive) {
297
297
  svg.setAttribute("height", height)
298
298
  if (responsive === 'resize')
299
299
  svg.style.position = ''
300
- svg.setAttribute("viewBox", "0 " + nextTop + " " + width + " " + height)
300
+ // TODO-PER: Hack! Not sure why this is needed.
301
+ var viewBoxHeight = renderer.firefox112 ? height+1 : height
302
+ svg.setAttribute("viewBox", "0 " + nextTop + " " + width + " " + viewBoxHeight)
301
303
  svg.appendChild(style.cloneNode(true))
302
304
  var titleEl = document.createElement("title")
303
305
  titleEl.innerText = fullTitle
package/src/write/svg.js CHANGED
@@ -345,6 +345,16 @@ Svg.prototype.pathToBack = function (attr) {
345
345
  return el;
346
346
  };
347
347
 
348
+ Svg.prototype.lineToBack = function (attr) {
349
+ var el = document.createElementNS(svgNS, 'line');
350
+ var keys = Object.keys(attr)
351
+ for (var i = 0; i < keys.length; i++)
352
+ el.setAttribute(keys[i], attr[keys[i]]);
353
+ this.prepend(el);
354
+ return el;
355
+ };
356
+
357
+
348
358
  Svg.prototype.append = function (el) {
349
359
  if (this.currentGroup.length > 0)
350
360
  this.currentGroup[0].appendChild(el);
package/types/index.d.ts CHANGED
@@ -259,7 +259,7 @@ declare module 'abcjs' {
259
259
  dragColor?: string;
260
260
  dragging?: boolean;
261
261
  foregroundColor?: string;
262
- format?: { [attr in FormatAttributes]: any };
262
+ format?: { [attr in FormatAttributes]?: any };
263
263
  header_only?: boolean;
264
264
  initialClef?: boolean;
265
265
  jazzchords?: boolean;
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
- var version = '6.2.1';
1
+ var version = '6.2.2';
2
2
 
3
3
  module.exports = version;