paginar 0.2.7 → 0.3.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.
- package/LICENSE.md +21 -0
- package/README.md +234 -4
- package/demo/slot/slot-chapter1.html +34 -7
- package/demo/summary/_content/1chapter.html +3 -0
- package/demo/summary/index.html +11 -0
- package/dist/index.es.js +252 -160
- package/dist/index.es.js.map +1 -1
- package/dist/style.css +13 -12
- package/package.json +1 -1
- package/src/App.ce.vue +9 -14
- package/src/components/HeaderSlot/HeaderSlot.vue +3 -3
- package/src/components/HeaderSlot/OptionsButton/OptionsButton.vue +2 -2
- package/src/components/HeaderSlot/OptionsButton/OptionsColor.vue +2 -2
- package/src/components/HeaderSlot/OptionsButton/OptionsColumns.vue +3 -1
- package/src/components/HeaderSlot/OptionsButton/OptionsDropdown.vue +13 -9
- package/src/components/HeaderSlot/OptionsButton/OptionsFontFamily.vue +1 -1
- package/src/components/HeaderSlot/OptionsButton/OptionsFontSize.vue +2 -2
- package/src/components/HeaderSlot/SummaryButton/SummaryButton.vue +32 -27
- package/src/components/HeaderSlot/SummaryButton/SummaryDropdown.vue +1 -1
- package/src/composables/useReaderSettings.js +23 -2
- package/src/composables/useStyles.js +20 -3
- package/src/tailwind.css +9 -29
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Eduardo Camillo Kasparevicis Ferreira & Sabiá Publisher
|
|
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/README.md
CHANGED
|
@@ -1,12 +1,242 @@
|
|
|
1
1
|
# Paginar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Web Component para transformar conteúdos HTML em uma visualização paginada, melhorando a leitura no browser, navegação, customização etc.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
-----
|
|
6
|
+
|
|
7
|
+
### Exemplo real em uso (com alguma complexidade)
|
|
8
|
+
|
|
9
|
+
[link](https://sabia.pub/book/okabayashi-uma-perspectiva-decolonial-para-o-design-no-brasil/read/haDxQvbtIIX4Hh5cOyee/content)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Como usar
|
|
13
|
+
|
|
14
|
+
Via CDN, basta incluir ao final do html, antes do fechamento da tag body, o script:
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<script type="module" src="https://cdn.jsdelivr.net/gh/sabia-publisher/paginar/dist/index.es.js"></script>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Esse link acima sempre puxa a última versão disponível para o software, e também as melhorias que eventualmente fazemos.
|
|
21
|
+
|
|
22
|
+
Para apontar para uma versão estável, e assim evitar possíveis bugs ou desconfigurações vindas das melhorias, pode ser da seguinte maneira:
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script type="module" src="https://unpkg.com/paginar@0.2.8/dist/index.es.js"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
No corpo do html, no local onde deseja que seja renderizado o leitor, utilizar o Web Component conforme abaixo, e inclua o conteúdo que deseja paginar dentro de um div com propriedade slot="content":
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<paginate-content id="pagination-el">
|
|
32
|
+
<div slot="content">
|
|
33
|
+
<p>Conteúdo HTML para paginar</p>
|
|
34
|
+
</div>
|
|
35
|
+
</paginate-content>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Customização
|
|
39
|
+
|
|
40
|
+
### Parametros de customização disponíveis
|
|
41
|
+
|
|
42
|
+
O web component disponibiliza algumas interfaces de customização por via de um objeto a ser linkado ao web component, conforme o exemplo:
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<paginate-content id="pagination-el">
|
|
46
|
+
<div slot="content">
|
|
47
|
+
<p>Conteúdo de uma pagina.</p>
|
|
48
|
+
</div>
|
|
49
|
+
</paginate-content>
|
|
50
|
+
|
|
51
|
+
<script>
|
|
52
|
+
const settings = {
|
|
53
|
+
fontSize: 19, // number
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const paginationEl = document.getElementById('pagination-el')
|
|
57
|
+
if (paginationEl) {
|
|
58
|
+
paginationEl.setAttribute("reader-settings", JSON.stringify(settings))
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Nesse exemplo, configuramos o tamanho padrão de `font-size` da interface e texto como `19px`. As demais configurações disponíveis até o momento são:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
const settings = {
|
|
67
|
+
// fontSize
|
|
68
|
+
// tamanho da fonte
|
|
69
|
+
// tipagem: número
|
|
70
|
+
fontSize: 19,
|
|
71
|
+
|
|
72
|
+
// textFont
|
|
73
|
+
// designa a fonte base a ser usada no corpo do texto
|
|
74
|
+
textFont: 'Times New Roman',
|
|
75
|
+
|
|
76
|
+
// baseFont
|
|
77
|
+
// designa a fonte padrão para a interface do paginador como um todo
|
|
78
|
+
baseFont: '"Inter", sans-serif',
|
|
79
|
+
|
|
80
|
+
// homeUrl
|
|
81
|
+
// URL a ser direcionado pelo botao de home ao lado do sumário.
|
|
82
|
+
// se nao for adicionada a opcao aqui, o botao de home nao aparecerá
|
|
83
|
+
homeUrl: 'https://sabia.pub',
|
|
84
|
+
|
|
85
|
+
// bookTitle
|
|
86
|
+
// titulo do livro, a ser mostrado no cabeçalho do paginador
|
|
87
|
+
bookTitle: 'A Tale of Two Cities',
|
|
88
|
+
|
|
89
|
+
// chapterTitle
|
|
90
|
+
// titulo do capítulo, a ser mostrado no cabeçalho do paginador
|
|
91
|
+
chapterTitle: 'Chapter One - The Period',
|
|
92
|
+
|
|
93
|
+
// fontsOptions
|
|
94
|
+
// customização da lista de fontes disponíveis para o usuário customizar
|
|
95
|
+
// a tela de leitura. Deve ser uma lista de até 4 opções, com o nome
|
|
96
|
+
// da fonte, o label a ser apresentado para o leitur, se é default ou nao
|
|
97
|
+
// e um link de onde essa fonte deve ser importada, caso não seja uma
|
|
98
|
+
// fonte de sistema
|
|
99
|
+
fontsOptions: [
|
|
100
|
+
{
|
|
101
|
+
label: 'Times New Roman',
|
|
102
|
+
name: 'TimesNewRoman, Times New Roman, Times, Baskerville, Georgia,serif',
|
|
103
|
+
defaultTextFont: true // fonte padrão do corpo do texto
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
label: 'Inter',
|
|
107
|
+
name: '"Inter", sans-serif',
|
|
108
|
+
link: 'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700&display=swap',
|
|
109
|
+
defaultBaseFont: true // fonte padrão da interface de paginação
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: 'Open Dyslexic',
|
|
113
|
+
name: '"Open-Dyslexic", sans-serif',
|
|
114
|
+
link: 'https://fonts.cdnfonts.com/css/open-dyslexic'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
label: 'Atkinson Hyperlegible',
|
|
118
|
+
name: 'Atkinson Hyperlegible',
|
|
119
|
+
link: 'https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&display=swap'
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
|
|
123
|
+
// cssString
|
|
124
|
+
// possibilita que CSS seja enxertado no escopo do web component
|
|
125
|
+
// para a customização da interface em si (conceito explicado abaixo,
|
|
126
|
+
// no item de "Aplicando estilos na interface do paginador")
|
|
127
|
+
// no exemplo abaixo, mudamos a cor do cabeçalho para transparente
|
|
128
|
+
// e o padding do cabeçalho. Existem diversas classes e ids auxiliares na
|
|
129
|
+
// interface, que podem ser explorados pelo inspetor de elementos do
|
|
130
|
+
// navegador.
|
|
131
|
+
// no segundo estilo, escondemos o menu de "Notas de rodapé" do menu
|
|
132
|
+
// de opções
|
|
133
|
+
cssString: `
|
|
134
|
+
header#component-header {
|
|
135
|
+
background-color: transparent;
|
|
136
|
+
padding: 5px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#footnotes-button {
|
|
140
|
+
display: none;
|
|
141
|
+
}
|
|
142
|
+
`
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
### Aplicando estilo no corpo do texto
|
|
149
|
+
|
|
150
|
+
O conteúdo que vai dentro do `<div slot="content"></div>` pode ser customizado por CSS, seja por importação de um link p/ arquivo CSS, ou seja por uma tag `<style>` fora do componente de `<page-content>`.
|
|
151
|
+
|
|
152
|
+
No exemplo abaixo, na classe `.page-break` criamos uma classe-auxiliar que força uma quebra de coluna/página. E também aplicamos uma classe geral em todos os parágrafos, para controlar a indentação:
|
|
153
|
+
|
|
154
|
+
```html
|
|
155
|
+
<style>
|
|
156
|
+
.page-break {
|
|
157
|
+
break-before: column;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
p {
|
|
161
|
+
text-indent: 4rem;
|
|
162
|
+
}
|
|
163
|
+
</style>
|
|
164
|
+
|
|
165
|
+
<paginate-content id="pagination-el" book-title="Título do livro">
|
|
166
|
+
<div slot="content">
|
|
167
|
+
<p>Conteúdo de uma pagina.</p>
|
|
168
|
+
<div class="page-break"></div>
|
|
169
|
+
<p>Conteúdo da próxima página.</div>
|
|
170
|
+
</div>
|
|
171
|
+
</paginate-content>
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Aplicando estilos na interface do paginador
|
|
176
|
+
|
|
177
|
+
No entanto, a maneira acima demonstrada não possibilita alterar o estilo da interface em sí do paginador. Isso porque o escopo do CSS do paginador está dentro de um [**web component**](https://developer.mozilla.org/en-US/docs/Web/API/Web_components), que possui escopo isolado do restante da página, aninhados no `shadow dom` daquele componente.
|
|
178
|
+
|
|
179
|
+
Para alterar o estilo da interface do web component, precisamos inserir o CSS almejado no escopo do web component. Para isso, disponibilizamos uma interface via parametros da configuração do componente, conforme exemplo a seguir:
|
|
180
|
+
|
|
181
|
+
```html
|
|
182
|
+
<paginate-content id="pagination-el" book-title="Título do livro">
|
|
183
|
+
<div slot="content">
|
|
184
|
+
<p>Conteúdo de uma pagina.</p>
|
|
185
|
+
</div>
|
|
186
|
+
</paginate-content>
|
|
187
|
+
|
|
188
|
+
<script>
|
|
189
|
+
const settings = {
|
|
190
|
+
// outras opções
|
|
191
|
+
cssString: `
|
|
192
|
+
main#rootComponent {
|
|
193
|
+
transition: background-color 200ms linear;
|
|
194
|
+
}
|
|
195
|
+
`
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const paginationEl = document.getElementById('pagination-el')
|
|
199
|
+
if (paginationEl) {
|
|
200
|
+
paginationEl.setAttribute("reader-settings", JSON.stringify(settings))
|
|
201
|
+
}
|
|
202
|
+
</script>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
-----
|
|
207
|
+
|
|
208
|
+
### Exemplos didáticos
|
|
209
|
+
|
|
210
|
+
Para customizações especiais, navegue pelos exemplos abaixo e inspecione o código como ele funciona.
|
|
211
|
+
|
|
212
|
+
[Uso básico](https://educkf.github.io/paginar-exemplos/exemplo1/exemplo1.html)
|
|
213
|
+
|
|
214
|
+
[Mostrar logo no cabeçalho](https://educkf.github.io/paginar-exemplos/exemplo1/exemplo1-com-logo-no-cabecalho.html)
|
|
215
|
+
|
|
216
|
+
[Com sumário](https://educkf.github.io/paginar-exemplos/exemplo2/exemplo2-cap1.html)
|
|
217
|
+
|
|
218
|
+
[Fontes especiais p/ menu de opções](https://educkf.github.io/paginar-exemplos/exemplo3/exemplo3.html)
|
|
219
|
+
|
|
220
|
+
Notas de rodapé (em breve)
|
|
221
|
+
|
|
222
|
+
Referências bibliográficas (em breve)
|
|
223
|
+
|
|
224
|
+
Customizar cores (em breve)
|
|
225
|
+
|
|
226
|
+
Customizar apresentaçào de páginas (abertura, cores de fundo, quebra de pagina etc. Em breve)
|
|
227
|
+
|
|
228
|
+
-----
|
|
229
|
+
|
|
230
|
+
### Exemplo real em uso (com alguma complexidade)
|
|
231
|
+
|
|
232
|
+
[link](https://sabia.pub/book/okabayashi-uma-perspectiva-decolonial-para-o-design-no-brasil/read/haDxQvbtIIX4Hh5cOyee/content)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
### Desenvolvimento
|
|
6
236
|
|
|
7
237
|
- [X] Custom Component (or Web Component) to be used in any environment
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
238
|
+
- [X] Paginate html/markdown content
|
|
239
|
+
- [X] Auto-generate Summary
|
|
10
240
|
- [X] Auto-recognize references and link accordingly
|
|
11
241
|
- [ ] Navigate to specific point in content
|
|
12
242
|
- [X] Customize options and summary menu
|
|
@@ -35,15 +35,25 @@
|
|
|
35
35
|
.reference:hover, .footnote:hover {
|
|
36
36
|
border-bottom: 2px solid #333;
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
p {
|
|
40
|
+
text-indent: 4rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.page-break {
|
|
44
|
+
break-before: column;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.page-break span {
|
|
48
|
+
background-color: #eee;
|
|
49
|
+
padding: 5px;
|
|
50
|
+
font-family: monospace;
|
|
51
|
+
display: block;
|
|
52
|
+
}
|
|
38
53
|
</style>
|
|
39
54
|
|
|
40
55
|
<div id="app">
|
|
41
|
-
<paginate-content id="pagination-el"
|
|
42
|
-
css-string="#rootComponent.currentPage-1{background-color: transparent !important; transition: background-color 200ms linear;}"
|
|
43
|
-
>
|
|
44
|
-
<div slot="header">
|
|
45
|
-
<img src="https://sabia.pub/images/logo-mobile-dark.svg" style="height: 40px">
|
|
46
|
-
</div>
|
|
56
|
+
<paginate-content id="pagination-el">
|
|
47
57
|
<div slot="content">
|
|
48
58
|
<h2>
|
|
49
59
|
CHAPTER I.<br>The Period
|
|
@@ -59,6 +69,9 @@
|
|
|
59
69
|
authorities insisted on its being received, for good or for evil, in the
|
|
60
70
|
superlative degree of comparison only.
|
|
61
71
|
</p>
|
|
72
|
+
<div class="page-break">
|
|
73
|
+
<span>Page Break</span>
|
|
74
|
+
</div>
|
|
62
75
|
<p>
|
|
63
76
|
There were a king with a large jaw and a queen with a plain face, on the
|
|
64
77
|
throne of England; there were a king with (LEON, 2006) a large jaw and a queen with a
|
|
@@ -148,7 +161,21 @@
|
|
|
148
161
|
</div>
|
|
149
162
|
<script>
|
|
150
163
|
const settings = {
|
|
151
|
-
baseFont: 'Verdana, sans-serif'
|
|
164
|
+
baseFont: 'Verdana, sans-serif',
|
|
165
|
+
|
|
166
|
+
homeUrl: 'https://sabia.pub',
|
|
167
|
+
|
|
168
|
+
bookTitle: 'A Tale of Two Cities',
|
|
169
|
+
chapterTitle: 'Chapter One - The Period',
|
|
170
|
+
|
|
171
|
+
cssString: `
|
|
172
|
+
header#component-header {
|
|
173
|
+
background-color: #000;
|
|
174
|
+
}
|
|
175
|
+
#footnotes-button {
|
|
176
|
+
display: none;
|
|
177
|
+
}
|
|
178
|
+
`
|
|
152
179
|
}
|
|
153
180
|
|
|
154
181
|
const content = {
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
authorities insisted on its being received, for good or for evil, in the
|
|
13
13
|
superlative degree of comparison only.
|
|
14
14
|
</p>
|
|
15
|
+
<div class="page-break">
|
|
16
|
+
<span>Page Break</span>
|
|
17
|
+
</div>
|
|
15
18
|
<p>
|
|
16
19
|
There were a king with a large jaw and a queen with a plain face, on the
|
|
17
20
|
throne of England; there were a king with (LEON, 2006) a large jaw and a queen with a
|
package/demo/summary/index.html
CHANGED