...
 
Commits (2)
......@@ -83,9 +83,11 @@ const TEMPLATE = `
* @class
*/
class Chunker {
constructor(content, renderTo) {
constructor(content, renderTo, options) {
// this.preview = preview;
this.settings = options || {};
this.hooks = {};
this.hooks.beforeParsed = new Hook(this);
this.hooks.afterParsed = new Hook(this);
......@@ -197,7 +199,7 @@ class Chunker {
// }
async render(parsed, startAt) {
let renderer = this.layout(parsed, startAt);
let renderer = this.layout(parsed, startAt, this.settings);
let done = false;
let result;
......
......@@ -35,7 +35,7 @@ const MAX_CHARS_PER_BREAK = 1500;
*/
class Layout {
constructor(element, hooks, maxChars) {
constructor(element, hooks, options) {
this.element = element;
this.bounds = this.element.getBoundingClientRect();
......@@ -52,7 +52,9 @@ class Layout {
this.hooks.onBreakToken = new Hook();
}
this.maxChars = maxChars || MAX_CHARS_PER_BREAK;
this.settings = options || {};
this.maxChars = this.settings.maxChars || MAX_CHARS_PER_BREAK;
}
async renderTo(wrapper, source, breakToken, bounds=this.bounds) {
......@@ -589,11 +591,11 @@ class Layout {
// Add a hyphen if previous character is a letter or soft hyphen
if (
(breakLetter && /^\w|\u00AD$/.test(prevLetter) && /^\w|\u00AD$/.test(breakLetter)) ||
(breakLetter && /^\w|\u00AD$/.test(prevLetter) && /^\w|\u00AD$/.test(breakLetter)) ||
(!breakLetter && /^\w|\u00AD$/.test(prevLetter))
) {
startContainer.parentNode.classList.add("pagedjs_hyphen");
startContainer.textContent += "\u2011";
startContainer.textContent += this.settings.hyphenGlyph || "\u2011";
}
}
}
......
......@@ -22,10 +22,11 @@ let config = window.PagedConfig || {
after: undefined,
content: undefined,
stylesheets: undefined,
renderTo: undefined
renderTo: undefined,
settings: undefined
};
let previewer = new Previewer();
let previewer = new Previewer(config.settings);
ready.then(async function () {
let done;
......
......@@ -7,14 +7,16 @@ import Polisher from "../polisher/polisher";
import { registerHandlers, initializeHandlers } from "../utils/handlers";
class Previewer {
constructor() {
constructor(options) {
// this.preview = this.getParams("preview") !== "false";
this.settings = options || {};
// Process styles
this.polisher = new Polisher(false);
// Chunk contents
this.chunker = new Chunker();
this.chunker = new Chunker(undefined, undefined, this.settings);
// Hooks
this.hooks = {};
......