KET 1.0 text¶
A text box in the form of KET 1.0: a Draft.js document serialised into a string.
Writers of KET 2.0 write the structured Text form; readers accept both. The two are "type": "text" nodes, and the presence of data tells them apart.
Appears in¶
An inline element of root.nodes.
Identified by¶
"type": "text" with a data key.
Attributes¶
type¶
Type: string
Required: yes
Values:
"text"
Object type; always text.
data¶
Type: object
Required: yes
The content and the position of the text.
data.content¶
Type: string
Required: yes
The text and its styles: a Draft.js raw content state, serialised as JSON into this string.
The serialised object has a blocks array, one block per paragraph, and an entityMap object, which is empty. Of a block, these keys carry meaning:
Key |
Meaning |
|---|---|
|
The characters of the paragraph. |
|
The styled runs of the paragraph: objects with |
|
Where the run starts, in UTF-16 code units from the start of |
|
Length of the run, in UTF-16 code units. |
|
|
The other keys of a block — key, type, depth, entityRanges and data — carry no meaning for KET.
data.position¶
Type: Point
Required: yes
Top-left corner of the text box.
data.pos¶
Type: array of Point
Required: no
Items: exactly 4
Corners of the text box: top-left, bottom-left, bottom-right, top-right.
selected¶
Type: boolean
Required: no
Default:
false
Editor state: the text is selected. Carries no meaning; written only as true.
Rules¶
type,data.contentanddata.positionare required.data.contentis a JSON object serialised into a string, with ablocksarray.data.pos, when present, holds the four corners of the box, and its first point equalsdata.position.
Gotchas¶
Style offsets count UTF-16 code units, as JavaScript strings do: a character outside the Basic Multilingual Plane counts as two.