EDITORCLASSBLOGLOGINOpkleOpkle, the Editor for CreatorsInfiniteExpression,In New Forms.New ContentOpkle makes an editor so anyone can build for the web without code, and share it anywhere.Blending text and screen, we build tools that make the web about imagination, not code.Building Opkle Editor: A Spreadsheet for Table Imagesdev17Building Opkle Editor: One Dataset as Table, Board, Calendardev18Building Opkle Editor: A Publisher for Books on the Webdev19Building Opkle Editor: Publishing the Edit View to the Webdev20Building Opkle Editor: How the EPUB Editor Ties It Togetherdev211213141516...19 Building Opkle Editor: A Publisher for Books on the Web

After building the table editor, I turned back to the last stretch of the road along which finished content reaches readers. Letting people download an EPUB file or register it with a distributor wasn't enough. A book made in the editor had to be publishable straight to the browser without building a separate website, and its structure and behavior had to appear intact on both mobile and desktop.

I had no intention of building a feature that merely converts an EPUB into a few HTML pages and uploads them. That approach keeps the body text but loses the page turning, spreads, dark mode, chapter navigation, margins and layout set in the editor. For fixed-layout documents made in the vector and layout editors, it is even more direct. If the ratios, the time axis and the relationships between pages aren't preserved, the web post becomes a different document from the original.

So I built the Publisher not as a mere output window but as an independent document editor. What mattered was not which data goes where, but whether the document observed while editing and the document observed while reading are the same. I defined this problem not as copying a screen but as preserving meaning between two execution environments, and reorganized the whole Publisher on top of that definition.

Publication state

Mathematically, publication state can be thought of as a product space of a content set \(C\), presentation rules \(S\), a navigation structure \(N\) and an execution environment \(E\). A published document is \(p=(c,s,n,e)\in C\times S\times N\times E\), and the renderer is a function \(R:P\to O\) that maps this state to an observable screen. Here the correctness of publishing is decided less by the fact that a file exists than by whether \(R(p)\) has the same meaning in the editor and in the public environment.

If I demanded identical pixels, I couldn't handle different screen sizes. Conversely, if I defined it loosely as just the same meaning, I could claim it's the same document even when margins, spread behavior or page order differ. So I split equivalence into layers. Content equivalence of text and assets, order equivalence of reading order, structural equivalence of layout constraints and transition equivalence of interactions must all hold before I count something as the same publication.

The key is never to treat any one component of the state as a temporary by-product of another. Navigation state isn't a side effect of layout, and presentation rules aren't decoration mixed into the content string. Each is an independent coordinate axis, yet they act together in the final observed value. Once this product-space model is in place, the invariant that changing one axis must preserve the others comes out naturally.

The editing process of the Publisher is also, in the end, a transition that sends a state \(p_t\) to the next state \(p_{t+1}\). Collecting only the allowed transitions yields a state machine, and at boundaries like saving or publishing, the invariants must hold before and after the transition. I organized the actual implementation without damaging this mathematical model, and thanks to that the Publisher's semantics stayed one even as various documents came in.

Orthogonal State Space

If document state is treated as one lump, it's hard to compute the scope of a change's impact. Some edits affect only the body, some only the presentation, and some only the order. Viewing this as a vector \(x=(x_1,x_2,\ldots,x_n)\), a good decomposition is like choosing a basis in which each coordinate has as little correlation as possible. If a change in one coordinate forces every coordinate to be rewritten, the basis was chosen wrongly.

I separated state by lifecycle and meaning, so that components with different rates of change aren't forced into the same update cycle. A long-lived identity and a frequently changing presentation value, or a value derived from the source and a value the user decided directly, aren't on the same time scale. Placing them on nearly orthogonal axes makes the change vector \(\Delta x\) sparse, so only the parts actually affected need to be computed.

Of course, real state isn't perfectly orthogonal. When the reading order changes, the interpretation of the current position changes too, and when screen conditions change, the same presentation value gives a different result. So rather than independence, it is more accurate to express conditional dependencies as a graph. With state components as vertices and only direct influences as edges, I can obtain the closure a change produces and cut unnecessary full recalculation.

Saveability can be explained within this structure too. If I map the state to a normal form \(\nu(x)\) and let representations with the same meaning converge to one canonical value, I get idempotence: \(\nu(\nu(x))=\nu(x)\). Values that differ only in notation, such as color notations, out-of-range numbers or legacy settings, stop wobbling no matter how many times they are loaded and saved. The document's long-term stability came from the properties of this normal form rather than from some huge save function.

Flow and Fixed Semantics

The documents the Publisher handles fall broadly into two different semantic domains: flowing documents and fixed-layout documents. In a flowing document, position is a function recomputed according to screen conditions, whereas in a fixed-layout document, position is a value belonging to the original coordinate system. If both are interpreted with the same coordinate semantics, one of them is bound to be damaged.

In type-theoretic terms, the document space isn't a simple set but a sum type \(D=D_{flow}+D_{fixed}\) with different generation rules for each side. The layout operation of a flowing document is a re-typesetting function that depends on width and font metrics, while the layout operation of a fixed-layout document is a transformation that maps original coordinates to screen coordinates. Even when a common interface exists, I must not assume the internal semantics are the same.

What the two formats have in common are abstract operations: moving a page forward or backward, entering a particular logical unit and getting the current observation state. How pages get made, on the other hand, differs. This difference is closer to an algebraic data type than to an object-oriented class split. Common operations are defined on both types, while operations closed within each type must be performed only inside its own semantic domain.

Once this distinction was clear, I could handle responsive documents and graphic documents in one Publisher without either one's rules intruding on the other. I didn't make them share the same computation just because the same button appears, and I didn't assume they were the same document just because they have the same output format. For the user it is a single reading experience, but internally the math was finished to keep two correct semantics.

Constraint geometry

Laying out pages in the preview wasn't a matter of picking a fixed size but of optimizing an objective function under constraints. If the available screen area is \(W\times H\) and the width and height of a page are \(w,h\), the basic objective is to make the page area \(wh\) large. At the same time, inequality constraints such as outer margins, the navigation area, the gap between pages, the aspect ratio and a minimum readable width must all be satisfied.

So the set of feasible layouts can be written as \(\mathcal{F}=\{(w,h):g_i(w,h)\leq0\}\), and the actual layout can be seen as \(\arg\max_{(w,h)\in\mathcal{F}}wh\). When the aspect ratio is fixed, the degrees of freedom drop to one, but a single page and a spread have different constraint equations themselves. This is also why the topology of the optimal solution changes when the screen width crosses certain boundaries.

Switching layout modes isn't a plain conditional but a piecewise optimization. Within each interval the solution moves continuously, but at the points where the set of active constraints changes, it jumps into a different solution space. To keep the page from jumping or intruding on the navigation area at those boundaries, I had to look not just at each interval's objective function but also at continuity at the boundaries.

Mobile and desktop aren't two separate designs forced together, either. I saw them as the same semantic variables having optimal solutions in different feasible regions. So even when the screen changes, the document's content and order stay the same, and only the geometric solution moves to fit the new constraints. I organized the Publisher's responsive preview so that this constraint system converges stably.

Aspect-ratio fitting

A fixed-layout document has to preserve the aspect ratio of its original coordinate system. If the original width and height are \(a,b\) and the available area is \(W,H\), the uniform scale is \(s=\min(W/a,H/b)\) and the resulting size is \((sa,sb)\). This looks like a plain contain calculation, but once margins and auxiliary areas come in, the actual available area has to be defined precisely first.

If the inner margins are \(p_x,p_y\), what has to match the ratio is not the outer box but \((w-p_x,h-p_y)\). That is, \((w-p_x)/(h-p_y)=a/b\) must hold while the whole box fits inside the available area. In a spread, the two pages with the same constraints and the gap between them have to be treated as one composite shape, so I pick the stricter of the candidates from the width constraint and the height constraint.

Centering isn't about using the center of the whole screen, either. After excluding the area taken by auxiliary panels, I need the center of the remaining feasible rectangle. Which direction the auxiliary area sits in changes the reference origin, but the calculation itself can be unified as an affine transformation on the remaining area. Separating translation from uniform scaling lets me verify ratio preservation and position preservation independently.

I applied this geometric model repeatedly to portrait, landscape and square originals, and to single-page and spread conditions. Including rounding errors at the edges, I confirmed that the original is never cropped and the center never drifts, and a fixed-layout document no longer loses its own coordinate system on any screen.

Reading order

A book's reading order isn't the same as sorting file names. Logical precedence, the order shown to the reader and the position the current screen refers to are different coordinate systems. I viewed the order the original has as a total order \((S,<)\), and interpreted the user's rearrangement and private selections as a permutation and a subset selection acting on top of it.

If the element set is \(S\), the public subset the user chose is \(V\subseteq S\), and the rearrangement is a permutation \(\pi\in\mathrm{Sym}(S)\), the actual reading order is the projection of \(\pi(S)\) onto \(V\). Hiding isn't deleting an element but excluding it from the observed set, and rearranging is an order transformation that doesn't change an element's identity. Only by separating the two can I find the same chapter again when it's re-published later or the original is updated.

When the original changes, the correspondence between the two ordered sets has to be recomputed. If I match by array position, the moment one element is inserted at the front, every relation after it goes wrong. If I instead construct a partial isomorphism based on stable semantic identities, the relations among common elements are preserved, and only new and removed elements need handling at the boundary. This is closer to preserving order structure than to a plain merge.

I placed first entry and next/previous movement on the same order space too. When the arrangement of buttons on screen, the current position and the logical coordinates of the actual document are connected by a single order map, the result is the same whichever side you move from. The reading order doesn't break through repeated cover hiding, chapter rearranging and mid-list insertions because this order-theoretic invariant was held to the end.

