### Define and use Vspace Source: https://typeset.jp/references/blocks Defines the Vspace type and demonstrates the use of vspace() and addvspace() helper functions. ```typescript type Vspace = { type: "vspace"; space: number; additive?: boolean; } & AbstractBlock; ``` ```typescript import { addvspace, vspace } from "@minitype/minitype"; vspace(10); addvspace(10); ``` -------------------------------- ### Command ヘルパ関数の使用例 Source: https://typeset.jp/references/inline DocumentStyle.command に定義されたスタイルを適用する例。 ```typescript const style = { command: { red: { effects: [fill(cmyk(0, 100, 100, 0))] }, }, }; p([["ここだけ", command(["赤字"], { name: "red" }), "にて表記される"]]); ``` -------------------------------- ### Define and use Section Source: https://typeset.jp/references/blocks Defines the Section type and demonstrates applying styles to child blocks using the section() helper. ```typescript type Section = { type: "section"; blocks: (Block | BlockExtender)[]; block?: Partial; } & AbstractBlock; ``` ```typescript import { h2, p, section } from "@minitype/minitype"; section([h2("小見出し"), p("本文")], { paragraph: { size: 11 }, }); ``` -------------------------------- ### Define Colors Source: https://typeset.jp/references/style Shows how to define colors using various color spaces and apply alpha transparency. ```typescript import { cmyk, hsl, oklch, rgb, withAlpha } from "@minitype/minitype"; const black = cmyk(0, 0, 0, 100); const red = rgb(255, 0, 0); const translucentRed = withAlpha(red, 0.5); const blueFromHsl = hsl(220, 80, 50); const blueFromOklch = oklch(0.6, 0.15, 250); ``` -------------------------------- ### minitype Entry Point Source: https://typeset.jp/references/api The primary function for initiating document typesetting. ```typescript export const minitype: ( groups: Group[], style?: Partial, options?: MiniTypeOptions, ) => { save(path: string): Promise; toPdf(): Promise; toImages(): Promise; getLayout(): Promise; getPageCount(): Promise; getDiagnostics(): Promise; }; ``` -------------------------------- ### Helper Functions Source: https://typeset.jp/references/inline A collection of helper functions to create formatted Command objects for text styling and layout. ```APIDOC ## Helper Functions ### color(body, color) Creates a Command with a specified text color. ### fontSize(body, size) Creates a Command with a specified font size (mm). ### scale(body, em) Creates a Command with a relative scale. ### blockOffset(body, offset) Creates a Command with a block-direction offset. ### b(body) Creates a bold Command. ### sup(body) Creates a superscript Command. ### sub(body) Creates a subscript Command. ### u(body) Creates an underlined Command. ### overline(body, line) Creates an overlined Command. ### del(body) Creates a strikethrough Command. ### url(href, body?) Creates a Command with a URL link. ``` -------------------------------- ### Command インターフェースと関連型 Source: https://typeset.jp/references/inline テキストにスタイルやリンクなどの付加情報を与えるための Command 型およびその関連型の定義。 ```typescript interface Command { type: "command"; body: InlineOrExtender[]; name?: string; style?: Partial; link?: Link; footnoteLabel?: string; label?: string; id?: string; } ``` ```typescript type Link = UrlLink | DestinationLink; ``` ```typescript type UrlLink = { type: "url"; url: string; }; ``` ```typescript type DestinationLink = { type: "destination"; destination: string; }; ``` -------------------------------- ### Define and use Move Source: https://typeset.jp/references/blocks Defines the Move type and demonstrates applying offsets to blocks using the move() helper. ```typescript type Move = { type: "move"; inlineOffset?: number; blockOffset?: number; blocks: (Block | BlockExtender)[]; } & AbstractBlock; ``` ```typescript import { move, p } from "@minitype/minitype"; move([p("移動する内容")], { inlineOffset: 5, blockOffset: 10 }); ``` -------------------------------- ### 数式ブロックの定義と使用 Source: https://typeset.jp/references/blocks LaTeX 記法による数式ブロックの型定義と math ヘルパ関数の使用例です。 ```typescript type MathBlock = { type: "math"; lines: string[]; style?: Partial; } & AbstractBlock; ``` ```typescript import { math } from "@minitype/minitype"; math(["E = mc^2"]); ``` -------------------------------- ### Define and use Box and Flexbox Source: https://typeset.jp/references/blocks Defines Box and Flexbox types and demonstrates creating a flexbox layout with box helpers. ```typescript type Box = { type: "box"; blocks: (Block | BlockExtender)[]; style?: Partial; semanticType?: BoxSemanticType; } & AbstractBlock; ``` ```typescript type Flexbox = { type: "flexbox"; boxes: (Box | BlockExtender)[]; style?: Partial; } & AbstractBlock; ``` ```typescript import { box, flexbox, p } from "@minitype/minitype"; const firstBox = box([p("左側")]); const secondBox = box([p("右側")]); flexbox([firstBox, secondBox]); ``` -------------------------------- ### minitype(groups, style, options) Source: https://typeset.jp/references/api The main entry point for document typesetting. It accepts document groups, optional styles, and configuration options, returning an interface to interact with the generated document. ```APIDOC ## minitype(groups, style, options) ### Description Initializes the typesetting process for a document. ### Parameters - **groups** (Group[]) - Required - The array of groups representing the document content. - **style** (Partial) - Optional - The document style configuration. - **options** (MiniTypeOptions) - Optional - Additional typesetting options. ### Returns An object containing methods: `save(path)`, `toPdf()`, `toImages()`, `getLayout()`, `getPageCount()`, and `getDiagnostics()`. ``` -------------------------------- ### フロート配置 Source: https://typeset.jp/references/box float関数を使用してブロックをページの上端または下端に配置します。 ```typescript import { caption, float, image } from "@minitype/minitype"; float("top", [image("chart.png"), caption("図のキャプション")]); ``` -------------------------------- ### box() / flexbox() Source: https://typeset.jp/references/blocks Functions to create container elements for layout, columns, or decoration. ```APIDOC ## box(blocks: (Block | BlockExtender)[]) ## flexbox(boxes: (Box | BlockExtender)[]) ### Description Creates container elements. `box` is a general container, while `flexbox` is used for arranging multiple boxes. ``` -------------------------------- ### DocumentStyle 型定義 Source: https://typeset.jp/references/style 文書全体のスタイルを定義するための型構造です。 ```typescript type DocumentStyle = { size: PageSize; padding: Padding | ((pageIndex: number) => Padding); block: BlockStyleRecord; command: CommandStyleRecord; writingMode: WritingMode; gaps: Gap[]; }; ``` -------------------------------- ### 版面中央配置のためのパディング計算 Source: https://typeset.jp/references/style calculatePhysicalPadding を使用して版面を中央に配置するためのパディングを自動計算します。 ```typescript import { Q, em, calculatePhysicalPadding, type DocumentStyle } from "@minitype/minitype"; const style: Partial = { size: "A5", writingMode: "vertical", padding: calculatePhysicalPadding("A5", 35, 17, Q(13), em(1.8), "vertical"), }; ``` -------------------------------- ### ボックスの固定高さ設定 Source: https://typeset.jp/references/box blockSizeを指定してボックスのブロック方向サイズを固定します。 ```typescript box([p("内容...")], { blockSize: 50 }); // 高さを 50 mm に固定 ``` -------------------------------- ### ボックスの装飾設定 Source: https://typeset.jp/references/box padding、background、border、borderRadiusを使用してボックスを装飾します。 ```typescript import { box, cmyk, fill, p, physical, solid } from "@minitype/minitype"; box([p("囲み記事の内容")], { padding: physical(4, 6, 4, 6), background: [fill(cmyk(0, 0, 0, 5))], border: { type: "logical", blockStart: solid(0.5, cmyk(0, 0, 0, 80)), blockEnd: solid(0.5, cmyk(0, 0, 0, 80)), }, borderRadius: 2, }); ``` -------------------------------- ### section() Source: https://typeset.jp/references/blocks Function to create a transparent container for grouping blocks and applying styles. ```APIDOC ## section(blocks: (Block | BlockExtender)[], style?: Partial) ### Description Creates a transparent container that does not affect layout but allows overriding styles for child blocks. ``` -------------------------------- ### ForceBreak 型定義と使用例 Source: https://typeset.jp/references/inline 強制改行を挿入するための型定義とヘルパ関数。 ```typescript type ForceBreak = { type: "force-break"; }; ``` ```typescript p([["1 行目", fbr(), "2 行目"]]); ``` -------------------------------- ### Define and use Float Source: https://typeset.jp/references/blocks Defines the Float type and demonstrates positioning blocks at the top or bottom using the float() helper. ```typescript type Float = { type: "float"; position: "top" | "bottom"; blocks: (Block | BlockExtender)[]; } & AbstractBlock; ``` ```typescript import { float, image } from "@minitype/minitype"; float("top", [image("chart.png")]); ``` -------------------------------- ### ページごとのパディング切り替え Source: https://typeset.jp/references/style ページインデックスに基づいてパディングを動的に変更する関数です。 ```typescript padding: (pageIndex) => { if (pageIndex % 2 === 0) { return physical(20, 30, 20, 25); } return physical(20, 25, 20, 30); }, ``` -------------------------------- ### ブロック間のアキ(gapRole)設定 Source: https://typeset.jp/references/box gapRoleを指定して、ボックス内のブロック間アキの計算を調整します。 ```typescript box([h2("見出し")], { gapRole: "h2" }); ``` -------------------------------- ### move() Source: https://typeset.jp/references/blocks Function to apply offsets to blocks. ```APIDOC ## move(blocks: (Block | BlockExtender)[], options: { inlineOffset?: number, blockOffset?: number }) ### Description Applies inline or block direction offsets to the provided blocks. ``` -------------------------------- ### MathBlock Helper Source: https://typeset.jp/references/blocks Helper function for creating a LaTeX-based math block. ```APIDOC import { math } from "@minitype/minitype"; math(["E = mc^2"]); ``` -------------------------------- ### Decorationインターフェースの定義 Source: https://typeset.jp/references/style ボックスや図形、インライン要素に適用可能な装飾プロパティを定義します。 ```typescript interface Decoration { background?: Effect[]; border?: Borders; borderRadius?: number; openCornerRound?: boolean; openSideBorder?: boolean; underline?: Line; overline?: Line; strikethrough?: Line; } ``` -------------------------------- ### GroupLabelOptions 型定義 Source: https://typeset.jp/references 図表番号の採番やリセットルールを制御するための設定型です。 ```typescript type GroupLabelOptions = { counterResetAt?: HeadingLevel | false; formatCounter?: (context: LabelCounterFormatContext) => number | string; }; ``` -------------------------------- ### テキストブロック後のスペース計算式 Source: https://typeset.jp/references/vertical テキストブロックの最終行と後続ブロックとの間の実際のスペースを算出する式。 ```text (lineHeight - 最終行の文字サイズ) + blocks 間のアキ ``` -------------------------------- ### withTemplate Source: https://typeset.jp/references/blocks Used to define custom template-based helper functions. ```APIDOC ## withTemplate ### Description Defines a custom helper function that accepts lines and processes them through a template. ### Usage ```typescript import { text, withTemplate } from "@minitype/minitype"; const paragraph = withTemplate((lines) => { return text("paragraph", lines); }); ``` ``` -------------------------------- ### 文字組みアキ量の適用例 Source: https://typeset.jp/references/style ドキュメントスタイルに定義済みの文字組みアキ量を適用する例です。 ```typescript import { TEXT_SPACE_HALF, type DocumentStyle } from "@minitype/minitype"; const style: Partial = { block: { paragraph: { space: TEXT_SPACE_HALF, }, }, }; ``` -------------------------------- ### processTemplateを使用したカスタムヘルパの作成 Source: https://typeset.jp/references/blocks タグ付きテンプレートリテラルを処理するためのカスタム関数を定義します。 ```typescript import { processTemplate } from "@minitype/minitype"; const customText = (strings: TemplateStringsArray, ...values: string[]) => { return processTemplate(strings, ...values); }; ``` -------------------------------- ### Hbox ヘルパ関数の使用例 Source: https://typeset.jp/references/inline 目次のリーダや固定幅ボックスを作成する例。 ```typescript // 目次のリーダ hbox(fr(1), "……") // 残り幅をリーダで埋める // 固定幅ボックス hbox(30, ["左寄せの内容"]) hbox(30, ["右寄せの内容"], { align: "right" }) ``` -------------------------------- ### Hbox 型定義と関連型 Source: https://typeset.jp/references/inline 水平ボックスを作成するための型定義。 ```typescript type Hbox = { type: "hbox"; blockSize: HboxWidth; align?: "left" | "center" | "right" | "justify"; } & ( | { body: InlineOrExtender[]; } | { fill: string; } ); ``` ```typescript type HboxWidth = number | Em | Fr | "auto" | HboxPlus | HboxMax; ``` ```typescript interface HboxPlus { type: "plus"; values: HboxPlusValue[]; } ``` ```typescript interface HboxMax { type: "max"; values: HboxMaxValue[]; } ``` ```typescript type HboxPlusValue = number | Em | "auto"; ``` ```typescript type HboxMaxValue = HboxPlusValue | HboxPlus; ``` -------------------------------- ### テキストの回り込み設定 Source: https://typeset.jp/references/box inlineSizeとwrapを指定して、ボックスの周囲にテキストを回り込ませます。 ```typescript import { box, image, p } from "@minitype/minitype"; box([image("diagram.svg")], { inlineSize: ratio(0.4), wrap: "end", wrapGap: 4, }); ``` -------------------------------- ### 文字組みアキ量の型定義 Source: https://typeset.jp/references/style 文字クラス間のアキ量を定義するための型です。 ```typescript type TextSpace = Partial>>>; ``` -------------------------------- ### NoBreak 型定義と使用例 Source: https://typeset.jp/references/inline 行分割を禁止するための型定義とヘルパ関数。 ```typescript type NoBreak = { type: "no-break"; }; ``` ```typescript p([["分割を", noBreak(), "禁止するテキスト"]]); ``` -------------------------------- ### 基本的な文書スタイルの設定 Source: https://typeset.jp/references/style A5判の縦組文書における基本的なスタイル設定例です。 ```typescript import { Q, em, logical, type DocumentStyle } from "@minitype/minitype"; const style: Partial = { size: "A5", writingMode: "vertical", padding: logical(18, 20), block: { paragraph: { size: Q(13), lineHeight: em(1.8), }, h1: { size: Q(24), lineHeight: em(1.5), }, }, gaps: [ ["h1", "paragraph", 8], ["paragraph", "paragraph", 0], ], }; ``` -------------------------------- ### インラインスタイルの定義 Source: https://typeset.jp/references/style 文字スタイルとボックス装飾を組み合わせたインライン要素のスタイル定義です。 ```typescript type InlineStyle = Partial & BoxStyle; ``` ```typescript type CommandStyleRecord = Record; ``` -------------------------------- ### 数式スタイルの定義 Source: https://typeset.jp/references/style 数式ブロックの文字サイズを指定します。 ```typescript type MathStyle = { size: number; }; ``` -------------------------------- ### Padding Utilities Source: https://typeset.jp/references/style Utilities for defining page padding using physical or logical directions. ```APIDOC ## Padding Utilities ### Description Functions to define padding. `physical()` uses top, right, bottom, left coordinates. `logical()` uses block and inline directions to maintain consistency across writing modes. ### Functions - **physical(top, right, bottom, left)** - Sets padding based on physical page edges. - **logical(blockStart, inlineEnd, blockEnd, inlineStart)** - Sets padding based on writing direction. - **calculatePhysicalPadding(size, charsPerLine, lines, fontSize, lineHeight, writingMode)** - Calculates padding to center the content area. ``` -------------------------------- ### Define Style Units Source: https://typeset.jp/references/style Demonstrates usage of unit conversion functions to define dimensions and ratios. ```typescript import { Q, em, fr, pt, ratio } from "@minitype/minitype"; const fontSize = Q(12); // 3 mmです. const lineHeight = em(1.75); // 文字サイズの 1.75 倍です. const imageWidth = ratio(0.8); const columnWidth = fr(2); const borderWidth = pt(0.5); ``` -------------------------------- ### 表ブロックの定義と使用 Source: https://typeset.jp/references/blocks 表要素の型定義と table/cell ヘルパ関数の使用例です。 ```typescript type Table = { type: "table"; rows: TableCell[][]; style?: Partial; } & AbstractBlock; ``` ```typescript type TableCell = { type: "tableCell"; block: Block; colspan?: number; }; ``` ```typescript import { cell, p, table } from "@minitype/minitype"; table([ [cell(p("見出し"), { colspan: 2 })], [cell(p("左")), cell(p("右"))], ]); ``` -------------------------------- ### 物理方向と論理方向の指定 Source: https://typeset.jp/references/style physical() と logical() を使用した方向指定の比較です。 ```typescript import { logical, physical } from "@minitype/minitype"; physical(10, 15); // 上下 10 mm,左右 15 mmです. logical(10, 15); // ブロック方向 10 mm,インライン方向 15 mmです. ``` -------------------------------- ### 合成フォントの定義例 Source: https://typeset.jp/references/style 特定の文字や文字種に対してフォントやサイズ比率を適用する設定例です。 ```typescript import { em, type CompositeFont } from "@minitype/minitype"; const compositeFont: CompositeFont = { default: { font: "SourceHanSerifJP-Regular" }, latin: { font: "GaramondPremrPro", scale: em(0.88), blockOffset: em(-0.05), }, punctuation: { font: "SourceHanSerifJP-Regular" }, chars: { "!?": { font: "SourceHanSansJP-Bold" }, }, }; ``` -------------------------------- ### 脚注ブロックの定義と使用 Source: https://typeset.jp/references/blocks 脚注要素の型定義と footnote ヘルパ関数の使用例です。 ```typescript type Footnote = { type: "footnote"; lines: InlineOrExtender[][]; style?: Partial; label: string; id?: string; }; ``` ```typescript import { footnote } from "@minitype/minitype"; footnote("note-1", "脚注の内容"); ``` -------------------------------- ### DocumentStyleの合成 Source: https://typeset.jp/references/style mergeDocumentStyleを使用して既存のスタイルを基に一部のプロパティを上書きします。 ```typescript import { mergeDocumentStyle } from "@minitype/minitype"; const printStyle = mergeDocumentStyle(baseStyle, { block: { paragraph: { size: Q(11) }, h1: { effects: [fill(cmyk(0, 0, 0, 100))] }, }, }); ``` -------------------------------- ### processTemplate Source: https://typeset.jp/references/blocks Used to create custom helper functions that support tagged template literals. ```APIDOC ## processTemplate ### Description Creates a custom helper function that processes tagged template literals. ### Usage ```typescript import { processTemplate } from "@minitype/minitype"; const customText = (strings: TemplateStringsArray, ...values: string[]) => { return processTemplate(strings, ...values); }; ``` ``` -------------------------------- ### List Block Helpers Source: https://typeset.jp/references/blocks Helper functions for creating ordered and unordered lists at different hierarchy levels. ```APIDOC import { li1, li2, li3, ol1, ol2, ol3 } from "@minitype/minitype"; li1("順序なしリストの第 1 階層"); li2("順序なしリストの第 2 階層"); li3("順序なしリストの第 3 階層"); ol1("順序付きリストの第 1 階層"); ol2("順序付きリストの第 2 階層"); ol3("順序付きリストの第 3 階層"); ``` -------------------------------- ### InlineMath 型定義と使用例 Source: https://typeset.jp/references/inline LaTeX 数式を埋め込むための型定義とヘルパ関数。 ```typescript type InlineMath = { type: "inline-math"; latex: string; size?: number | Em; }; ``` ```typescript p([["アインシュタインの式 ", inlineMath("E=mc^2"), " は有名です."]]); ``` -------------------------------- ### withTemplateを使用したカスタムヘルパの作成 Source: https://typeset.jp/references/blocks withTemplateを使用して、特定のテキスト構造を生成するヘルパ関数を定義します。 ```typescript import { text, withTemplate } from "@minitype/minitype"; const paragraph = withTemplate((lines) => { return text("paragraph", lines); }); ``` -------------------------------- ### Kerning 型定義と使用例 Source: https://typeset.jp/references/inline 文字間隔を調整するための型定義とヘルパ関数。 ```typescript type Kerning = { type: "kerning"; em: number; }; ``` ```typescript p([["「", kern(-0.25), "括弧内のテキスト", kern(-0.25), "」"]]); ``` -------------------------------- ### テキストブロックの定義とヘルパ関数 Source: https://typeset.jp/references/blocks テキスト要素の型定義と、段落や見出しを作成するためのヘルパ関数の使用例です。 ```typescript type Text = { type: "text"; textType: TextType; lines: InlineOrExtender[][]; style?: Partial; unnumbered?: boolean; } & AbstractBlock; ``` ```typescript type TextType = (typeof TEXT_TYPES)[number]; ``` ```typescript const TEXT_TYPES = ["paragraph", "h1", "h2", "h3", "h4", "caption"] as const; ``` ```typescript import { caption, h1, h2, h3, h4, p, text } from "@minitype/minitype"; text("paragraph", "任意の種類のテキスト"); p("段落"); h1("レベル 1 の見出し"); h2("レベル 2 の見出し"); h3("レベル 3 の見出し"); h4("レベル 4 の見出し"); caption("図のキャプション"); ``` -------------------------------- ### コードブロックの定義と使用 Source: https://typeset.jp/references/blocks ソースコードを表示するための Code 型定義とヘルパ関数の使用例です。 ```typescript type Code = { type: "code"; lines: string[]; lang?: string; style?: Partial; } & AbstractBlock; ``` ```typescript import { code } from "@minitype/minitype"; code("const message = 'Hello';", "typescript"); ``` -------------------------------- ### リストブロックの定義とヘルパ関数 Source: https://typeset.jp/references/blocks リスト要素の型定義と、階層に応じたリスト作成用ヘルパ関数の使用例です。 ```typescript type List = { type: "list"; listType: ListType; level: ListLevel; lines: InlineOrExtender[][]; style?: Partial; } & AbstractBlock; ``` ```typescript type ListType = (typeof LIST_TYPES)[number]; ``` ```typescript type ListLevel = (typeof LIST_LEVELS)[number]; ``` ```typescript const LIST_TYPES = ["unordered", "ordered"] as const; ``` ```typescript const LIST_LEVELS = [1, 2, 3] as const; ``` ```typescript import { li1, li2, li3, ol1, ol2, ol3 } from "@minitype/minitype"; li1("順序なしリストの第 1 階層"); li2("順序なしリストの第 2 階層"); li3("順序なしリストの第 3 階層"); ol1("順序付きリストの第 1 階層"); ol2("順序付きリストの第 2 階層"); ol3("順序付きリストの第 3 階層"); ``` -------------------------------- ### vspace() / addvspace() Source: https://typeset.jp/references/blocks Functions to insert vertical space. vspace() inserts an absolute space, while addvspace() adds to existing gaps. ```APIDOC ## vspace(space: number) ## addvspace(space: number) ### Description Inserts a vertical space into the document layout. `vspace` ignores adjacent gaps, while `addvspace` adds the specified value to existing gaps. ### Parameters - **space** (number) - Required - The size of the vertical space to insert. ``` -------------------------------- ### カスタムページサイズと物理パディングの設定 Source: https://typeset.jp/references/style 独自のページサイズを指定し、物理方向でパディングを設定する例です。 ```typescript import { physical, type DocumentStyle } from "@minitype/minitype"; const style: Partial = { size: { width: 148, height: 210 }, padding: physical(15, 18, 20, 18), }; ``` -------------------------------- ### 表スタイルの定義 Source: https://typeset.jp/references/style 列幅、罫線、パディング、背景色、テキストスタイルを定義します。各プロパティには固定値または関数を指定可能です。 ```typescript type TableStyle = { align: Align; columnWidths?: | (number | Ratio | Fr)[] | ((columnIndex: number) => number | Ratio | Fr); verticalBorders?: | Border | ((columnIndex: number, columnCount: number) => Border); horizontalBorders?: Border | ((rowIndex: number, rowCount: number) => Border); cellPadding?: | DynamicPadding | ((rowIndex: number, columnIndex: number) => DynamicPadding); background?: | Color | ((rowIndex: number, columnIndex: number) => Color | undefined); textStyle?: | Partial | ((rowIndex: number, colIndex: number) => Partial); }; ``` -------------------------------- ### 画像ブロックの定義と使用 Source: https://typeset.jp/references/blocks 画像要素の型定義と image ヘルパ関数の使用例です。 ```typescript type Image = { type: "image"; src: string; style?: Partial; } & AbstractBlock; ``` ```typescript import { image, ratio } from "@minitype/minitype"; image("chart.png", { width: ratio(0.8), align: "center" }); ``` -------------------------------- ### 論理方向への罫線適用 Source: https://typeset.jp/references/style logical関数を使用して、物理方向または論理方向の各辺に罫線を指定します。 ```typescript border: logical( solid(1, cmyk(0, 0, 0, 100)), solid(0.5, cmyk(0, 0, 0, 40)), ), ``` -------------------------------- ### ブロック要素の型定義 Source: https://typeset.jp/references/blocks minitype で利用可能なすべてのブロック要素の型定義です。 ```typescript type Block = | Text | Code | List | Footnote | Image | Shape | Table | MathBlock | NewPage | ClearPage | NewColumn | Vspace | Box | Flexbox | ResetLabel | Section | Float | Move; ``` ```typescript interface AbstractBlock { label?: string; id?: string; } ``` -------------------------------- ### MiniTypeOptions Interface Source: https://typeset.jp/references/api Configuration options for the minitype typesetting process. ```typescript interface MiniTypeOptions { outline?: boolean; metadata?: PdfMetadata; ppi?: number; blockTransformers?: BlockTransformer[]; disableDefaultTransformers?: boolean; fontDir?: string; fonts?: BrowserFontData[]; browserFiles?: { path: string; data: ArrayBuffer }[]; } ``` -------------------------------- ### box(blocks, style) Source: https://typeset.jp/references/box Creates a container element for child block elements, used for columns, floats, text wrapping, and decoration. ```APIDOC ## box(blocks, style) ### Description Creates a container element for child block elements. Used for layout tasks like columns, floats, text wrapping, and applying background or border decorations. ### Parameters - **blocks** (Array) - Required - An array of block elements to be contained. - **style** (Object) - Optional - Configuration object for layout and decoration (e.g., columns, splitable, padding, background, border, inlineSize, blockSize). ### Example ```typescript import { box, p } from "@minitype/minitype"; box([p("Paragraph 1..."), p("Paragraph 2...")], { columns: 2, columnGap: 5, columnFill: "balance", }); ``` ``` -------------------------------- ### 罫線スタイルの定義 Source: https://typeset.jp/references/style 罫線の幅や破線設定を定義するBorderStyle型です。 ```typescript type BorderStyle = { width: number; dashLength?: number; gapLength?: number; enabled?: boolean; }; ``` -------------------------------- ### Decoration Interface Source: https://typeset.jp/references/style The Decoration interface defines common styling properties for boxes, shapes, and inline elements, including backgrounds, borders, and text decorations. ```APIDOC ## Decoration Interface ### Description Defines styling properties for elements. ### Properties - **background** (Effect[]) - Optional - Array of effects (fill, stroke, image) applied to the background. - **border** (Borders) - Optional - Border configuration. - **borderRadius** (number) - Optional - Corner radius in mm. - **openCornerRound** (boolean) - Optional - Applies rounding to corners when elements are split across pages/columns. - **openSideBorder** (boolean) - Optional - Draws borders on edges when elements are split. - **underline** (Line) - Optional - Underline style. - **overline** (Line) - Optional - Overline style. - **strikethrough** (Line) - Optional - Strikethrough style. ``` -------------------------------- ### float() Source: https://typeset.jp/references/blocks Function to position blocks at the top or bottom of a column. ```APIDOC ## float(position: 'top' | 'bottom', blocks: (Block | BlockExtender)[]) ### Description Places child blocks at the top or bottom of the current column. ``` -------------------------------- ### タグ付きテンプレートリテラルによるInlineOrExtenderの作成 Source: https://typeset.jp/references/inline ilタグを使用してInlineOrExtender[]を作成し、ilsタグを使用して行区切りを含むInlineOrExtender[][]を作成します。 ```typescript import { il, ils, kern } from "@minitype/minitype"; const inline: InlineOrExtender[] = il`「${kern(-0.25)}テキスト${kern(-0.25)}」`; const lines: InlineOrExtender[][] = ils`1行目\n${kern(-0.25)}2行目`; ``` -------------------------------- ### Ruby 型定義と使用例 Source: https://typeset.jp/references/inline ルビを付与するための型定義とヘルパ関数。 ```typescript type Ruby = { type: "ruby"; base: string; ruby: string; }; ``` ```typescript ruby("薔薇", "ばら") // 単一のルビ ruby("薔", "ば", "薇", "ら") // 文字ごとにルビを付ける(Ruby[] を返す) ``` -------------------------------- ### 背景エフェクトの適用 Source: https://typeset.jp/references/style 塗り、ストローク、画像塗りを含むEffect配列を定義します。配列の先頭が最上層として描画されます。 ```typescript import { cmyk, fill, imageFill, linearGradient, rgb, stroke } from "@minitype/minitype"; const effects = [ stroke(cmyk(0, 0, 0, 100), 0.3), fill( linearGradient(0, 0, 1, 0, [ { position: 0, color: rgb(255, 255, 255) }, { position: 1, color: rgb(120, 160, 220) }, ]), ), imageFill("texture.png", "cover", ["middle", "center"]), ]; ``` -------------------------------- ### GroupStyleの定義 Source: https://typeset.jp/references/style ページサイズを除く文書スタイルの部分集合としてGroupStyleを定義します。 ```typescript type GroupStyle = Partial>; ``` -------------------------------- ### ラベルと相互参照の利用例 Source: https://typeset.jp/references 要素へのラベル付与と、autoref、ref、pageref を使用した相互参照の記述例です。 ```javascript { ...image("chart.png"), label: "fig:result" }; { ...math(["E = mc^2"]), label: "eq:energy" }; // 図 1 に示すように…… p([[autoref("fig:result"), "に示すように……"]]); // 式 1 より…… p([["式", ref("eq:energy"), "より,"]]); // 詳細は 1 ページ参照 p([["詳細は", pageref("fig:result"), "ページ参照"]]); ``` -------------------------------- ### Box型定義 Source: https://typeset.jp/references/box Boxコンテナの型定義です。 ```typescript type Box = { type: "box"; blocks: (Block | BlockExtender)[]; style?: Partial; semanticType?: BoxSemanticType; } & AbstractBlock; ``` -------------------------------- ### InlineOrExtender 型定義 Source: https://typeset.jp/references/inline インライン要素として使用可能な型の定義。 ```typescript type InlineOrExtender = | Command | ForceBreak | Kerning | NoBreak | NoSplit | InlineGraphic | InlineMath | Hbox | Ruby | Cid | InlineExtender | string; ``` -------------------------------- ### Layout Information Types Source: https://typeset.jp/references/api Definitions for block layout structures returned by getLayout(). ```typescript type BlockLabel = | ({ type: BlockLabelType; index: string; } & BaseLabel) | HeadingBlockLabel | ListBlockLabel; ``` ```typescript type BlockLabelType = | "paragraph" | "code" | "image" | "shape" | "caption" | "math" | "table" | "footnote" | "newpage" | "clearpage" | "newcolumn" | "box" | "flexbox"; ``` ```typescript type BaseLabel = { pageIndex: number | null; x: number | null; y: number | null; width: number | null; height: number | null; id: string; label?: string; content: string | null; inlines?: InlineOrExtender[]; }; ``` ```typescript type HeadingBlockLabel = { type: "heading"; index: HeadingIndex; level: HeadingLevel; unnumbered?: boolean; } & BaseLabel; ``` ```typescript type ListBlockLabel = { type: "list"; index: number; order: number[]; } & BaseLabel; ``` -------------------------------- ### ページ制御ブロックの定義と使用 Source: https://typeset.jp/references/blocks 改ページや改段を行うブロックの型定義とヘルパ関数の使用例です。 ```typescript type NewPage = { type: "newpage"; } & AbstractBlock; ``` ```typescript type ClearPage = { type: "clearpage"; } & AbstractBlock; ``` ```typescript type NewColumn = { type: "newcolumn"; } & AbstractBlock; ``` ```typescript import { clearpage, newcolumn, newpage } from "@minitype/minitype"; newpage(); clearpage(); newcolumn(); ``` -------------------------------- ### Block Spacing (Gaps) Source: https://typeset.jp/references/style Configuration for spacing between different block types. ```APIDOC ## Gaps Configuration ### Description Defines the spacing between blocks using the format `[previousBlockType, nextBlockType, gapSize]`. ### Parameters - **previousBlockType** (string) - The type of the preceding block (e.g., "paragraph", "h1", "fallback"). - **nextBlockType** (string) - The type of the following block. - **gapSize** (number) - The spacing in millimeters. ``` -------------------------------- ### Borderインターフェースの定義 Source: https://typeset.jp/references/style 色と複数の線スタイルを組み合わせたBorder型です。 ```typescript interface Border { color: Color; styles: BorderStyle[]; } ``` -------------------------------- ### Cid 型定義と使用例 Source: https://typeset.jp/references/inline フォントの CID を直接指定するための型定義とヘルパ関数。 ```typescript type Cid = { type: "cid"; cid: number; }; ``` ```typescript // Adobe-Japan 1-* に準拠したフォントでは「あ」が表示される p([["CID で指定した文字:", cid(843)]]); ``` -------------------------------- ### Code Block Helper Source: https://typeset.jp/references/blocks Helper function for creating a code block with syntax highlighting support. ```APIDOC import { code } from "@minitype/minitype"; code("const message = 'Hello';", "typescript"); ``` -------------------------------- ### Table Helper Source: https://typeset.jp/references/blocks Helper functions for creating tables with cells and column spanning. ```APIDOC import { cell, p, table } from "@minitype/minitype"; table([ [cell(p("見出し"), { colspan: 2 })], [cell(p("左")), cell(p("右"))], ]); ``` -------------------------------- ### Text Block Helpers Source: https://typeset.jp/references/blocks Helper functions for creating various text-based blocks like paragraphs, headings, and captions. ```APIDOC import { caption, h1, h2, h3, h4, p, text } from "@minitype/minitype"; text("paragraph", "任意の種類のテキスト"); p("段落"); h1("レベル 1 の見出し"); h2("レベル 2 の見出し"); h3("レベル 3 の見出し"); h4("レベル 4 の見出し"); caption("図のキャプション"); ``` -------------------------------- ### 合成フォントの型定義 Source: https://typeset.jp/references/style 合成フォントの各エントリおよび全体の構造を定義する型です。 ```typescript type CompositeFontEntry = { font: string; scale?: Em; blockOffset?: Em; }; ``` ```typescript type CompositeFont = { kana?: CompositeFontEntry; sutegana?: CompositeFontEntry; prolongedSound?: CompositeFontEntry; latin?: CompositeFontEntry; punctuation?: CompositeFontEntry; default: CompositeFontEntry; chars?: Record; }; ``` -------------------------------- ### Flexbox型定義 Source: https://typeset.jp/references/box Flexboxコンテナの型定義です。 ```typescript type Flexbox = { type: "flexbox"; boxes: (Box | BlockExtender)[]; style?: Partial; } & AbstractBlock; ``` ```typescript type FlexboxStyle = { gap: number; alignItems: "stretch" | "start"; }; ``` -------------------------------- ### float(position, blocks) Source: https://typeset.jp/references/box Floats blocks to the top or bottom of the page. ```APIDOC ## float(position, blocks) ### Description Floats the provided blocks to the top or bottom of the page. If the blocks cannot fit on the current page, they are carried over to the next. ### Parameters - **position** (string) - Required - Either "top" or "bottom". - **blocks** (Array) - Required - The blocks to be floated. ### Example ```typescript import { caption, float, image } from "@minitype/minitype"; float("top", [image("chart.png"), caption("Figure caption")]); ``` ``` -------------------------------- ### Group 型定義 Source: https://typeset.jp/references 文書の基本単位である Group の構造定義です。 ```typescript type Group = { body: Body; pageIndex?: number; style?: GroupStyle; labelOptions?: GroupLabelOptions; }; ``` -------------------------------- ### 独自のアキ量設定 Source: https://typeset.jp/references/style 文字クラスの組み合わせに基づいて独自のアキ量を指定する設定です。 ```typescript space: { kanji: { latin: 0.25, fallback: 0, }, fallback: { openingBracket: 0.5, fallback: 0, }, }, ```