narraleaf-react 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,4 +29,4 @@ export type { LayeredDefinition, LayerGroupDefinition, LayerResolver, LayerSlot,
|
|
|
29
29
|
export type { SentenceMetadata } from "../elements/character/sentence";
|
|
30
30
|
export type { TextEventAppearance, TextEventConfig, TextEventExpression, } from "../elements/character/textEvent";
|
|
31
31
|
export type { CharacterPortraitConfig, DialogAvatar, DialogAvatarResolver, DialogAvatarResolverContext, DialogAvatarResolution, DialogAvatarSource, } from "../elements/character/avatar";
|
|
32
|
-
export type { WordConfig, WordRenderProps, WordRenderer, } from "../elements/character/word";
|
|
32
|
+
export type { WordConfig, WordEmphasis, WordRenderProps, WordRenderer, } from "../elements/character/word";
|
|
@@ -44,12 +44,50 @@ export type WordRenderProps<T = unknown> = {
|
|
|
44
44
|
* cannot carry a function. An id that resolves to nothing renders as plain text.
|
|
45
45
|
*/
|
|
46
46
|
export type WordRenderer<T = any> = string | React.ComponentType<WordRenderProps<T>>;
|
|
47
|
+
/**
|
|
48
|
+
* Emphasis marks: a small glyph drawn beside every character of a word, the typographic way East
|
|
49
|
+
* Asian text stresses a phrase where a Latin one would go italic (傍点 / 圏点 in Japanese, 着重号 in
|
|
50
|
+
* Chinese). The marks follow the characters as they are typed out, so a word that is half revealed
|
|
51
|
+
* carries half its marks.
|
|
52
|
+
*/
|
|
53
|
+
export type WordEmphasis = {
|
|
54
|
+
/**
|
|
55
|
+
* The glyph drawn beside each character.
|
|
56
|
+
* @default "dot"
|
|
57
|
+
*/
|
|
58
|
+
mark?: "dot" | "circle" | "sesame" | "triangle";
|
|
59
|
+
/**
|
|
60
|
+
* Whether that glyph is solid or hollow.
|
|
61
|
+
* @default "filled"
|
|
62
|
+
*/
|
|
63
|
+
fill?: "filled" | "open";
|
|
64
|
+
/**
|
|
65
|
+
* Which side of the text the marks sit on. In horizontal writing `over` is above the line and
|
|
66
|
+
* `under` is below it; in vertical writing both sit to the right of the column, where the
|
|
67
|
+
* convention places them.
|
|
68
|
+
* @default "over"
|
|
69
|
+
*/
|
|
70
|
+
position?: "over" | "under";
|
|
71
|
+
};
|
|
47
72
|
export type WordConfig = {
|
|
48
73
|
className: string;
|
|
49
74
|
ruby: string;
|
|
50
75
|
color: Color;
|
|
51
76
|
pause: boolean;
|
|
52
77
|
cps?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Emphasis marks drawn beside this word's characters. See {@link Word.emphasis}.
|
|
80
|
+
*/
|
|
81
|
+
emphasis?: WordEmphasis;
|
|
82
|
+
/**
|
|
83
|
+
* This word's size as a share of the line's — `1.25` for a quarter larger, `0.8` for a fifth
|
|
84
|
+
* smaller. Relative rather than absolute, so the word keeps its weight against the rest of the
|
|
85
|
+
* line whatever size the line is set at, including while text scaling brings the line down to
|
|
86
|
+
* fit its box.
|
|
87
|
+
*
|
|
88
|
+
* Ignored when {@link WordConfig.fontSize} is set, which pins the word to an absolute size.
|
|
89
|
+
*/
|
|
90
|
+
fontScale?: number;
|
|
53
91
|
/**
|
|
54
92
|
* Renders this word's revealed characters. See {@link Word.custom}.
|
|
55
93
|
*/
|
|
@@ -82,6 +120,20 @@ export declare class Word<T extends string | DynamicWord | Pausing | TextEvent =
|
|
|
82
120
|
* @param text - The text or word to italicize.
|
|
83
121
|
*/
|
|
84
122
|
static italic(text: string | Word): Word;
|
|
123
|
+
/**
|
|
124
|
+
* Return a word with emphasis marks beside its characters — the East Asian counterpart of
|
|
125
|
+
* italicising a phrase.
|
|
126
|
+
*
|
|
127
|
+
* @param text - The text or word to emphasise.
|
|
128
|
+
* @param emphasis - Which glyph to draw and which side of the text to draw it on. Defaults to a
|
|
129
|
+
* filled dot above the line, the Japanese convention; Chinese text sets `position: "under"`.
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* character.say(["それは", Word.emphasis("わたし"), "が決めることです。"]);
|
|
133
|
+
* character.say(["这是", Word.emphasis("我", {position: "under"}), "的决定。"]);
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
static emphasis(text: string | Word, emphasis?: WordEmphasis): Word;
|
|
85
137
|
/**
|
|
86
138
|
* Render a word with a component of your own — an inline glossary term that opens a definition
|
|
87
139
|
* popup, a name that links into an in-game encyclopedia, anything the dialogue box cannot say
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { WordConfig, WordEmphasis } from "../../../nlcore/elements/character/word";
|
|
3
|
+
/**
|
|
4
|
+
* The size one word of a line is set at.
|
|
5
|
+
*
|
|
6
|
+
* A word sized in absolute units goes through the line's scale multiplier like every other length
|
|
7
|
+
* in the line. A word sized as a share of the line does not: `em` already resolves against the
|
|
8
|
+
* line's own size, which the multiplier has been applied to, so scaling it a second time would
|
|
9
|
+
* bring the word down twice for every step the line comes down.
|
|
10
|
+
*/
|
|
11
|
+
export declare function wordFontSize(config: Partial<WordConfig>, sentenceFontSize: React.CSSProperties["fontSize"]): React.CSSProperties["fontSize"];
|
|
12
|
+
/**
|
|
13
|
+
* The same rule where no scaling is in play — the sample line a settings screen types out has no box
|
|
14
|
+
* to fit itself into.
|
|
15
|
+
*/
|
|
16
|
+
export declare function previewWordFontSize(config: Partial<WordConfig>, sentenceFontSize: React.CSSProperties["fontSize"]): React.CSSProperties["fontSize"];
|
|
17
|
+
/**
|
|
18
|
+
* The emphasis marks a word carries, as the two declarations that draw them.
|
|
19
|
+
*
|
|
20
|
+
* The position keyword for vertical writing is always `right`: `over` and `under` are read only in
|
|
21
|
+
* horizontal writing, and both Japanese and Chinese set the marks on the right of a vertical column.
|
|
22
|
+
*/
|
|
23
|
+
export declare function emphasisStyle(emphasis: WordEmphasis | undefined): React.CSSProperties;
|