Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pagedjs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guillaume
pagedjs
Commits
04d2a0c4
Commit
04d2a0c4
authored
Jun 22, 2020
by
Guillaume
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolves
#220
reset the page counter once per unique element
parent
59191637
Pipeline
#564
passed with stage
in 4 minutes and 28 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
2 deletions
+100
-2
counter-page-reset-scope-spec-js-counter-page-reset-scope-should-create-a-pdf-1-snap.png
...s-counter-page-reset-scope-should-create-a-pdf-1-snap.png
+0
-0
counter-page-reset-scope-spec-js-counter-page-reset-scope-should-create-a-pdf-2-snap.png
...s-counter-page-reset-scope-should-create-a-pdf-2-snap.png
+0
-0
counter-page-reset-scope-spec-js-counter-page-reset-scope-should-create-a-pdf-3-snap.png
...s-counter-page-reset-scope-should-create-a-pdf-3-snap.png
+0
-0
counter-page-reset-scope.html
...counters/counter-page-reset/counter-page-reset-scope.html
+63
-0
counter-page-reset-scope.spec.js
...nters/counter-page-reset/counter-page-reset-scope.spec.js
+26
-0
counters.js
src/modules/paged-media/counters.js
+11
-2
No files found.
specs/counters/counter-page-reset/__image_snapshots_linux__/counter-page-reset-scope-spec-js-counter-page-reset-scope-should-create-a-pdf-1-snap.png
0 → 100644
View file @
04d2a0c4
16.7 KB
specs/counters/counter-page-reset/__image_snapshots_linux__/counter-page-reset-scope-spec-js-counter-page-reset-scope-should-create-a-pdf-2-snap.png
0 → 100644
View file @
04d2a0c4
17 KB
specs/counters/counter-page-reset/__image_snapshots_linux__/counter-page-reset-scope-spec-js-counter-page-reset-scope-should-create-a-pdf-3-snap.png
0 → 100644
View file @
04d2a0c4
17.1 KB
specs/counters/counter-page-reset/counter-page-reset-scope.html
0 → 100644
View file @
04d2a0c4
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
/>
<title>
counter-page-reset-scope
</title>
<style>
@page
{
size
:
A4
;
}
@page
{
@bottom-center
{
content
:
"Page "
counter
(
page
);
}
}
@page
frontmatter
{
@bottom-center
{
content
:
none
;
}
}
header
{
page
:
frontmatter
;
}
.cover
{
page
:
cover
;
}
main
{
counter-reset
:
page
1
;
break-before
:
right
;
}
section
{
break-after
:
page
;
}
</style>
<script
src=
"../../../dist/paged.polyfill.js"
></script>
</head>
<body>
<header>
<div
class=
"cover"
>
<h1>
Test Document
</h1>
</div>
<div
class=
"tableofcontents"
>
<h2>
Table Of Contents
</h2>
</div>
</header>
<main>
<section>
<h2>
Section 1
</h2>
</section>
<section>
<h2>
Section 2
</h2>
</section>
<section>
<h2>
Section 3
</h2>
</section>
</main>
</body>
</html>
specs/counters/counter-page-reset/counter-page-reset-scope.spec.js
0 → 100644
View file @
04d2a0c4
const
TIMEOUT
=
10000
;
// Some book might take longer than this to renderer
describe
(
"
counter-page-reset-scope
"
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
loadPage
(
"
counters/counter-page-reset/counter-page-reset-scope.html
"
);
return
page
.
rendered
;
},
TIMEOUT
);
afterAll
(
async
()
=>
{
if
(
!
DEBUG
)
{
await
page
.
close
();
}
});
if
(
!
DEBUG
)
{
it
(
"
should create a pdf
"
,
async
()
=>
{
let
pdf
=
await
page
.
pdf
(
PDF_SETTINGS
);
expect
(
pdf
).
toMatchPDFSnapshot
(
3
);
expect
(
pdf
).
toMatchPDFSnapshot
(
4
);
expect
(
pdf
).
toMatchPDFSnapshot
(
5
);
});
}
}
);
src/modules/paged-media/counters.js
View file @
04d2a0c4
...
...
@@ -7,6 +7,7 @@ class Counters extends Handler {
this
.
styleSheet
=
polisher
.
styleSheet
;
this
.
counters
=
{};
this
.
resetCountersMap
=
new
Map
();
}
onDeclaration
(
declaration
,
dItem
,
dList
,
rule
)
{
...
...
@@ -219,8 +220,16 @@ class Counters extends Handler {
afterPageLayout
(
pageElement
,
page
)
{
let
pgreset
=
pageElement
.
querySelectorAll
(
"
[data-counter-page-reset]
"
);
pgreset
.
forEach
((
reset
)
=>
{
let
value
=
reset
.
dataset
.
counterPageReset
;
this
.
styleSheet
.
insertRule
(
`[data-page-number="
${
pageElement
.
dataset
.
pageNumber
}
"] { counter-increment: none; counter-reset: page
${
value
}
; }`
,
this
.
styleSheet
.
cssRules
.
length
);
const
ref
=
reset
.
dataset
&&
reset
.
dataset
.
ref
;
if
(
ref
&&
this
.
resetCountersMap
.
has
(
ref
))
{
// ignoring, the counter-reset directive has already been taken into account.
}
else
{
if
(
ref
)
{
this
.
resetCountersMap
.
set
(
ref
,
""
);
}
let
value
=
reset
.
dataset
.
counterPageReset
;
this
.
styleSheet
.
insertRule
(
`[data-page-number="
${
pageElement
.
dataset
.
pageNumber
}
"] { counter-increment: none; counter-reset: page
${
value
}
; }`
,
this
.
styleSheet
.
cssRules
.
length
);
}
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment