Comparing version 0.0.5 to 0.0.6
@@ -8,2 +8,6 @@ 'use strict' | ||
constructor(selector = 'svg') { | ||
if (!document.querySelector(selector)) { | ||
throw new Error('Invalid selector') | ||
} | ||
this.selector = selector | ||
@@ -44,6 +48,10 @@ this.svg = document.querySelector(selector).outerHTML.replace(/[\r|\n]+/g, "\n") | ||
const textElement = doc.querySelector(selector) | ||
if (!textElement) { | ||
return this | ||
} | ||
const textSvg = textElement.outerHTML | ||
// SVGElement doesn't have innerText | ||
// @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement | ||
const textContent = textElement.innerHTML.replace(new RegExp('^<tspan[^>]*>((.|\\s)*)</tspan>$'), '$1') | ||
const textContent = textElement.innerHTML.replace(new RegExp('^<tspan[^>]*>([\\S|\\s]*)</tspan>$'), '$1') | ||
@@ -50,0 +58,0 @@ const adjustedTextSvg = adjustTextarea(textSvg, textContent, width, height, lineHeight, paddingX, paddingY, nowrap) |
{ | ||
"name": "svg-paper", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "The world's most maintainable way to create paper-printable documents 🖨💘", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/ttskch/svg-paper", |
@@ -50,2 +50,7 @@ # svg-paper | ||
<script src="https://cdn.jsdelivr.net/npm/svg-paper@x.x.x/dist/svg-paper.min.js"></script> | ||
<script> | ||
paper = new SvgPaper() | ||
paper.replace('%placeholder%', 'Actual value') | ||
</script> | ||
``` | ||
@@ -61,2 +66,9 @@ | ||
```js | ||
import SvgPaper from 'svg-paper' | ||
paper = new SvgPaper() | ||
paper.replace('%placeholder%', 'Actual value') | ||
``` | ||
## Basic usage | ||
@@ -63,0 +75,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
190770
866
274