@nakamura-123/pages 1.4.3 → 1.4.5
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.
- package/dist/component/Article/ArticleContentView.js +34 -32
- package/dist/component/Article/Cloze.d.ts +1 -1
- package/dist/component/Article/Cloze.js +57 -11
- package/dist/component/PointBox.d.ts +6 -0
- package/dist/component/PointBox.js +51 -0
- package/dist/functions/articleContentFnc.d.ts +0 -1
- package/dist/functions/articleContentFnc.js +18 -8
- package/dist/quiz/explain/ExplainBox.js +9 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -38,6 +38,7 @@ const renderTransUdl_1 = require("../../quiz/common/renderTransUdl");
|
|
|
38
38
|
const ArticleTable_1 = __importDefault(require("./ArticleTable"));
|
|
39
39
|
const ArticleImage_1 = __importDefault(require("./ArticleImage"));
|
|
40
40
|
const FramesFigure_1 = __importDefault(require("./FramesFigure"));
|
|
41
|
+
const PointBox_1 = __importDefault(require("../PointBox"));
|
|
41
42
|
const isJudgmentBlock = (block) => (block === null || block === void 0 ? void 0 : block.type) === "incorrect" || (block === null || block === void 0 ? void 0 : block.type) === "correct";
|
|
42
43
|
const ArticleContentView = ({ content, articleId, navigation, exampleOffset = 0, isLesson = false, }) => {
|
|
43
44
|
let exampleCount = exampleOffset;
|
|
@@ -150,7 +151,7 @@ const ArticleBlockView = ({ block, blockIndex, exampleNumber, exampleImg, groupP
|
|
|
150
151
|
exampleImg !== undefined && styles.exampleTopWithImg,
|
|
151
152
|
]}>
|
|
152
153
|
{exampleImg === undefined && exampleLabel}
|
|
153
|
-
<Cloze_1.ExampleText text={block.japanese}
|
|
154
|
+
<Cloze_1.ExampleText text={block.japanese} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.exampleText}/>
|
|
154
155
|
</react_native_1.View>
|
|
155
156
|
{block.translation && (<react_native_1.TouchableOpacity onPress={() => setIsRevealed(!isRevealed)} style={styles.exampleBottom}>
|
|
156
157
|
{/* 非表示時もopacity:0で全幅描画し、訳文の実際の高さ分の領域を最初から確保する(アイコンの有無で幅が変わって高さがずれないよう、アイコンは重ねて表示する別レイヤーにする) */}
|
|
@@ -201,19 +202,26 @@ const ArticleBlockView = ({ block, blockIndex, exampleNumber, exampleImg, groupP
|
|
|
201
202
|
lineHeight: (0, articleContentFnc_1.getScaledLineHeight)((0, articleContentFnc_1.getScaledFsize)("md", userFsize), 22),
|
|
202
203
|
}}/>
|
|
203
204
|
</react_native_1.View>);
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
<common_1.
|
|
210
|
-
|
|
211
|
-
|
|
205
|
+
// 意味の欄の注意(n2bの訳だけ。英語の「considering」は理由にも使えるが…のように、母語から来る取り違えを先に止める)。
|
|
206
|
+
// 伏せずに目立たせる(2026-11-18、本人)。札の名前は訳の側が持つ(Note・주의・注意・Lưu ý)
|
|
207
|
+
case "note":
|
|
208
|
+
return (<react_native_1.View style={styles.noteBox}>
|
|
209
|
+
<react_native_1.View style={styles.noteLabel}>
|
|
210
|
+
<common_1.Icon5 name="exclamation-triangle" size={11} color="red" style={styles.noteLabelIcon}/>
|
|
211
|
+
{block.label ? (<common_1.MyText fsize="xs" weight={700} style={styles.noteLabelText}>
|
|
212
|
+
{block.label}
|
|
213
|
+
</common_1.MyText>) : null}
|
|
212
214
|
</react_native_1.View>
|
|
215
|
+
<BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={{
|
|
216
|
+
lineHeight: (0, articleContentFnc_1.getScaledLineHeight)((0, articleContentFnc_1.getScaledFsize)("md", userFsize), 22),
|
|
217
|
+
}}/>
|
|
218
|
+
</react_native_1.View>);
|
|
219
|
+
case "point":
|
|
220
|
+
return (<PointBox_1.default>
|
|
213
221
|
<BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(700, userFWeight)} style={{
|
|
214
222
|
lineHeight: (0, articleContentFnc_1.getScaledLineHeight)((0, articleContentFnc_1.getScaledFsize)("md", userFsize), 24),
|
|
215
223
|
}}/>
|
|
216
|
-
</
|
|
224
|
+
</PointBox_1.default>);
|
|
217
225
|
default:
|
|
218
226
|
return null;
|
|
219
227
|
}
|
|
@@ -421,33 +429,27 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
421
429
|
exampleNoteIcon: {
|
|
422
430
|
marginRight: 6,
|
|
423
431
|
},
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
borderColor: lib_1.colors.darkGray,
|
|
433
|
-
borderRadius: 14,
|
|
432
|
+
noteBox: {
|
|
433
|
+
marginTop: 4,
|
|
434
|
+
marginBottom: 12,
|
|
435
|
+
paddingVertical: 8,
|
|
436
|
+
paddingHorizontal: 12,
|
|
437
|
+
borderLeftWidth: 4,
|
|
438
|
+
borderLeftColor: lib_1.colors.yellow,
|
|
439
|
+
borderRadius: 6,
|
|
434
440
|
backgroundColor: lib_1.colors.white,
|
|
435
441
|
},
|
|
436
|
-
|
|
437
|
-
position: "absolute",
|
|
438
|
-
top: -12,
|
|
439
|
-
left: 12,
|
|
442
|
+
noteLabel: {
|
|
440
443
|
flexDirection: "row",
|
|
441
444
|
alignItems: "center",
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
borderWidth: 1.5,
|
|
446
|
-
borderColor: lib_1.colors.darkGray,
|
|
447
|
-
backgroundColor: lib_1.colors.yellow,
|
|
448
|
-
},
|
|
449
|
-
pointLabelIcon: {
|
|
445
|
+
marginBottom: 2,
|
|
446
|
+
},
|
|
447
|
+
noteLabelIcon: {
|
|
450
448
|
marginRight: 6,
|
|
451
449
|
},
|
|
450
|
+
// 共通の黄(#F7D44C)は白の上の文字には薄いので、同じ系統の濃い色にする
|
|
451
|
+
noteLabelText: {
|
|
452
|
+
color: "#A06A00",
|
|
453
|
+
},
|
|
452
454
|
});
|
|
453
455
|
exports.default = ArticleContentView;
|
|
@@ -17,12 +17,12 @@ interface ClozeTextProps {
|
|
|
17
17
|
groupOf?: (hole: number) => string;
|
|
18
18
|
holeEm?: number;
|
|
19
19
|
ruby?: boolean;
|
|
20
|
+
underlineHoles?: boolean;
|
|
20
21
|
}
|
|
21
22
|
export declare const RUBY_LINE_EM = 2.3;
|
|
22
23
|
export declare const ClozeText: React.FC<ClozeTextProps>;
|
|
23
24
|
interface ExampleTextProps {
|
|
24
25
|
text: string;
|
|
25
|
-
group: string;
|
|
26
26
|
fsize: FontSize;
|
|
27
27
|
weight: FontWeight;
|
|
28
28
|
style?: TextStyle;
|
|
@@ -26,40 +26,54 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.ExampleText = exports.ClozeText = exports.RUBY_LINE_EM = exports.ClozeBar = exports.useLessonSearch = exports.ClozeProvider = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const react_native_1 = require("react-native");
|
|
29
|
+
const react_redux_1 = require("react-redux");
|
|
29
30
|
const lib_1 = require("@nakamura-123/lib");
|
|
30
31
|
const common_1 = require("@nakamura-123/common");
|
|
32
|
+
const stores_1 = require("@nakamura-123/stores");
|
|
31
33
|
const MyTextqqyy_1 = require("../../quiz/common/MyTextqqyy");
|
|
32
34
|
const RefLink_1 = require("./RefLink");
|
|
33
35
|
const articleContentFnc_1 = require("../../functions/articleContentFnc");
|
|
34
36
|
const MathView = require("react-native-math-view").default;
|
|
35
37
|
const ClozeContext = (0, react_1.createContext)(null);
|
|
36
38
|
// 開いたかどうかは保存しない(10/24の決定)。LESSONではページごと、名札の無い記事では記事全体で1つ持つ。
|
|
37
|
-
//
|
|
39
|
+
// 開いた答えは押しても閉じない(押すのは検索に使う)。隠し直すのはページの上の「全部隠す」で行う。
|
|
40
|
+
// 「常に表示」にチェックがあれば、どのページ・記事でも全部開いた形で出す(設定に保存する。2026-11-18、本人)
|
|
38
41
|
const ClozeProvider = ({ blocks, searchEnabled, children }) => {
|
|
39
42
|
const groups = (0, react_1.useMemo)(() => (0, articleContentFnc_1.clozeGroups)(blocks), [blocks]);
|
|
40
43
|
const pageImages = (0, react_1.useMemo)(() => blocks.flatMap((b) => (b.type === "image" ? [b.name] : [])), [blocks]);
|
|
41
44
|
const [opened, setOpened] = (0, react_1.useState)(new Set());
|
|
45
|
+
const isLocked = (0, react_redux_1.useSelector)((state) => { var _a; return (_a = state.quizCfg.inQuizOption.isClozeOpenLock) !== null && _a !== void 0 ? _a : false; });
|
|
42
46
|
const value = (0, react_1.useMemo)(() => ({
|
|
43
47
|
groups,
|
|
44
|
-
opened,
|
|
48
|
+
opened: isLocked ? new Set(groups) : opened,
|
|
45
49
|
open: (group) => setOpened((prev) => prev.has(group) ? prev : new Set(prev).add(group)),
|
|
46
50
|
setAll: (open) => setOpened(open ? new Set(groups) : new Set()),
|
|
47
51
|
searchEnabled,
|
|
48
52
|
pageImages,
|
|
49
|
-
|
|
53
|
+
isLocked,
|
|
54
|
+
}), [groups, opened, searchEnabled, pageImages, isLocked]);
|
|
50
55
|
return (<ClozeContext.Provider value={value}>{children}</ClozeContext.Provider>);
|
|
51
56
|
};
|
|
52
57
|
exports.ClozeProvider = ClozeProvider;
|
|
53
58
|
const useLessonSearch = () => { var _a, _b; return (_b = (_a = (0, react_1.useContext)(ClozeContext)) === null || _a === void 0 ? void 0 : _a.searchEnabled) !== null && _b !== void 0 ? _b : false; };
|
|
54
59
|
exports.useLessonSearch = useLessonSearch;
|
|
55
60
|
// 穴の数と、全部を開ける・隠すボタン。穴の無いページには出さない。
|
|
56
|
-
// 1つでも閉じていれば「全部見る」、1
|
|
61
|
+
// 1つでも閉じていれば「全部見る」、1つでも開いていれば「全部隠す」を出す(途中までは両方)。
|
|
62
|
+
// 「常に表示」にチェックがある間は全部開いているので、開ける・隠すボタンは出さない
|
|
57
63
|
const ClozeBar = () => {
|
|
58
64
|
const cloze = (0, react_1.useContext)(ClozeContext);
|
|
59
65
|
const { t } = (0, common_1.useDrillTranslation)();
|
|
66
|
+
const dispatch = (0, react_redux_1.useDispatch)();
|
|
60
67
|
if (!cloze || cloze.groups.length === 0)
|
|
61
68
|
return null;
|
|
62
69
|
const openCount = cloze.groups.filter((g) => cloze.opened.has(g)).length;
|
|
70
|
+
const toggleLock = () => {
|
|
71
|
+
dispatch(stores_1.cfgAction.selectInQuizOption({
|
|
72
|
+
key: "isClozeOpenLock",
|
|
73
|
+
value: !cloze.isLocked,
|
|
74
|
+
}));
|
|
75
|
+
dispatch(stores_1.cfgStorage.saveCfgOption());
|
|
76
|
+
};
|
|
63
77
|
return (<react_native_1.View style={styles.bar}>
|
|
64
78
|
<common_1.MyText fsize="xs" weight={700} color="ltBlack">
|
|
65
79
|
{t("article.clozeCount", {
|
|
@@ -68,12 +82,18 @@ const ClozeBar = () => {
|
|
|
68
82
|
})}
|
|
69
83
|
</common_1.MyText>
|
|
70
84
|
<react_native_1.View style={styles.barButtons}>
|
|
71
|
-
|
|
85
|
+
<common_1.PressAnimatedWrap onPress={toggleLock} style={styles.lockButton}>
|
|
86
|
+
<common_1.Icon5 name={cloze.isLocked ? "check-square" : "square"} size={14} color={cloze.isLocked ? "red" : "ltBlack"} solid={cloze.isLocked} style={styles.lockIcon}/>
|
|
87
|
+
<common_1.MyText fsize="xs" weight={700} color="text">
|
|
88
|
+
{t("article.keepAnswersShown")}
|
|
89
|
+
</common_1.MyText>
|
|
90
|
+
</common_1.PressAnimatedWrap>
|
|
91
|
+
{!cloze.isLocked && openCount > 0 && (<common_1.PressAnimatedWrap onPress={() => cloze.setAll(false)} style={styles.barButton}>
|
|
72
92
|
<common_1.MyText fsize="xs" weight={700} color="text">
|
|
73
93
|
{t("article.hideAllAnswers")}
|
|
74
94
|
</common_1.MyText>
|
|
75
95
|
</common_1.PressAnimatedWrap>)}
|
|
76
|
-
{openCount < cloze.groups.length && (<common_1.PressAnimatedWrap onPress={() => cloze.setAll(true)} style={styles.barButton}>
|
|
96
|
+
{!cloze.isLocked && openCount < cloze.groups.length && (<common_1.PressAnimatedWrap onPress={() => cloze.setAll(true)} style={styles.barButton}>
|
|
77
97
|
<common_1.MyText fsize="xs" weight={700} color="text">
|
|
78
98
|
{t("article.showAllAnswers")}
|
|
79
99
|
</common_1.MyText>
|
|
@@ -111,7 +131,7 @@ const RubyWord = ({ base, ruby, fsize, weight }) => {
|
|
|
111
131
|
};
|
|
112
132
|
// 穴は文字の並びの中に置く箱で描く(数式の部品と同じやり方)。押すと箱が答えの幅まで広がり、後ろの文字は少しずつ押し出される
|
|
113
133
|
// (一度に答えを入れると、後ろの文字が一瞬で飛んで読みにくいため)
|
|
114
|
-
const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = false, }) => {
|
|
134
|
+
const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = false, underlineHoles = false, }) => {
|
|
115
135
|
const cloze = (0, react_1.useContext)(ClozeContext);
|
|
116
136
|
const figRef = (0, RefLink_1.useRefLink)();
|
|
117
137
|
const parts = (0, articleContentFnc_1.splitCloze)(text);
|
|
@@ -149,6 +169,10 @@ const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = f
|
|
|
149
169
|
}
|
|
150
170
|
if (part.type === "math")
|
|
151
171
|
return (<MathView key={i} math={part.content} config={MyTextqqyy_1.mathConfigs[fsize]}/>);
|
|
172
|
+
if (underlineHoles)
|
|
173
|
+
return (<common_1.MyText key={i} fsize={fsize} weight={weight} color="red" style={styles.exampleUdl}>
|
|
174
|
+
{ruby ? (0, articleContentFnc_1.stripRuby)(part.content) : part.content}
|
|
175
|
+
</common_1.MyText>);
|
|
152
176
|
const g = groupOf ? groupOf(holeIndex[i]) : (0, articleContentFnc_1.holeGroup)(part.content);
|
|
153
177
|
return (<HoleBox key={i} answer={ruby ? (0, articleContentFnc_1.stripRuby)(part.content) : part.content} isOpen={(_b = cloze === null || cloze === void 0 ? void 0 : cloze.opened.has(g)) !== null && _b !== void 0 ? _b : true} onOpen={() => cloze === null || cloze === void 0 ? void 0 : cloze.open(g)} onSearch={part.search && (cloze === null || cloze === void 0 ? void 0 : cloze.searchEnabled)
|
|
154
178
|
? () => lib_1.utilFnc.handleSearch(part.content)
|
|
@@ -160,7 +184,7 @@ const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = f
|
|
|
160
184
|
押しても素通りする箱に入れる */}
|
|
161
185
|
<react_native_1.View pointerEvents="none" style={react_native_1.StyleSheet.absoluteFill}>
|
|
162
186
|
{containerWidth > 0 &&
|
|
163
|
-
parts.map((part, i) => part.type === "hole" ? (<common_1.MyText key={`m${i}`} fsize={fsize} weight={700} style={[styles.measure, { width: containerWidth, lineHeight }]} onTextLayout={(e) => {
|
|
187
|
+
parts.map((part, i) => part.type === "hole" && !underlineHoles ? (<common_1.MyText key={`m${i}`} fsize={fsize} weight={700} style={[styles.measure, { width: containerWidth, lineHeight }]} onTextLayout={(e) => {
|
|
164
188
|
const lines = e.nativeEvent.lines;
|
|
165
189
|
const width = Math.max(0, ...lines.map((l) => l.width));
|
|
166
190
|
setSizes((prev) => {
|
|
@@ -176,15 +200,16 @@ const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = f
|
|
|
176
200
|
</react_native_1.View>);
|
|
177
201
|
};
|
|
178
202
|
exports.ClozeText = ClozeText;
|
|
179
|
-
//
|
|
203
|
+
// 説明の例文。文法の部分(ana[])は穴にせず、訳の決め手と同じ赤い下線で出す(2026-11-18、本人。
|
|
204
|
+
// 穴は説明の文に置き、例文は答えを見せて形を覚える場にする)。
|
|
180
205
|
// ふりがな((漢字)ff(よみ))は、よみと漢字を縦に積んだ小さな箱を文字の並びに置いて描く
|
|
181
|
-
const ExampleText = ({ text,
|
|
206
|
+
const ExampleText = ({ text, fsize, weight, style, }) => {
|
|
182
207
|
const ruby = (0, articleContentFnc_1.hasRuby)(text);
|
|
183
208
|
if (ruby || (0, articleContentFnc_1.hasCloze)(text))
|
|
184
209
|
return (<exports.ClozeText text={text} fsize={fsize} weight={weight}
|
|
185
210
|
// ふりがなの箱が上の行に重ならないよう、行を高くそろえる(行ごとに高さが変わると読みにくい)
|
|
186
211
|
style={ruby
|
|
187
|
-
? Object.assign(Object.assign({}, style), { lineHeight: (0, articleContentFnc_1.fsizeToPx)(fsize) * exports.RUBY_LINE_EM }) : style}
|
|
212
|
+
? Object.assign(Object.assign({}, style), { lineHeight: (0, articleContentFnc_1.fsizeToPx)(fsize) * exports.RUBY_LINE_EM }) : style} ruby={ruby} underlineHoles/>);
|
|
188
213
|
return (<common_1.MyText fsize={fsize} weight={weight} color="text" style={style}>
|
|
189
214
|
{text}
|
|
190
215
|
</common_1.MyText>);
|
|
@@ -280,8 +305,14 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
280
305
|
justifyContent: "space-between",
|
|
281
306
|
marginBottom: 10,
|
|
282
307
|
},
|
|
308
|
+
// 途中まで開くと「常に表示」と2つのボタンが並ぶ。狭い画面や長い訳では折り返す
|
|
283
309
|
barButtons: {
|
|
284
310
|
flexDirection: "row",
|
|
311
|
+
flexWrap: "wrap",
|
|
312
|
+
justifyContent: "flex-end",
|
|
313
|
+
alignItems: "center",
|
|
314
|
+
flexShrink: 1,
|
|
315
|
+
marginLeft: 8,
|
|
285
316
|
gap: 6,
|
|
286
317
|
},
|
|
287
318
|
barButton: {
|
|
@@ -292,6 +323,16 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
292
323
|
borderColor: lib_1.colors.light,
|
|
293
324
|
backgroundColor: lib_1.colors.white,
|
|
294
325
|
},
|
|
326
|
+
// ボタンと違って押しても消えない切り替えなので、枠を付けずにチェックの印と文字だけにする
|
|
327
|
+
lockButton: {
|
|
328
|
+
flexDirection: "row",
|
|
329
|
+
alignItems: "center",
|
|
330
|
+
paddingHorizontal: 4,
|
|
331
|
+
paddingVertical: 4,
|
|
332
|
+
},
|
|
333
|
+
lockIcon: {
|
|
334
|
+
marginRight: 5,
|
|
335
|
+
},
|
|
295
336
|
hole: {
|
|
296
337
|
borderRadius: 4,
|
|
297
338
|
backgroundColor: lib_1.colors.beige,
|
|
@@ -310,6 +351,11 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
310
351
|
mathLine: {
|
|
311
352
|
marginTop: 5,
|
|
312
353
|
},
|
|
354
|
+
// 下線だけだと細くて見えにくい(太さは変えられない)ので、例文の訳の決め手(transUdl)と同じく字も赤にする
|
|
355
|
+
exampleUdl: {
|
|
356
|
+
textDecorationLine: "underline",
|
|
357
|
+
textDecorationColor: lib_1.colors.red,
|
|
358
|
+
},
|
|
313
359
|
rubyText: {
|
|
314
360
|
position: "absolute",
|
|
315
361
|
top: 0,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const lib_1 = require("@nakamura-123/lib");
|
|
9
|
+
const common_1 = require("@nakamura-123/common");
|
|
10
|
+
// ポイントの枠。LESSONの記事と問題の解説で同じ形にする(2026-11-18、本人)。
|
|
11
|
+
// 題は札に入れず、使う側が枠の中の1行目に置く(長い題でも札が崩れないように)
|
|
12
|
+
const PointBox = ({ children }) => (<react_native_1.View style={styles.box}>
|
|
13
|
+
<react_native_1.View style={styles.label}>
|
|
14
|
+
<common_1.Icon5 name="lightbulb" size={11} color="black" solid style={styles.labelIcon}/>
|
|
15
|
+
<common_1.MyText fsize="xs" weight={700} color="black">
|
|
16
|
+
POINT
|
|
17
|
+
</common_1.MyText>
|
|
18
|
+
</react_native_1.View>
|
|
19
|
+
{children}
|
|
20
|
+
</react_native_1.View>);
|
|
21
|
+
const styles = react_native_1.StyleSheet.create({
|
|
22
|
+
// 札を枠の上の線に重ねるので、その分だけ上を空ける
|
|
23
|
+
box: {
|
|
24
|
+
marginTop: 22,
|
|
25
|
+
marginBottom: 14,
|
|
26
|
+
paddingTop: 20,
|
|
27
|
+
paddingBottom: 14,
|
|
28
|
+
paddingHorizontal: 14,
|
|
29
|
+
borderWidth: 1.5,
|
|
30
|
+
borderColor: lib_1.colors.darkGray,
|
|
31
|
+
borderRadius: 14,
|
|
32
|
+
backgroundColor: lib_1.colors.white,
|
|
33
|
+
},
|
|
34
|
+
label: {
|
|
35
|
+
position: "absolute",
|
|
36
|
+
top: -12,
|
|
37
|
+
left: 12,
|
|
38
|
+
flexDirection: "row",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
paddingHorizontal: 11,
|
|
41
|
+
paddingVertical: 2,
|
|
42
|
+
borderRadius: 999,
|
|
43
|
+
borderWidth: 1.5,
|
|
44
|
+
borderColor: lib_1.colors.darkGray,
|
|
45
|
+
backgroundColor: lib_1.colors.yellow,
|
|
46
|
+
},
|
|
47
|
+
labelIcon: {
|
|
48
|
+
marginRight: 6,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
exports.default = PointBox;
|
|
@@ -35,7 +35,6 @@ export type RubyPart = {
|
|
|
35
35
|
export declare const hasRuby: (text: string) => boolean;
|
|
36
36
|
export declare const stripRuby: (text: string) => string;
|
|
37
37
|
export declare const splitRuby: (text: string) => RubyPart[];
|
|
38
|
-
export declare const exampleHoleGroup: (blockIndex: number) => string;
|
|
39
38
|
export declare const clozeGroups: (blocks: ArticleBlock[]) => string[];
|
|
40
39
|
export declare const parseArticleContent: (raw: string) => ArticleContent;
|
|
41
40
|
export interface ArticleSection {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectLessonAnchors = exports.findSectionIndex = exports.splitArticleSections = exports.parseArticleContent = exports.clozeGroups = exports.
|
|
3
|
+
exports.collectLessonAnchors = exports.findSectionIndex = exports.splitArticleSections = exports.parseArticleContent = exports.clozeGroups = exports.splitRuby = exports.stripRuby = exports.hasRuby = exports.tableHoleGroup = exports.holeGroup = exports.splitCloze = exports.usesClozeText = exports.hasFigref = exports.hasSearch = exports.hasCloze = exports.getScaledLineHeight = exports.fsizeToPx = exports.getScaledWeight = exports.getScaledFsize = void 0;
|
|
4
4
|
const lib_1 = require("@nakamura-123/lib");
|
|
5
5
|
const ExplainLogic_1 = require("../quiz/explain/ExplainLogic");
|
|
6
6
|
const REI_PATTERN = /^rei\d*$/;
|
|
@@ -88,10 +88,8 @@ const splitRuby = (text) => {
|
|
|
88
88
|
return parts;
|
|
89
89
|
};
|
|
90
90
|
exports.splitRuby = splitRuby;
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
exports.exampleHoleGroup = exampleHoleGroup;
|
|
94
|
-
// ページ(ArticleContentViewに渡すblocks)にある穴の組を、出てくる順に重ねずに並べる
|
|
91
|
+
// ページ(ArticleContentViewに渡すblocks)にある穴の組を、出てくる順に重ねずに並べる。
|
|
92
|
+
// 例文のana[]は下線で出す(穴にしない)ので数えない
|
|
95
93
|
const clozeGroups = (blocks) => {
|
|
96
94
|
const groups = new Set();
|
|
97
95
|
const addText = (text) => (0, exports.splitCloze)(text).forEach((part) => {
|
|
@@ -101,10 +99,9 @@ const clozeGroups = (blocks) => {
|
|
|
101
99
|
blocks.forEach((block, index) => {
|
|
102
100
|
if (block.type === "paragraph" ||
|
|
103
101
|
block.type === "point" ||
|
|
104
|
-
block.type === "exampleNote"
|
|
102
|
+
block.type === "exampleNote" ||
|
|
103
|
+
block.type === "note")
|
|
105
104
|
addText(block.text);
|
|
106
|
-
if (block.type === "example" && (0, exports.hasCloze)(block.japanese))
|
|
107
|
-
groups.add((0, exports.exampleHoleGroup)(index));
|
|
108
105
|
if (block.type === "table")
|
|
109
106
|
block.rows.forEach((cells, r) => cells.forEach((cell, c) => (0, exports.splitCloze)(cell)
|
|
110
107
|
.filter((part) => part.type === "hole")
|
|
@@ -208,6 +205,19 @@ const parseArticleContent = (raw) => {
|
|
|
208
205
|
lastExampleBlock = null;
|
|
209
206
|
return;
|
|
210
207
|
}
|
|
208
|
+
// 注意の札(n2bの訳の意味の欄の「Note: …」。書き出し(export_n2b_lessons.py)が「note 札の名前|本文」に替える)
|
|
209
|
+
if (token === "note") {
|
|
210
|
+
const bar = content.indexOf("|");
|
|
211
|
+
blocks.push(bar === -1
|
|
212
|
+
? { type: "note", label: "", text: content }
|
|
213
|
+
: {
|
|
214
|
+
type: "note",
|
|
215
|
+
label: content.slice(0, bar),
|
|
216
|
+
text: content.slice(bar + 1),
|
|
217
|
+
});
|
|
218
|
+
lastExampleBlock = null;
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
211
221
|
if (token === "img") {
|
|
212
222
|
blocks.push({ type: "image", name: content });
|
|
213
223
|
lastExampleBlock = null;
|
|
@@ -32,19 +32,21 @@ const react_native_collapsible_1 = __importDefault(require("react-native-collaps
|
|
|
32
32
|
const react_redux_1 = require("react-redux");
|
|
33
33
|
const lib_1 = require("@nakamura-123/lib");
|
|
34
34
|
const common_1 = require("@nakamura-123/common");
|
|
35
|
+
const PointBox_1 = __importDefault(require("../../component/PointBox"));
|
|
35
36
|
// ポイントは開いたまま、用語の説明は閉じて置く(知っている人は飛ばせるように)
|
|
36
37
|
const ExplainBox = ({ type, title, children }) => {
|
|
37
38
|
const [collapsed, setCollapsed] = (0, react_1.useState)(type === "term");
|
|
38
39
|
const fsize = (0, react_redux_1.useSelector)((state) => state.quizCfg.inQuizOption.fsize);
|
|
39
40
|
// 題は押して開くための見出しなので、検索語の印(yy)は外して出す
|
|
40
41
|
const label = title.replace(/yy/g, "");
|
|
42
|
+
// 札が「POINT」と示すので、題の無い枠には題の行を出さない
|
|
41
43
|
if (type === "point")
|
|
42
|
-
return (<
|
|
43
|
-
<common_1.MyText fsize=
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
return (<PointBox_1.default>
|
|
45
|
+
{label ? (<common_1.MyText fsize={fsize} weight={700} style={styles.pointTitle}>
|
|
46
|
+
{label}
|
|
47
|
+
</common_1.MyText>) : null}
|
|
46
48
|
{children}
|
|
47
|
-
</
|
|
49
|
+
</PointBox_1.default>);
|
|
48
50
|
return (<react_native_1.View style={styles.box}>
|
|
49
51
|
<react_native_1.TouchableOpacity style={styles.termHead} onPress={() => setCollapsed(!collapsed)}>
|
|
50
52
|
<common_1.MyText fsize={fsize} weight={700} style={styles.termTitle}>
|
|
@@ -65,8 +67,8 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
65
67
|
padding: 6,
|
|
66
68
|
marginVertical: 8,
|
|
67
69
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
pointTitle: {
|
|
71
|
+
marginBottom: 8,
|
|
70
72
|
},
|
|
71
73
|
termHead: {
|
|
72
74
|
flexDirection: "row",
|