don't put page markers on disconnected page sides
This commit is contained in:
parent
7cf7e0c90a
commit
ff784a1073
1 changed files with 11 additions and 13 deletions
|
@ -18,17 +18,15 @@ const indexLetter = (i) => String.fromCharCode('A'.charCodeAt(0) + i - 1)
|
||||||
* */
|
* */
|
||||||
export const pagesPlugin = ({
|
export const pagesPlugin = ({
|
||||||
size='a4',
|
size='a4',
|
||||||
orientation='portrait',
|
...settings
|
||||||
margin=10,
|
|
||||||
printStyle = false, /** should the pages be rendered for printing or for screen viewing? */
|
|
||||||
setPatternSize = true
|
|
||||||
}) => {
|
}) => {
|
||||||
const ls = orientation === 'landscape'
|
const ls = settings.orientation === 'landscape'
|
||||||
let sheetHeight = sizes[size][ls ? 0 : 1]
|
let sheetHeight = sizes[size][ls ? 0 : 1]
|
||||||
let sheetWidth = sizes[size][ls ? 1 : 0]
|
let sheetWidth = sizes[size][ls ? 1 : 0]
|
||||||
sheetWidth -= margin * 2
|
sheetWidth -= settings.margin * 2
|
||||||
sheetHeight -= margin * 2
|
sheetHeight -= settings.margin * 2
|
||||||
return basePlugin({sheetWidth, sheetHeight, orientation, printStyle, setPatternSize})
|
|
||||||
|
return basePlugin({...settings, sheetWidth, sheetHeight})
|
||||||
}
|
}
|
||||||
|
|
||||||
const doScanForBlanks = (parts, layout, x, y, w, h) => {
|
const doScanForBlanks = (parts, layout, x, y, w, h) => {
|
||||||
|
@ -166,7 +164,7 @@ const basePlugin = ({
|
||||||
else {
|
else {
|
||||||
paths[pageName].attr('class', 'interfacing stroke-xs')
|
paths[pageName].attr('class', 'interfacing stroke-xs')
|
||||||
// add markers and rulers
|
// add markers and rulers
|
||||||
macro('addPageMarkers', {row, col, pageName})
|
macro('addPageMarkers', {row, col, pageName, withContent})
|
||||||
macro('addRuler', {xAxis: true, pageName})
|
macro('addRuler', {xAxis: true, pageName})
|
||||||
macro('addRuler', {xAxis: false, pageName})
|
macro('addRuler', {xAxis: false, pageName})
|
||||||
}
|
}
|
||||||
|
@ -193,7 +191,7 @@ const basePlugin = ({
|
||||||
// also make a tick for the end of the ruler
|
// also make a tick for the end of the ruler
|
||||||
points[`${rulerName}-ruler-tick`] = points[`${rulerName}-ruler-end`].translate(xAxis ? 0 : 3, xAxis ? 3 : 0)
|
points[`${rulerName}-ruler-tick`] = points[`${rulerName}-ruler-end`].translate(xAxis ? 0 : 3, xAxis ? 3 : 0)
|
||||||
// add a label to it
|
// add a label to it
|
||||||
.attr('data-text', rulerLength + (isMetric ? 'cm' : 'in'))
|
.attr('data-text', rulerLength + (isMetric ? 'cm' : '"'))
|
||||||
// space the text properly from the end of the line
|
// space the text properly from the end of the line
|
||||||
.attr('data-text-class', 'fill-interfacing baseline-center' + (xAxis ? ' center' : ''))
|
.attr('data-text-class', 'fill-interfacing baseline-center' + (xAxis ? ' center' : ''))
|
||||||
.attr(`data-text-d${xAxis ? 'y' : 'x'}`, xAxis ? 5 : 3)
|
.attr(`data-text-d${xAxis ? 'y' : 'x'}`, xAxis ? 5 : 3)
|
||||||
|
@ -237,17 +235,17 @@ const basePlugin = ({
|
||||||
.line(points[`${rulerName}-ruler-tick`])
|
.line(points[`${rulerName}-ruler-tick`])
|
||||||
},
|
},
|
||||||
/** add page markers to the given page */
|
/** add page markers to the given page */
|
||||||
addPageMarkers({row, col, pageName}) {
|
addPageMarkers({row, col, pageName, withContent}) {
|
||||||
const {macro, points} = this.shorthand()
|
const {macro, points} = this.shorthand()
|
||||||
// these markers are placed on the top and left of the page,
|
// these markers are placed on the top and left of the page,
|
||||||
// so skip markers for the top row or leftmost column
|
// so skip markers for the top row or leftmost column
|
||||||
if (row !== 0) macro('addPageMarker', {
|
if (row !== 0 && withContent[row-1][col]) macro('addPageMarker', {
|
||||||
along: [points[`${pageName}-tl`], points[`${pageName}-tr`]],
|
along: [points[`${pageName}-tl`], points[`${pageName}-tr`]],
|
||||||
label: '' + row,
|
label: '' + row,
|
||||||
isRow: true,
|
isRow: true,
|
||||||
pageName
|
pageName
|
||||||
})
|
})
|
||||||
if (col !== 0) macro('addPageMarker', {
|
if (col !== 0 && withContent[row][col-1]) macro('addPageMarker', {
|
||||||
along: [points[`${pageName}-tl`], points[`${pageName}-bl`]],
|
along: [points[`${pageName}-tl`], points[`${pageName}-bl`]],
|
||||||
label: indexLetter(col),
|
label: indexLetter(col),
|
||||||
isRow: false,
|
isRow: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue