Bihar Police Notebook ships two print-ready A4 templates that share the same editor shell. Letter is a plain multi-page text document; Diary is a structured FIR case diary with a fixed header block and two-column pages. Switching between them starts a fresh document of the chosen type after flushing any pending autosave.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/arverma/Bihar-Police-Notebook/llms.txt
Use this file to discover all available pages before exploring further.
| Template | Module | Content shape |
|---|---|---|
| Letter | editor/js/paged-sheet.js | Plain text that spills across page cards automatically |
| Diary | editor/js/diary-sheet.js | FIR header + pages each with a 20 % left column and 80 % right column |
A4 Geometry Constants
Both templates derive all measurements from a shared set of constants so that screen preview and print output remain pixel-perfect:| Constant | Value | Meaning |
|---|---|---|
PAGE_W_MM | 210 | A4 page width in millimetres |
PAGE_H_MM | 297 | A4 page height in millimetres |
MARGIN_MM | 12.7 | Page margin — half of Google Docs’ default 1 inch margin |
FONT_PX | 15 | Base body font size in CSS pixels |
LINE_HEIGHT_PX | 24 | Line height in CSS pixels |
LEFT_COL_PCT | 20 | Diary left column width as a percentage of the page content area |
HEADER_BLOCK_H_PX | 140 | FIR header block height in CSS pixels |
TITLES_ROW_H_PX | 72 | Column-titles row height in CSS pixels |
TABLE_BORDER_H_PX | 4 | Combined table border height consumed from the page content area |
All box heights in the Diary template snap to whole multiples of
LINE_HEIGHT_PX (24 px). This guarantees that no line of Devanagari text is ever split across a page boundary.Letter Template
The Letter template (paged-sheet.js) renders a sequence of .letter-page card elements, each containing a <textarea class="letter-page-input">. When a textarea overflows its fixed-height page card, content spills automatically to the next page card.
User types in a page card
Each keystroke fires an
input event that paged-sheet.js listens to via the onChange callback passed from main.js.Overflow detection
paged-sheet.js measures scrollHeight vs the page card’s fixed height. If the text overflows, a new page card is created and excess content is moved there.Autosave debounce
main.js receives the onChange callback and calls scheduleSave(), which debounces the IndexedDB write by 600 ms.Diary Template
The Diary template (diary-sheet.js) manages a richer data model: a top-level header object plus an array of pages, each page holding left-column and right-column content.
Structural Layout
HEADER_BLOCK_H_PX); the titles row is 72 px (TITLES_ROW_H_PX). Both values are multiples of LINE_HEIGHT_PX so the first body line of the diary aligns cleanly to the 24 px grid. A 4 px table border (TABLE_BORDER_H_PX) is also deducted when computing the usable text area height.
Diary-Specific Controls
Add Page
Appends a new blank page object to the model and re-renders the diary pages container.
Delete Page
Removes the selected page from the model (minimum one page is always retained).
Hide / Show Header
Toggles the FIR header visibility per page. Useful when printing continuation pages that do not need the header repeated.
Content Model
The diary content is stored as JSON in IndexedDB:Screen vs Print
The same A4 geometry drives both the on-screen preview and the printed output, but the two rendering paths are independent:- On Screen
- Print / PDF
Pages are rendered into the DOM as styled
<div> elements and then scaled visually to fit the viewport using a CSS transform applied by page-scale.js. The scale is purely cosmetic — it does not affect layout dimensions, so paginating logic always operates on full A4 pixels.See Page Preview for scaling details.Print Export Flow
Collect content
runPdfExport() reads letterSheet.getPages() or diarySheet.getModel() depending on getActiveTemplate().Generate HTML
letterPagesHtml(pages) or diaryPagesHtml(model) returns a string of <div class="page"> elements with inline content at real A4 pixel dimensions.Apply print CSS
letterPrintCss() / diaryPrintCss() returns a <style> block that sets @page { size: A4; margin: 12.7mm; }, loads Noto Sans Devanagari from Google Fonts, and disables any transforms.Open print window
window.open('', '_blank') creates the print target. If pop-ups are blocked an alert prompts the user to allow them.