Navigation projection

The chapter navigation UI isn't a copy of the reading order but a projection of the order space onto the screen. A vertical list and a horizontal list aren't different data structures; they are the same permutation laid out along different axes. If the direction vector is \(u\), the position of each item can be compared by the scalar projection \(x_i\cdot u\), and the algebra of the order doesn't change even if the screen orientation does.

For per-device presentation values, I didn't just scale a single number up or down. If I write the presentation state over a set of environments \(E\) as a function \(s:E\to V\), then mobile and desktop are not abridged versions of the same state but values corresponding to different elements of the domain. It is far more stable to share common values explicitly and leave environment-dependent values at their own coordinates.

When there are very many items, exposing every element at the same visual density actually raises the cost of navigation. If the amount of information needed is \(I\) and the amount a screen can hold is \(B\), the navigation interface needs a compressed representation to reduce \(I/B\). By keeping only the high-value operations, such as the current position, the boundaries and direct jumps, the cognitive load stays almost constant even as the number of elements grows.

Applying this principle, I made sure the meaning of navigation doesn't change when the size of the document or the screen orientation does. The presentation can be compressed or change direction, but the order space that selection and movement act on is the same. Chapter editing in the Publisher became a stable tool for handling permutations and projections, not a UI effect.

Render convergence

Rendering mixes different time axes, such as fonts, images, layout measurement and user input. These events don't occur in one complete chronological order. Some events must come before others, but many are independent of each other. So it is more accurate to view execution not as a single timeline but as a partial order \((E,\prec)\), and to preserve only the happens-before relations that affect the result.

The problem is when an old computation finishes late and overwrites the latest state. If the state version is \(v\) and the version the result computation started from is \(v_r\), the condition for applying a result is at least \(v_r=v\). There's no need to expose every intermediate state on screen either. When several changes overlap within a short time, I keep only the computation the final state requires, so that the observable result matches the latest intent.

Render completion doesn't mean a single asynchronous task has finished, either. Only when applying the layout function \(L\) repeatedly reaches a fixed point near \(L(x)=x\) and the required resources have become observable can the screen be revealed. But I can't wait for external resources forever, so a convergence condition and a bounded-wait condition have to be set together. It means waiting for completeness without giving up the system's liveness.

I made this part independent of any particular execution order. Even if events arrive in a slightly different order, the final state is the same, and even when settings or the screen size change rapidly in succession, only the last intent remains, accurately. The stability of rendering came from keeping the partial order and version invariants, not from speed.

Temporal identity

To be able to say it is the same published document after the source has been edited, identity and the time of the content have to be separated. The document's value can change as \(V(t)\) at time \(t\), but the identity \(I\) that refers to the document persists. If sameness is defined as complete equality of values, every edit makes a new document, and if sameness is defined by name alone, different documents collide.

So I saw a document as a trajectory \((I,V_t)\) that changes over time. An update isn't an operation that changes the identity but one that maps a new valid state to the same identity. Values that must be kept independently of the source, such as presentation settings and reading order, are preserved within this trajectory, and only values that must be re-derived from the source are computed against the new state.

Results made in several editors were interpreted as a provenance graph between source and result. What matters isn't the concrete round-trip path but which result was derived from which point in which source. With this relation as a directed graph, I can explain update authority and the scope of influence, and structurally block circular references and changes of unclear origin.

I repeatedly reviewed flowing and fixed-layout documents, portrait and landscape formats, single pages and spreads, mobile and desktop, hiding and rearranging chapters, and consecutive state changes and source updates. I confirmed that in every condition, content equivalence, order equivalence, layout constraints and interaction transitions are preserved consistently. The Publisher engine, which edits a book's structure into a reading experience on the web, was fully implemented and stabilized.

PreviousListNext
CopyrightAll design outputs and videos on this website are copyrighted by Abstract Cloud and protected under copyright law and related regulations. All content, including web, video, text, cover, and interior designs, is the property of the copyright holder. Unauthorized reproduction, distribution, creation of derivative works, or online sharing without prior consent is strictly prohibited. Violations may result in civil and criminal liability under copyright law. Legitimate purchases and copyright protection preserve creators' rights and fuel better works in return.Copyright: Abstract Cloud | CEO: Bae Changkyu
© Abstract Cloud. All Rights Reserved.
HOMEFAQTerms of ServicePrivacy PolicyRefund PolicySeller Informationhelp@opkle.app
+82 10-2747-3403
Business Name :Abstract Cloud  |  CEO :Bae ChangkyuBusiness Registration Number :249-74-00533E-commerce Registration Number :2025-Uijeongbu Songsan-0634Address :402, 108-dong, 49 Buyong-ro, Uijeongbu-si, Gyeonggi-do, Republic of KoreaAll content, designs, and source code on this website
are copyrighted by Opkle.
Opkle