@nakamura-123/pages 1.4.3 → 1.4.4

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.
@@ -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} group={(0, articleContentFnc_1.exampleHoleGroup)(blockIndex)} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.exampleText}/>
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
- // 解説のポイント枠(ExplainBox)は全アプリの解説で使っているので変えず、記事は別の形にする
205
- case "point":
206
- return (<react_native_1.View style={styles.pointBox}>
207
- <react_native_1.View style={styles.pointLabel}>
208
- <common_1.Icon5 name="lightbulb" size={11} color="black" solid style={styles.pointLabelIcon}/>
209
- <common_1.MyText fsize="xs" weight={700} color="black">
210
- POINT
211
- </common_1.MyText>
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
- </react_native_1.View>);
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
- pointBox: {
426
- marginTop: 22,
427
- marginBottom: 14,
428
- paddingTop: 20,
429
- paddingBottom: 14,
430
- paddingHorizontal: 14,
431
- borderWidth: 1.5,
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
- pointLabel: {
437
- position: "absolute",
438
- top: -12,
439
- left: 12,
442
+ noteLabel: {
440
443
  flexDirection: "row",
441
444
  alignItems: "center",
442
- paddingHorizontal: 11,
443
- paddingVertical: 2,
444
- borderRadius: 999,
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;
@@ -111,7 +111,7 @@ const RubyWord = ({ base, ruby, fsize, weight }) => {
111
111
  };
112
112
  // 穴は文字の並びの中に置く箱で描く(数式の部品と同じやり方)。押すと箱が答えの幅まで広がり、後ろの文字は少しずつ押し出される
113
113
  // (一度に答えを入れると、後ろの文字が一瞬で飛んで読みにくいため)
114
- const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = false, }) => {
114
+ const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = false, underlineHoles = false, }) => {
115
115
  const cloze = (0, react_1.useContext)(ClozeContext);
116
116
  const figRef = (0, RefLink_1.useRefLink)();
117
117
  const parts = (0, articleContentFnc_1.splitCloze)(text);
@@ -149,6 +149,10 @@ const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = f
149
149
  }
150
150
  if (part.type === "math")
151
151
  return (<MathView key={i} math={part.content} config={MyTextqqyy_1.mathConfigs[fsize]}/>);
152
+ if (underlineHoles)
153
+ return (<common_1.MyText key={i} fsize={fsize} weight={weight} color="red" style={styles.exampleUdl}>
154
+ {ruby ? (0, articleContentFnc_1.stripRuby)(part.content) : part.content}
155
+ </common_1.MyText>);
152
156
  const g = groupOf ? groupOf(holeIndex[i]) : (0, articleContentFnc_1.holeGroup)(part.content);
153
157
  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
158
  ? () => lib_1.utilFnc.handleSearch(part.content)
@@ -160,7 +164,7 @@ const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = f
160
164
  押しても素通りする箱に入れる */}
161
165
  <react_native_1.View pointerEvents="none" style={react_native_1.StyleSheet.absoluteFill}>
162
166
  {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) => {
167
+ 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
168
  const lines = e.nativeEvent.lines;
165
169
  const width = Math.max(0, ...lines.map((l) => l.width));
166
170
  setSizes((prev) => {
@@ -176,15 +180,16 @@ const ClozeText = ({ text, fsize, weight, style, groupOf, holeEm = 4.5, ruby = f
176
180
  </react_native_1.View>);
177
181
  };
178
182
  exports.ClozeText = ClozeText;
179
- // 説明の例文。穴(ana[])は例文ごとに1組で開き、LESSONと同じ箱で描く。
183
+ // 説明の例文。文法の部分(ana[])は穴にせず、訳の決め手と同じ赤い下線で出す(2026-11-18、本人。
184
+ // 穴は説明の文に置き、例文は答えを見せて形を覚える場にする)。
180
185
  // ふりがな((漢字)ff(よみ))は、よみと漢字を縦に積んだ小さな箱を文字の並びに置いて描く
181
- const ExampleText = ({ text, group, fsize, weight, style, }) => {
186
+ const ExampleText = ({ text, fsize, weight, style, }) => {
182
187
  const ruby = (0, articleContentFnc_1.hasRuby)(text);
183
188
  if (ruby || (0, articleContentFnc_1.hasCloze)(text))
184
189
  return (<exports.ClozeText text={text} fsize={fsize} weight={weight}
185
190
  // ふりがなの箱が上の行に重ならないよう、行を高くそろえる(行ごとに高さが変わると読みにくい)
186
191
  style={ruby
187
- ? Object.assign(Object.assign({}, style), { lineHeight: (0, articleContentFnc_1.fsizeToPx)(fsize) * exports.RUBY_LINE_EM }) : style} groupOf={() => group} ruby={ruby}/>);
192
+ ? Object.assign(Object.assign({}, style), { lineHeight: (0, articleContentFnc_1.fsizeToPx)(fsize) * exports.RUBY_LINE_EM }) : style} ruby={ruby} underlineHoles/>);
188
193
  return (<common_1.MyText fsize={fsize} weight={weight} color="text" style={style}>
189
194
  {text}
190
195
  </common_1.MyText>);
@@ -310,6 +315,11 @@ const styles = react_native_1.StyleSheet.create({
310
315
  mathLine: {
311
316
  marginTop: 5,
312
317
  },
318
+ // 下線だけだと細くて見えにくい(太さは変えられない)ので、例文の訳の決め手(transUdl)と同じく字も赤にする
319
+ exampleUdl: {
320
+ textDecorationLine: "underline",
321
+ textDecorationColor: lib_1.colors.red,
322
+ },
313
323
  rubyText: {
314
324
  position: "absolute",
315
325
  top: 0,
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ interface Props {
3
+ children: React.ReactNode;
4
+ }
5
+ declare const PointBox: React.FC<Props>;
6
+ export default PointBox;
@@ -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.exampleHoleGroup = 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;
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
- // 例文の穴は例文ごとに1組(n2bのLessonは例文の文法の部分を穴にする。別の例文に同じ答えがあっても一緒に開かない)
92
- const exampleHoleGroup = (blockIndex) => `e${blockIndex}`;
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 (<react_native_1.View style={styles.box}>
43
- <common_1.MyText fsize="sm" weight={700} color="gray" style={styles.title}>
44
- {label || "ポイント"}
45
- </common_1.MyText>
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
- </react_native_1.View>);
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
- title: {
69
- marginHorizontal: 5,
70
+ pointTitle: {
71
+ marginBottom: 8,
70
72
  },
71
73
  termHead: {
72
74
  flexDirection: "row",