paginar 0.1.6 → 0.2.0

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.
@@ -2,6 +2,7 @@ import { computed, reactive } from 'vue'
2
2
 
3
3
  const state = reactive({
4
4
  footnotes: [],
5
+ showFootnotes: false,
5
6
  footnote: null
6
7
  })
7
8
 
@@ -10,18 +11,40 @@ function setFootnotes(footnotes) {
10
11
  state.footnotes = footnotes
11
12
  }
12
13
 
14
+ const showFootnotes = computed(() => state.showFootnotes)
15
+ function setShowFootnotes(value) {
16
+ state.showFootnotes = value
17
+ }
18
+
13
19
  const footnote = computed(() => state.footnote)
14
20
  function setHighlightedFootnote(footnote) {
15
21
  state.footnote = footnote
16
22
  }
17
23
 
18
- function initFootnotes() {
24
+ function applyFootnote(event) {
25
+ const classList = event.target.classList.value.split(' ')
26
+
27
+ if (classList.length === 0)
28
+ return
29
+
30
+ const footnoteTarget = classList.find(
31
+ item => item.includes('footnote') && item !== 'footnote'
32
+ )
19
33
 
34
+ if (footnoteTarget) {
35
+ const ref = state.footnotes.find(item => item.id === footnoteTarget)
36
+ if (ref) {
37
+ state.footnote = ref
38
+ }
39
+ }
20
40
  }
21
41
 
22
42
  export default {
23
43
  footnotes,
24
44
  footnote,
25
45
  setFootnotes,
26
- setHighlightedFootnote
46
+ applyFootnote,
47
+ setHighlightedFootnote,
48
+ setShowFootnotes,
49
+ showFootnotes
27
50
  }
@@ -1,5 +1,7 @@
1
1
  import { reactive, computed, watch } from 'vue'
2
2
  import { onKeyStroke } from '@vueuse/core'
3
+
4
+ import useReaderSettings from './useReaderSettings'
3
5
  import useEstimatePages from './useEstimatePages'
4
6
 
5
7
  const state = reactive({
@@ -12,6 +14,10 @@ const totalPages = computed(() => useEstimatePages.totalPages.value)
12
14
  function init(viewport, content) {
13
15
  useEstimatePages.estimate(viewport, content)
14
16
  addEventListener('wheel', onWheel)
17
+
18
+ setInterval(() => {
19
+ useEstimatePages.estimate(viewport, content)
20
+ }, 5000)
15
21
  }
16
22
 
17
23
  // when resizing the viewport, totalPages change
@@ -24,8 +30,10 @@ watch(totalPages, () => {
24
30
 
25
31
  // navigate by increase/decrease value
26
32
  function next() {
27
- if ((state.currentPage + 1) <= totalPages.value) {
28
- state.currentPage = state.currentPage + 1
33
+ if (!useReaderSettings.blocked.value) {
34
+ if ((state.currentPage + 1) <= totalPages.value) {
35
+ state.currentPage = state.currentPage + 1
36
+ }
29
37
  }
30
38
  }
31
39
  onKeyStroke('ArrowRight', (e) => {
@@ -42,8 +50,10 @@ function onWheel(event) {
42
50
  };
43
51
 
44
52
  function prev() {
45
- if ((state.currentPage - 1) > 0) {
46
- state.currentPage = state.currentPage - 1
53
+ if (!useReaderSettings.blocked.value) {
54
+ if ((state.currentPage - 1) > 0) {
55
+ state.currentPage = state.currentPage - 1
56
+ }
47
57
  }
48
58
  }
49
59
  onKeyStroke('ArrowLeft', (e) => {
@@ -12,7 +12,8 @@ const state = reactive({
12
12
  ],
13
13
  fontSize: 16,
14
14
  columns: 'single',
15
- mode: 'light'
15
+ mode: 'light',
16
+ blocked: false
16
17
  })
17
18
 
18
19
  const baseFont = computed(() => state.baseFont)
@@ -21,6 +22,7 @@ const fontSize = computed(() => state.fontSize)
21
22
  const fontsOptions = computed(() => state.fontsOptions)
22
23
  const columns = computed(() => state.columns)
23
24
  const mode = computed(() => state.mode)
25
+ const blocked = computed(() => state.blocked)
24
26
 
25
27
  watch(
26
28
  [baseFont, textFont, fontSize, columns, mode],
@@ -101,6 +103,10 @@ function setFontSize(value) {
101
103
  state.fontSize = value
102
104
  }
103
105
 
106
+ function setBlocked(value) {
107
+ state.blocked = value
108
+ }
109
+
104
110
  function setMode(value) {
105
111
  state.mode = value
106
112
 
@@ -139,7 +145,9 @@ export default {
139
145
  setColumns,
140
146
  setTextFont,
141
147
  setFontSize,
148
+ setBlocked,
142
149
  mode,
150
+ blocked,
143
151
  setMode,
144
152
  saveSettings
145
153
  }
@@ -1,5 +1,4 @@
1
1
  import { computed, reactive } from 'vue'
2
- import { useEventListener } from '@vueuse/core'
3
2
 
4
3
  const state = reactive({
5
4
  references: [],
@@ -37,27 +36,18 @@ function applyReferences(contentRaw) {
37
36
  }, contentRaw)
38
37
  }
39
38
 
40
- function listenToReferencesClick(contentWrapper) {
41
- setTimeout(() => {
42
- useEventListener(contentWrapper, 'click', getClickedReferenceData)
43
- }, 100)
44
- }
45
-
46
- function getClickedReferenceData(event) {
47
- console.log(event.target.classList)
48
- if (event.target.classList.value.includes('reference')) {
49
- const ref = state.references.find(item => item.cit === event.target.innerText)
50
- if (ref) {
51
- state.reference = ref
52
- }
39
+ function applyReference(event) {
40
+ const ref = state.references.find(item => item.cit === event.target.innerText)
41
+ if (ref) {
42
+ state.reference = ref
53
43
  }
54
44
  }
55
45
 
56
46
  export default {
57
47
  references,
58
48
  reference,
49
+ applyReference,
59
50
  setReferences,
60
51
  setHighlightedReference,
61
52
  applyReferences,
62
- listenToReferencesClick
63
53
  }
@@ -21,10 +21,7 @@ async function stylesheetLoader(stylesheet, ref) {
21
21
  const dataRef = await fetch(stylesheet)
22
22
  const cssText = await dataRef.text()
23
23
 
24
- const style = document.createElement('style')
25
- ref.value.appendChild(style)
26
- style.type = 'text/css'
27
- style.appendChild(document.createTextNode(cssText))
24
+ applyStylesheet(cssText, ref)
28
25
 
29
26
  } catch (err) {
30
27
  console.log({ err })
@@ -32,7 +29,15 @@ async function stylesheetLoader(stylesheet, ref) {
32
29
  }
33
30
  }
34
31
 
32
+ async function applyStylesheet(stylesheet, ref) {
33
+ const style = document.createElement('style')
34
+ ref.value.appendChild(style)
35
+ style.type = 'text/css'
36
+ style.appendChild(document.createTextNode(stylesheet))
37
+ }
38
+
35
39
  export default {
36
40
  fontLoader,
37
- stylesheetLoader
41
+ stylesheetLoader,
42
+ applyStylesheet
38
43
  }
@@ -1,6 +1,8 @@
1
1
  import { computed, reactive } from 'vue'
2
+ import { useEventListener } from '@vueuse/core'
2
3
 
3
4
  import useReferences from './useReferences'
5
+ import useFootnotes from './useFootnotes'
4
6
 
5
7
  const state = reactive({
6
8
  summary: null,
@@ -11,7 +13,8 @@ const content = computed(() => state.content)
11
13
  const summary = computed(() => state.summary)
12
14
 
13
15
  async function initContent(contentString, contentWrapper) {
14
- const { setReferences, applyReferences, listenToReferencesClick } = useReferences
16
+ const { setReferences, applyReferences } = useReferences
17
+ const { setFootnotes } = useFootnotes
15
18
 
16
19
  const content = contentString
17
20
  ? JSON.parse(contentString)
@@ -23,6 +26,9 @@ async function initContent(contentString, contentWrapper) {
23
26
  if (content?.references)
24
27
  setReferences(content.references)
25
28
 
29
+ if (content?.footnotes)
30
+ setFootnotes(content.footnotes)
31
+
26
32
  // if content comes from file, apply references to file
27
33
  if (content?.summary?.[0]?.file) {
28
34
  const text = await getContent(content.summary?.[0]?.file)
@@ -42,7 +48,7 @@ async function initContent(contentString, contentWrapper) {
42
48
  }
43
49
 
44
50
  // after applying references above, now we start to listen to its clicks
45
- listenToReferencesClick(contentWrapper)
51
+ listenToClicks(contentWrapper)
46
52
  }
47
53
 
48
54
  async function getContent(location) {
@@ -62,10 +68,27 @@ function applyContent(text) {
62
68
  state.content = newContent
63
69
  }
64
70
 
71
+ function listenToClicks(contentWrapper) {
72
+ setTimeout(() => {
73
+ useEventListener(contentWrapper, 'click', getClickedReferenceData)
74
+ }, 100)
75
+ }
76
+
77
+ function getClickedReferenceData(event) {
78
+ if (event.target.classList.value.includes('reference')) {
79
+ useReferences.applyReference(event)
80
+ }
81
+
82
+ if (event.target.classList.value.includes('footnote')) {
83
+ useFootnotes.applyFootnote(event)
84
+ }
85
+ }
86
+
65
87
  export default {
66
88
  content,
67
89
  summary,
68
90
  initContent,
69
91
  getContent,
70
- applyContent
92
+ applyContent,
93
+ listenToClicks
71
94
  }
package/src/tailwind.css CHANGED
@@ -563,10 +563,22 @@ video {
563
563
  position: relative;
564
564
  }
565
565
 
566
+ .top-0 {
567
+ top: 0px;
568
+ }
569
+
566
570
  .right-0 {
567
571
  right: 0px;
568
572
  }
569
573
 
574
+ .top-4 {
575
+ top: 1rem;
576
+ }
577
+
578
+ .right-8 {
579
+ right: 2rem;
580
+ }
581
+
570
582
  .bottom-0 {
571
583
  bottom: 0px;
572
584
  }
@@ -583,6 +595,10 @@ video {
583
595
  left: -0.5rem;
584
596
  }
585
597
 
598
+ .z-20 {
599
+ z-index: 20;
600
+ }
601
+
586
602
  .z-40 {
587
603
  z-index: 40;
588
604
  }
@@ -614,6 +630,22 @@ video {
614
630
  margin-bottom: 2rem;
615
631
  }
616
632
 
633
+ .mb-10 {
634
+ margin-bottom: 2.5rem;
635
+ }
636
+
637
+ .ml-4 {
638
+ margin-left: 1rem;
639
+ }
640
+
641
+ .ml-10 {
642
+ margin-left: 2.5rem;
643
+ }
644
+
645
+ .mt-10 {
646
+ margin-top: 2.5rem;
647
+ }
648
+
617
649
  .mt-3 {
618
650
  margin-top: 0.75rem;
619
651
  }
@@ -626,10 +658,6 @@ video {
626
658
  margin-left: 0.75rem;
627
659
  }
628
660
 
629
- .ml-4 {
630
- margin-left: 1rem;
631
- }
632
-
633
661
  .mb-2 {
634
662
  margin-bottom: 0.5rem;
635
663
  }
@@ -650,14 +678,22 @@ video {
650
678
  display: none;
651
679
  }
652
680
 
653
- .h-full {
654
- height: 100%;
681
+ .h-screen {
682
+ height: 100vh;
655
683
  }
656
684
 
657
685
  .h-6 {
658
686
  height: 1.5rem;
659
687
  }
660
688
 
689
+ .h-8 {
690
+ height: 2rem;
691
+ }
692
+
693
+ .h-full {
694
+ height: 100%;
695
+ }
696
+
661
697
  .h-10 {
662
698
  height: 2.5rem;
663
699
  }
@@ -670,14 +706,22 @@ video {
670
706
  width: 100%;
671
707
  }
672
708
 
673
- .w-4\/5 {
674
- width: 80%;
709
+ .w-96 {
710
+ width: 24rem;
675
711
  }
676
712
 
677
713
  .w-6 {
678
714
  width: 1.5rem;
679
715
  }
680
716
 
717
+ .w-8 {
718
+ width: 2rem;
719
+ }
720
+
721
+ .w-4\/5 {
722
+ width: 80%;
723
+ }
724
+
681
725
  .w-5 {
682
726
  width: 1.25rem;
683
727
  }
@@ -686,6 +730,10 @@ video {
686
730
  width: 15rem;
687
731
  }
688
732
 
733
+ .flex-shrink-0 {
734
+ flex-shrink: 0;
735
+ }
736
+
689
737
  .scale-95 {
690
738
  --tw-scale-x: .95;
691
739
  --tw-scale-y: .95;
@@ -738,10 +786,18 @@ video {
738
786
  align-self: flex-end;
739
787
  }
740
788
 
789
+ .overflow-auto {
790
+ overflow: auto;
791
+ }
792
+
741
793
  .overflow-hidden {
742
794
  overflow: hidden;
743
795
  }
744
796
 
797
+ .overflow-x-hidden {
798
+ overflow-x: hidden;
799
+ }
800
+
745
801
  .rounded {
746
802
  border-radius: 0.25rem;
747
803
  }
@@ -772,6 +828,10 @@ video {
772
828
  border-color: rgb(209 213 219 / var(--tw-border-opacity));
773
829
  }
774
830
 
831
+ .border-b-white\/25 {
832
+ border-bottom-color: rgb(255 255 255 / 0.25);
833
+ }
834
+
775
835
  .bg-gray-800 {
776
836
  --tw-bg-opacity: 1;
777
837
  background-color: rgb(31 41 55 / var(--tw-bg-opacity));
@@ -800,6 +860,11 @@ video {
800
860
  padding-right: 2.5rem;
801
861
  }
802
862
 
863
+ .py-4 {
864
+ padding-top: 1rem;
865
+ padding-bottom: 1rem;
866
+ }
867
+
803
868
  .px-2 {
804
869
  padding-left: 0.5rem;
805
870
  padding-right: 0.5rem;
@@ -810,11 +875,6 @@ video {
810
875
  padding-bottom: 0.75rem;
811
876
  }
812
877
 
813
- .py-4 {
814
- padding-top: 1rem;
815
- padding-bottom: 1rem;
816
- }
817
-
818
878
  .px-3 {
819
879
  padding-left: 0.75rem;
820
880
  padding-right: 0.75rem;
@@ -824,6 +884,14 @@ video {
824
884
  padding-top: 2.5rem;
825
885
  }
826
886
 
887
+ .pl-4 {
888
+ padding-left: 1rem;
889
+ }
890
+
891
+ .pb-10 {
892
+ padding-bottom: 2.5rem;
893
+ }
894
+
827
895
  .text-left {
828
896
  text-align: left;
829
897
  }
@@ -851,6 +919,10 @@ video {
851
919
  font-weight: 300;
852
920
  }
853
921
 
922
+ .lowercase {
923
+ text-transform: lowercase;
924
+ }
925
+
854
926
  .tracking-wide {
855
927
  letter-spacing: 0.025em;
856
928
  }
@@ -875,6 +947,10 @@ video {
875
947
  color: rgb(0 0 0 / var(--tw-text-opacity));
876
948
  }
877
949
 
950
+ .opacity-50 {
951
+ opacity: 0.5;
952
+ }
953
+
878
954
  .opacity-100 {
879
955
  opacity: 1;
880
956
  }
@@ -891,6 +967,12 @@ video {
891
967
  opacity: 0.3;
892
968
  }
893
969
 
970
+ .shadow-2xl {
971
+ --tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
972
+ --tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);
973
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
974
+ }
975
+
894
976
  .shadow {
895
977
  --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
896
978
  --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
@@ -915,12 +997,6 @@ video {
915
997
  transition-duration: 150ms;
916
998
  }
917
999
 
918
- .transition-opacity {
919
- transition-property: opacity;
920
- transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
921
- transition-duration: 150ms;
922
- }
923
-
924
1000
  .transition {
925
1001
  transition-property: color, background-color, border-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-text-decoration-color, -webkit-backdrop-filter;
926
1002
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
@@ -929,6 +1005,12 @@ video {
929
1005
  transition-duration: 150ms;
930
1006
  }
931
1007
 
1008
+ .transition-opacity {
1009
+ transition-property: opacity;
1010
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
1011
+ transition-duration: 150ms;
1012
+ }
1013
+
932
1014
  .duration-100 {
933
1015
  transition-duration: 100ms;
934
1016
  }
@@ -949,6 +1031,10 @@ video {
949
1031
  transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
950
1032
  }
951
1033
 
1034
+ .last\:border-transparent:last-child {
1035
+ border-color: transparent;
1036
+ }
1037
+
952
1038
  .hover\:bg-gray-100:hover {
953
1039
  --tw-bg-opacity: 1;
954
1040
  background-color: rgb(243 244 246 / var(--tw-bg-opacity));