1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { Parser } from './parser.js';
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | declare class NodeOrText {
|
25 | nodeOrText: Text | string;
|
26 | chunks: string[];
|
27 | hasBreakOpportunityAfter: boolean;
|
28 | constructor(nodeOrText: Text | string);
|
29 | get isString(): boolean;
|
30 | get canSplit(): boolean;
|
31 | get text(): string | null;
|
32 | get length(): number;
|
33 | /**
|
34 | * Split the {@link Text} in the same way as the {@link chunks}.
|
35 | * Joining all {@link chunks} must be equal to {@link text}.
|
36 | */
|
37 | split(separator: string | Node): void;
|
38 | }
|
39 | export declare class NodeOrTextForTesting extends NodeOrText {
|
40 | }
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | declare class Paragraph {
|
50 | element: HTMLElement;
|
51 | nodes: NodeOrText[];
|
52 | constructor(element: HTMLElement);
|
53 | isEmpty(): boolean;
|
54 | get text(): string;
|
55 | get lastNode(): NodeOrText | undefined;
|
56 | setHasBreakOpportunityAfter(): void;
|
57 | /**
|
58 | * @return Indices of forced break opportunities in the source.
|
59 | * They can be created by `<wbr>` tag or `​`.
|
60 | */
|
61 | getForcedOpportunities(): number[];
|
62 | /**
|
63 | * @return Filtered {@param boundaries} by excluding
|
64 | * {@link getForcedOpportunities} if it's not empty.
|
65 | * Otherwise {@param boundaries}.
|
66 | */
|
67 | excludeForcedOpportunities(boundaries: number[]): number[];
|
68 | }
|
69 | export declare class ParagraphForTesting extends Paragraph {
|
70 | }
|
71 |
|
72 |
|
73 |
|
74 | export interface HTMLProcessorOptions {
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | className?: string;
|
83 | |
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | separator?: string | Node;
|
91 | }
|
92 |
|
93 |
|
94 |
|
95 | export declare class HTMLProcessor {
|
96 | private parser_;
|
97 |
|
98 | className?: string;
|
99 |
|
100 | separator: string | Node;
|
101 | |
102 |
|
103 |
|
104 | constructor(parser: Parser, options?: HTMLProcessorOptions);
|
105 | /**
|
106 | * Checks if the given element has a text node in its children.
|
107 | *
|
108 | * @param ele An element to be checked.
|
109 | * @return Whether the element has a child text node.
|
110 | */
|
111 | static hasChildTextNode(ele: HTMLElement): boolean;
|
112 | /**
|
113 | * Applies markups for semantic line breaks to the given HTML element.
|
114 | *
|
115 | * It breaks descendant nodes into paragraphs,
|
116 | * and applies the BudouX to each paragraph.
|
117 | * @param element The input element.
|
118 | */
|
119 | applyToElement(element: HTMLElement): void;
|
120 | /**
|
121 | * Find paragraphs from a given HTML element.
|
122 | * @param element The root element to find paragraphs.
|
123 | * @param parent The parent {@link Paragraph} if any.
|
124 | * @return A list of {@link Paragraph}s.
|
125 | */
|
126 | getBlocks(element: HTMLElement, parent?: Paragraph): IterableIterator<Paragraph>;
|
127 | |
128 |
|
129 |
|
130 |
|
131 | applyToParagraph(paragraph: Paragraph): void;
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 | splitNodes(nodes: NodeOrText[], boundaries: number[]): void;
|
138 | |
139 |
|
140 |
|
141 |
|
142 | applyBlockStyle(element: HTMLElement): void;
|
143 | }
|
144 |
|
145 |
|
146 |
|
147 | export declare class HTMLProcessingParser extends Parser {
|
148 | htmlProcessor: HTMLProcessor;
|
149 | constructor(model: {
|
150 | [key: string]: {
|
151 | [key: string]: number;
|
152 | };
|
153 | }, htmlProcessorOptions?: HTMLProcessorOptions);
|
154 | /**
|
155 | * @deprecated Use `applyToElement` instead. `applyElement` will be removed
|
156 | * in v0.7.0 to align the function name with `HTMLProcessor`'s API.
|
157 | *
|
158 | * Applies markups for semantic line breaks to the given HTML element.
|
159 | * @param parentElement The input element.
|
160 | */
|
161 | applyElement(parentElement: HTMLElement): void;
|
162 | /**
|
163 | * Applies markups for semantic line breaks to the given HTML element.
|
164 | * @param parentElement The input element.
|
165 | */
|
166 | applyToElement(parentElement: HTMLElement): void;
|
167 | /**
|
168 | * Translates the given HTML string to another HTML string with markups
|
169 | * for semantic line breaks.
|
170 | * @param html An input html string.
|
171 | * @return The translated HTML string.
|
172 | */
|
173 | translateHTMLString(html: string): string;
|
174 | }
|
175 | export {};
|