data-bionic-reading 1.0.0 → 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Mark Mead
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/builds/cdn.js CHANGED
@@ -1,3 +1,3 @@
1
- import bionicReading from "../src/index.js";
1
+ import bionicReading from '../src/index.js'
2
2
 
3
- document.addEventListener("DOMContentLoaded", bionicReading());
3
+ document.addEventListener('DOMContentLoaded', bionicReading())
@@ -1 +1 @@
1
- function l(){let t=document.querySelector("[data-bionic-reading]");if(!t)return;[...t.querySelectorAll("h1, h2, h3, h4, h5, h6, p, li, a")].forEach(e=>{e.style.fontWeight=400;let i=e.innerText.split(" ").map(r=>{let n=r.length;if(n===1)return`<strong>${r}</strong>`;let a=Math.floor(n/2);return r.split("").map((o,s)=>s<a?`<strong>${o}</strong>`:o).join("")});e.innerHTML=i.join(" ")})}var y=l;export{y as default};
1
+ function l(){let r=document.querySelector("[data-bionic-reading]");if(!r)return;[...r.querySelectorAll("h1, h2, h3, h4, h5, p, a, li, blockquote")].forEach(e=>{e.style.fontWeight=400;let i=e.innerText.split(" ").map(t=>{let n=t.length;if(n===1)return`<strong>${t}</strong>`;let a=Math.floor(n/2);return t.split("").map((o,c)=>c<a?`<strong>${o}</strong>`:o).join("")});e.innerHTML=i.join(" ")})}var y=l;export{y as default};
@@ -1 +1 @@
1
- (()=>{function i(){let r=document.querySelector("[data-bionic-reading]");if(!r)return;[...r.querySelectorAll("h1, h2, h3, h4, h5, h6, p, li, a")].forEach(e=>{e.style.fontWeight=400;let l=e.innerText.split(" ").map(t=>{let n=t.length;if(n===1)return`<strong>${t}</strong>`;let a=Math.floor(n/2);return t.split("").map((o,s)=>s<a?`<strong>${o}</strong>`:o).join("")});e.innerHTML=l.join(" ")})}document.addEventListener("DOMContentLoaded",i());})();
1
+ (()=>{function i(){let r=document.querySelector("[data-bionic-reading]");if(!r)return;[...r.querySelectorAll("h1, h2, h3, h4, h5, p, a, li, blockquote")].forEach(e=>{e.style.fontWeight=400;let l=e.innerText.split(" ").map(t=>{let n=t.length;if(n===1)return`<strong>${t}</strong>`;let a=Math.floor(n/2);return t.split("").map((o,c)=>c<a?`<strong>${o}</strong>`:o).join("")});e.innerHTML=l.join(" ")})}document.addEventListener("DOMContentLoaded",i());})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "data-bionic-reading",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Helps developers add support for bionic reading to their content 📚",
5
5
  "keywords": [
6
6
  "Bionic Reading"
package/src/index.js CHANGED
@@ -1,39 +1,41 @@
1
1
  export default function () {
2
- const articleElement = document.querySelector("[data-bionic-reading]");
2
+ const articleElement = document.querySelector('[data-bionic-reading]')
3
3
 
4
4
  if (!articleElement) {
5
- return;
5
+ return
6
6
  }
7
7
 
8
8
  const articleElements = [
9
- ...articleElement.querySelectorAll("h1, h2, h3, h4, h5, h6, p, li, a"),
10
- ];
9
+ ...articleElement.querySelectorAll(
10
+ 'h1, h2, h3, h4, h5, p, a, li, blockquote'
11
+ ),
12
+ ]
11
13
 
12
14
  articleElements.forEach((contentElement) => {
13
- contentElement.style.fontWeight = 400;
15
+ contentElement.style.fontWeight = 400
14
16
 
15
- const elementText = contentElement.innerText;
16
- const elementTextArray = elementText.split(" ");
17
+ const elementText = contentElement.innerText
18
+ const elementTextArray = elementText.split(' ')
17
19
 
18
20
  const elementTextArrayWithBold = elementTextArray.map((textWord) => {
19
- const wordLength = textWord.length;
21
+ const wordLength = textWord.length
20
22
 
21
23
  if (wordLength === 1) {
22
- return `<strong>${textWord}</strong>`;
24
+ return `<strong>${textWord}</strong>`
23
25
  }
24
26
 
25
- const wordLengthHalf = Math.floor(wordLength / 2);
27
+ const wordLengthHalf = Math.floor(wordLength / 2)
26
28
 
27
- const wordArray = textWord.split("");
29
+ const wordArray = textWord.split('')
28
30
  const wordArrayWithBold = wordArray.map((wordLetter, letterIndex) => {
29
31
  return letterIndex < wordLengthHalf
30
32
  ? `<strong>${wordLetter}</strong>`
31
- : wordLetter;
32
- });
33
+ : wordLetter
34
+ })
33
35
 
34
- return wordArrayWithBold.join("");
35
- });
36
+ return wordArrayWithBold.join('')
37
+ })
36
38
 
37
- contentElement.innerHTML = elementTextArrayWithBold.join(" ");
38
- });
39
+ contentElement.innerHTML = elementTextArrayWithBold.join(' ')
40
+ })
39
41
  }