Skip to content

Commit d15b1a1

Browse files
docs(readme): add animation info and clarify CJT locales
1 parent 7a3e8e5 commit d15b1a1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Features:
44

55
- splitting text into lines, words, and chars
6-
- support for CJT languages (Traditional/Simplified Chinese, Japanese, Korean, etc)
6+
- support for CJT languages (Traditional/Simplified Chinese, Japanese, Korean, Thai)
77
- nested HTML elements (with all the types of splits)
88
- text balancing
99
- accessibility
@@ -25,6 +25,20 @@ import SplitText from '@activetheory/split-text';
2525
const el = document.querySelector('.el');
2626

2727
const splitTextInstance = new SplitText(el);
28+
29+
console.log(splitTextInstance.lines);
30+
console.log(splitTextInstance.words);
31+
console.log(splitTextInstance.chars);
32+
33+
// Useful for animations purposes
34+
for (const line of splitTextInstance.lines) {
35+
console.log(line.__words);
36+
console.log(line.__wordCount);
37+
}
38+
39+
for (const word of splitTextInstance.words) {
40+
console.log(word.__lineIndex);
41+
}
2842
```
2943

3044
## Options
@@ -61,4 +75,6 @@ To run the demo, run `npm run dev`.
6175
### CJT locales
6276

6377
The `handleCJT` option will leverage `​` to split the text properly.
78+
This library does not handle this automatically, you need to manually add `​` in your text.
79+
However, it's not mandatory, you can still use the library without it and most of the time it will work nicely.
6480
We suggest to have a look at https://github.com/google/budoux/ for more information about how to place `​` in your text.

demo/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ document.addEventListener('DOMContentLoaded', () => {
8888
// Initial text
8989
inputText.value = [
9090
/*html*/ `<h1>split anything 🐳 🍔 🍕 into words, chars, lines</h1>`,
91-
/*html*/ `<p>Try typing some text here to see it split into lines, words, and characters!</p>`,
91+
/*html*/ `<p>Try typing some text <a href="https://www.google.com">here</a> to see it split into lines, words, and characters!</p>`,
9292
/*html*/ `<ul>`,
9393
/*html*/ ` <li>pizza <b>margherita</b></li>`,
9494
/*html*/ ` <li>hamburger</li>`,

0 commit comments

Comments
 (0)