paginar 0.2.2 → 0.2.4
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/demo/slot/slot-chapter1.html +1 -1
- package/dist/index.es.js +83 -15
- package/dist/index.es.js.map +1 -1
- package/dist/style.css +10 -15
- package/package.json +1 -1
- package/src/components/FootnotesAside.vue +1 -1
- package/src/components/HeaderSlot/OptionsButton/OptionsColor.vue +4 -4
- package/src/composables/useEstimatePages.js +3 -0
- package/src/composables/usePagination.js +38 -1
- package/src/composables/useReferences.js +17 -5
- package/src/composables/useTextContent.js +18 -1
- package/src/tailwind.css +4 -9
package/dist/style.css
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
.width-enter-active[data-v-
|
|
3
|
-
.width-leave-active[data-v-
|
|
2
|
+
.width-enter-active[data-v-4f3c3c73],
|
|
3
|
+
.width-leave-active[data-v-4f3c3c73] {
|
|
4
4
|
transition: width .5s;
|
|
5
5
|
}
|
|
6
|
-
.width-enter-active>*[data-v-
|
|
6
|
+
.width-enter-active>*[data-v-4f3c3c73] {
|
|
7
7
|
transition-property: opacity;
|
|
8
8
|
transition-duration: .2s;
|
|
9
9
|
transition-delay: .3s;
|
|
10
10
|
}
|
|
11
|
-
.width-leave-active>*[data-v-
|
|
11
|
+
.width-leave-active>*[data-v-4f3c3c73] {
|
|
12
12
|
transition: opacity .25s;
|
|
13
13
|
}
|
|
14
|
-
.width-enter[data-v-
|
|
15
|
-
.width-leave-to[data-v-
|
|
14
|
+
.width-enter[data-v-4f3c3c73],
|
|
15
|
+
.width-leave-to[data-v-4f3c3c73] {
|
|
16
16
|
width: 0;
|
|
17
17
|
}
|
|
18
18
|
/*
|
|
@@ -659,10 +659,6 @@ video {
|
|
|
659
659
|
margin-left: 2.5rem;
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
.mb-10 {
|
|
663
|
-
margin-bottom: 2.5rem;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
662
|
.mt-3 {
|
|
667
663
|
margin-top: 0.75rem;
|
|
668
664
|
}
|
|
@@ -863,6 +859,10 @@ video {
|
|
|
863
859
|
padding: 1rem;
|
|
864
860
|
}
|
|
865
861
|
|
|
862
|
+
.p-10 {
|
|
863
|
+
padding: 2.5rem;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
866
|
.p-3 {
|
|
867
867
|
padding: 0.75rem;
|
|
868
868
|
}
|
|
@@ -950,11 +950,6 @@ video {
|
|
|
950
950
|
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
951
951
|
}
|
|
952
952
|
|
|
953
|
-
.text-gray-800 {
|
|
954
|
-
--tw-text-opacity: 1;
|
|
955
|
-
color: rgb(31 41 55 / var(--tw-text-opacity));
|
|
956
|
-
}
|
|
957
|
-
|
|
958
953
|
.text-black {
|
|
959
954
|
--tw-text-opacity: 1;
|
|
960
955
|
color: rgb(0 0 0 / var(--tw-text-opacity));
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "A flipping page web component for reading long texts on the brower",
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.4",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/educkf/paginar.git"
|
|
@@ -85,7 +85,7 @@ watch(
|
|
|
85
85
|
:id="footnoteItem.id"
|
|
86
86
|
v-html="`<span class='footnote-index'>${index + 1}.</span> ${footnoteItem.text}`"
|
|
87
87
|
class="text-left border-b border-b-white/25 last:border-transparent
|
|
88
|
-
|
|
88
|
+
p-10 relative
|
|
89
89
|
"
|
|
90
90
|
:class="footnote && footnote.id !== footnoteItem.id
|
|
91
91
|
? 'opacity-50'
|
|
@@ -10,18 +10,18 @@ const { mode, setMode } = useReaderSettings
|
|
|
10
10
|
<template>
|
|
11
11
|
<button @click.prevent="setMode('light')"
|
|
12
12
|
title="Leitura diurna"
|
|
13
|
-
class="font-light text-base border
|
|
13
|
+
class="font-light text-base border w-full h-10 flex justify-center items-center"
|
|
14
14
|
:class="{
|
|
15
|
-
'bg-primary-extralight text-
|
|
15
|
+
'bg-primary-extralight text-primary border-2 border-primary': mode === 'light'
|
|
16
16
|
}">
|
|
17
17
|
<IconSun class="w-5 h-5" />
|
|
18
18
|
</button>
|
|
19
19
|
|
|
20
20
|
<button @click.prevent="setMode('dark')"
|
|
21
21
|
title="Leitura noturna"
|
|
22
|
-
class="font-light text-base border
|
|
22
|
+
class="font-light text-base border w-full h-10 flex justify-center items-center"
|
|
23
23
|
:class="{
|
|
24
|
-
'bg-primary-extralight text-
|
|
24
|
+
'bg-primary-extralight text-primary border-2 border-primary': mode === 'dark'
|
|
25
25
|
}">
|
|
26
26
|
<IconMoon class="w-5 h-5" />
|
|
27
27
|
</button>
|
|
@@ -11,12 +11,15 @@ function estimate(viewport, content) {
|
|
|
11
11
|
|
|
12
12
|
if (contentWidth > viewportWidth) {
|
|
13
13
|
state.totalPages = Math.ceil(contentWidth / viewportWidth)
|
|
14
|
+
return Math.ceil(contentWidth / viewportWidth)
|
|
14
15
|
|
|
15
16
|
} else {
|
|
16
17
|
state.totalPages = 1
|
|
18
|
+
return 1
|
|
17
19
|
}
|
|
18
20
|
} else {
|
|
19
21
|
state.totalPages = 1
|
|
22
|
+
return 1
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
|
|
@@ -3,9 +3,12 @@ import { onKeyStroke } from '@vueuse/core'
|
|
|
3
3
|
|
|
4
4
|
import useReaderSettings from './useReaderSettings'
|
|
5
5
|
import useEstimatePages from './useEstimatePages'
|
|
6
|
+
import useTextContent from './useTextContent'
|
|
6
7
|
|
|
7
8
|
const state = reactive({
|
|
8
|
-
currentPage: 1
|
|
9
|
+
currentPage: 1,
|
|
10
|
+
nextTry: 0,
|
|
11
|
+
prevTry: 0
|
|
9
12
|
})
|
|
10
13
|
|
|
11
14
|
const currentPage = computed(() => state.currentPage)
|
|
@@ -13,6 +16,18 @@ const totalPages = computed(() => useEstimatePages.totalPages.value)
|
|
|
13
16
|
|
|
14
17
|
function init(viewport, content) {
|
|
15
18
|
useEstimatePages.estimate(viewport, content)
|
|
19
|
+
|
|
20
|
+
// check if there is a query string for oring, and
|
|
21
|
+
// if previews chapter was the next one. If so,
|
|
22
|
+
// start from the end, as we are coming backwards
|
|
23
|
+
const urlParams = new URLSearchParams(window.location.search)
|
|
24
|
+
const origin = urlParams.get('origin')
|
|
25
|
+
if (origin && origin === 'next') {
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
state.currentPage = totalPages.value
|
|
28
|
+
}, 200)
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
addEventListener('wheel', onWheel)
|
|
17
32
|
|
|
18
33
|
setInterval(() => {
|
|
@@ -33,6 +48,17 @@ function next() {
|
|
|
33
48
|
if (!useReaderSettings.blocked.value) {
|
|
34
49
|
if ((state.currentPage + 1) <= totalPages.value) {
|
|
35
50
|
state.currentPage = state.currentPage + 1
|
|
51
|
+
} else {
|
|
52
|
+
// prevent going too fast to next chapter on
|
|
53
|
+
// stronger scroll
|
|
54
|
+
if (state.nextTry < 4) {
|
|
55
|
+
state.nextTry += 1
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
const context = useTextContent.context.value
|
|
59
|
+
if (context.surround?.after) {
|
|
60
|
+
window.location.href = context.surround.after.link + (`?origin=prev`)
|
|
61
|
+
}
|
|
36
62
|
}
|
|
37
63
|
}
|
|
38
64
|
}
|
|
@@ -53,6 +79,17 @@ function prev() {
|
|
|
53
79
|
if (!useReaderSettings.blocked.value) {
|
|
54
80
|
if ((state.currentPage - 1) > 0) {
|
|
55
81
|
state.currentPage = state.currentPage - 1
|
|
82
|
+
} else {
|
|
83
|
+
// prevent going too fast to prev chapter on
|
|
84
|
+
// stronger scroll
|
|
85
|
+
if (state.prevTry < 4) {
|
|
86
|
+
state.prevTry += 1
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
const context = useTextContent.context.value
|
|
90
|
+
if (context.surround?.before) {
|
|
91
|
+
window.location.href = context.surround.before.link + (`?origin=next`)
|
|
92
|
+
}
|
|
56
93
|
}
|
|
57
94
|
}
|
|
58
95
|
}
|
|
@@ -28,7 +28,9 @@ function applyReferences(contentRaw) {
|
|
|
28
28
|
const regex = new RegExp(reference.cit, 'g');
|
|
29
29
|
const newContent = content.replace(
|
|
30
30
|
regex,
|
|
31
|
-
`<span class='reference
|
|
31
|
+
`<span class='reference reference-${reference.cit.replaceAll(' ', '')}'>
|
|
32
|
+
${reference.cit}
|
|
33
|
+
</span>`
|
|
32
34
|
)
|
|
33
35
|
return newContent
|
|
34
36
|
}
|
|
@@ -37,12 +39,22 @@ function applyReferences(contentRaw) {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
function applyReference(event) {
|
|
40
|
-
const
|
|
42
|
+
const classList = event.target.closest('.reference')?.classList.value.split(' ')
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (classList.length === 0)
|
|
45
|
+
return
|
|
46
|
+
|
|
47
|
+
const target = classList.find(item => item.startsWith('reference-'))
|
|
48
|
+
|
|
49
|
+
if (target) {
|
|
50
|
+
const ref = state.references.find(
|
|
51
|
+
item => target && item.cit.replaceAll(' ', '') === target.replace('reference-', '')
|
|
52
|
+
)
|
|
53
|
+
if (ref) {
|
|
54
|
+
state.reference = ref
|
|
55
|
+
}
|
|
45
56
|
}
|
|
57
|
+
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
export default {
|
|
@@ -11,6 +11,22 @@ const state = reactive({
|
|
|
11
11
|
|
|
12
12
|
const content = computed(() => state.content)
|
|
13
13
|
const summary = computed(() => state.summary)
|
|
14
|
+
const context = computed(() => {
|
|
15
|
+
const current = state.summary.findIndex(
|
|
16
|
+
chapter => window.location.href.includes(chapter.link)
|
|
17
|
+
)
|
|
18
|
+
return {
|
|
19
|
+
chapter: state.summary[current],
|
|
20
|
+
surround: {
|
|
21
|
+
before: current - 1 >= 0
|
|
22
|
+
? state.summary[current - 1]
|
|
23
|
+
: null,
|
|
24
|
+
after: current + 1 <= state.summary.length
|
|
25
|
+
? state.summary[current + 1]
|
|
26
|
+
: null,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
14
30
|
|
|
15
31
|
async function initContent(contentString, contentWrapper) {
|
|
16
32
|
const { setReferences, applyReferences } = useReferences
|
|
@@ -92,5 +108,6 @@ export default {
|
|
|
92
108
|
initContent,
|
|
93
109
|
getContent,
|
|
94
110
|
applyContent,
|
|
95
|
-
listenToClicks
|
|
111
|
+
listenToClicks,
|
|
112
|
+
context
|
|
96
113
|
}
|
package/src/tailwind.css
CHANGED
|
@@ -642,10 +642,6 @@ video {
|
|
|
642
642
|
margin-left: 2.5rem;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
-
.mb-10 {
|
|
646
|
-
margin-bottom: 2.5rem;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
645
|
.mt-3 {
|
|
650
646
|
margin-top: 0.75rem;
|
|
651
647
|
}
|
|
@@ -846,6 +842,10 @@ video {
|
|
|
846
842
|
padding: 1rem;
|
|
847
843
|
}
|
|
848
844
|
|
|
845
|
+
.p-10 {
|
|
846
|
+
padding: 2.5rem;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
849
|
.p-3 {
|
|
850
850
|
padding: 0.75rem;
|
|
851
851
|
}
|
|
@@ -933,11 +933,6 @@ video {
|
|
|
933
933
|
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
934
934
|
}
|
|
935
935
|
|
|
936
|
-
.text-gray-800 {
|
|
937
|
-
--tw-text-opacity: 1;
|
|
938
|
-
color: rgb(31 41 55 / var(--tw-text-opacity));
|
|
939
|
-
}
|
|
940
|
-
|
|
941
936
|
.text-black {
|
|
942
937
|
--tw-text-opacity: 1;
|
|
943
938
|
color: rgb(0 0 0 / var(--tw-text-opacity));
|