@ihabdevteam/core 0.380.0 → 0.383.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.
- package/CHANGELOG.md +177 -1
- package/dist/components.cjs.js +169 -169
- package/dist/components.esm.css +1 -1
- package/dist/hooks.cjs.js +3 -3
- package/dist/i18n.cjs.js +3 -3
- package/dist/ihabdevteam-core.cjs.js +174 -174
- package/dist/ihabdevteam-core.d.ts +27 -3
- package/dist/packages/core/src/components/Table.d.ts +7 -0
- package/dist/packages/core/src/components/Table.js +20 -9
- package/dist/packages/core/src/components/Word/TableFilterPanel.d.ts +2 -0
- package/dist/packages/core/src/components/Word/TableFilterPanel.js +2 -2
- package/dist/packages/core/src/components/Word/WordTableBlock.d.ts +1 -1
- package/dist/packages/core/src/components/Word/WordTableBlock.js +43 -9
- package/dist/packages/core/src/components/Word/wordTableBlockTypes.d.ts +15 -0
- package/dist/packages/core/src/components/Word/wordTableSettings.d.ts +23 -5
- package/dist/packages/core/src/components/Word/wordTableSettings.js +29 -7
- package/dist/packages/core/src/components/WordTable.css +33 -8
- package/dist/packages/core/src/components/WordTable.js +44 -6
- package/dist/packages/core/src/components/tableSpanMeasure.d.ts +48 -0
- package/dist/packages/core/src/components/tableSpanMeasure.js +74 -0
- package/dist/packages/core/src/components/wordTableLayout.d.ts +1 -1
- package/dist/packages/core/src/i18n/locales/en.json +1 -0
- package/dist/packages/core/src/i18n/locales/ko.json +1 -0
- package/dist/packages/core/src/utils/headProbeStatus.d.ts +21 -0
- package/dist/packages/core/src/utils/headProbeStatus.js +23 -0
- package/dist/packages/core/src/utils/imageConfig.js +3 -2
- package/dist/packages/core/src/utils/ttsConfig.js +3 -2
- package/dist/packages/core/src/version.d.ts +1 -1
- package/dist/packages/core/src/version.js +1 -1
- package/dist/utils.cjs.js +160 -160
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import './WordTable.css';
|
|
|
8
8
|
import Button from './Button';
|
|
9
9
|
import Badge from './Badge';
|
|
10
10
|
import { withLegacy } from '../utils/legacyBlocks';
|
|
11
|
+
import { devWarnOnce } from '../utils/devWarn';
|
|
11
12
|
import Section from './Section';
|
|
12
13
|
import DescriptionTooltip from './Tooltip/DescriptionTooltip';
|
|
13
14
|
import { getTTSUrlResolver, getTTSFallbackUrlResolver } from '../utils/ttsConfig';
|
|
@@ -49,7 +50,7 @@ const srOnly = {
|
|
|
49
50
|
const LONG_PRESS_MS = 400;
|
|
50
51
|
/** 길게 누르기가 익기 전에 이만큼 움직이면 그건 끌기가 아니라 **스크롤**이라 취소한다 */
|
|
51
52
|
const MOVE_THRESHOLD_PX = 8;
|
|
52
|
-
function WordCell({ label, subLabel, colloquialLabel, captionLabel, captionBadge, homonum, showWord = true, showImage = true, showPronunciation = true, showColloquial = true, buttonSize = 40, wordInfo, outerScale = 1, }) {
|
|
53
|
+
function WordCell({ label, subLabel, colloquialLabel, captionLabel, captionBadge, homonum, showWord = true, showImage = true, showPronunciation = true, showColloquial = true, showCaption = true, buttonSize = 40, wordInfo, outerScale = 1, }) {
|
|
53
54
|
const { t } = useTranslation();
|
|
54
55
|
const outerRef = useRef(null);
|
|
55
56
|
const infoRef = useRef(null);
|
|
@@ -253,7 +254,7 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, captionBadge
|
|
|
253
254
|
* 안 곱하면 또 조용히 헛돈다.
|
|
254
255
|
*/
|
|
255
256
|
const tapTooSmall = buttonSize * outerScale < MIN_TAP_PX;
|
|
256
|
-
return (_jsxs("div", { ref: outerRef, className: cx('word-table-cell', tapTooSmall && 'word-table-cell--tap-too-small', hasImage ? 'word-table-cell--with-image' : ''), "data-ref-w": refW, "data-ref-h": refH, children: [_jsxs("div", { className: "word-table-cell__inner", style: { transform: `scale(${scale})` }, children: [hasImage && (_jsxs("div", { className: "word-table-cell__image-wrap", children: [imgLoading && _jsx("div", { className: "word-table-cell__spinner" }), _jsx("img", { ref: imgRef, className: "word-table-cell__image", src: imageUrl, alt: label, draggable: false, style: { opacity: imgLoading ? 0 : 1 }, onLoad: handleImgLoad, onError: handleImgError })] })), (captionBadge || captionLabel) && (
|
|
257
|
+
return (_jsxs("div", { ref: outerRef, className: cx('word-table-cell', tapTooSmall && 'word-table-cell--tap-too-small', hasImage ? 'word-table-cell--with-image' : ''), "data-ref-w": refW, "data-ref-h": refH, children: [_jsxs("div", { className: "word-table-cell__inner", style: { transform: `scale(${scale})` }, children: [hasImage && (_jsxs("div", { className: "word-table-cell__image-wrap", children: [imgLoading && _jsx("div", { className: "word-table-cell__spinner" }), _jsx("img", { ref: imgRef, className: "word-table-cell__image", src: imageUrl, alt: label, draggable: false, style: { opacity: imgLoading ? 0 : 1 }, onLoad: handleImgLoad, onError: handleImgError })] })), showCaption && (captionBadge || captionLabel) && (
|
|
257
258
|
/* **[배지][이름표] 한 줄** — 둘은 성격이 다르다(청 (328)). 배지는 *무엇을 하는
|
|
258
259
|
말인가*(치료사가 고르는 잣대), 이름표는 *어떤 꼬리가 붙는가*(학습자가 낼
|
|
259
260
|
소리)다. 한 글자로 붙여 놓으면 그 둘이 안 갈린다. 가운뎃점은 안 쓴다 —
|
|
@@ -522,8 +523,45 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
522
523
|
image: types.length === 0 || types.includes('image'),
|
|
523
524
|
pron: types.length === 0 || types.includes('standardPron'),
|
|
524
525
|
colloq: types.length === 0 || types.includes('colloquialPron'),
|
|
526
|
+
/* 이름표(`captionBadge`·`captionLabel`) — 말귀 청 (334), 2026-10-28. 종이로 뽑아 쓰는
|
|
527
|
+
자리라 **무엇을 숨기느냐가 그대로 과제가 된다**: 끄면 *이 꼴이 무엇인지 맞혀 보라*,
|
|
528
|
+
켜면 *이 꼴은 이것이다* 다. 전에는 주면 늘 서서 뒤쪽 하나만 만들 수 있었다. */
|
|
529
|
+
caption: types.length === 0 || types.includes('caption'),
|
|
525
530
|
});
|
|
526
531
|
const show = showOf(contentTypes);
|
|
532
|
+
/**
|
|
533
|
+
* **칸의 열쇠** — `item.id` 가 표 안에서 **하나뿐일 때만** 그것으로 센다(말귀 청 (335), 2026-10-28).
|
|
534
|
+
*
|
|
535
|
+
* 번호로 세면 셋째 칸을 뺄 때 그 뒤 칸이 **전부 다른 `item` 을 받는다.** 칸은 그대로 선
|
|
536
|
+
* 채로 속만 바뀌니 `WordCell` 의 `useEffect([pron, label])` 이 그때마다 소리 주소를 다시
|
|
537
|
+
* 받아 오고, 재생 중이던 소리와 상태가 밀린다 — 서른네 칸짜리 표에서 둘째를 빼자 HEAD 가
|
|
538
|
+
* **열다섯 번** 나갔다(말귀 실측, 전부 이미 받아 둔 파일).
|
|
539
|
+
*
|
|
540
|
+
* **그래도 `id` 를 곧바로 못 쓴다.** `id` 가 겹치는 표에서는 React 가 그 칸들을 하나로
|
|
541
|
+
* 본다 — 2026-10-27 에 활용표가 그랬다(`감사하다#1` 이 네 칸에 섰다. 한 낱말의 열두 꼴이
|
|
542
|
+
* 모두 그 낱말의 `id` 를 쥐던 때다). 말귀는 그 뒤 `감사하다#1::과거` 꼴로 바꾸어 겹침을
|
|
543
|
+
* 풀었지만, **코어는 부르는 쪽이 그랬다고 믿을 수 없다.** 그래서 센다 — 겹치거나 빈
|
|
544
|
+
* `id` 가 하나라도 있으면 표 **통째로** 번호로 돌아간다(지금까지와 같다).
|
|
545
|
+
*
|
|
546
|
+
* **번호에 `id` 를 덧붙이지 않는다.** 그러면 겹침은 풀리지만 자리바꿈에서 두 칸이 **다시
|
|
547
|
+
* 태어난다**(실측: DOM 마디 `false/false`). 이 표에는 끌어 옮기기가 있고 `WordCell` 은
|
|
548
|
+
* `ResizeObserver` 로 제 상자를 재어 배율을 쥐므로, 끄는 동안 칸마다 관찰자가 뜯겼다
|
|
549
|
+
* 붙고 배율이 처음부터 다시 선다. 그대로인 `item.id` 는 자리만 옮기니 그 값을 안 치른다.
|
|
550
|
+
*
|
|
551
|
+
* 격자 자리(`dotDashStyle(index, …)`)·채점 열쇠(`renderScore(index, …)`)·손가락 밑의
|
|
552
|
+
* 칸(`data-wordtable-cell`)은 **그대로 번호**다 — 그것들은 자리를 묻는 것이고, 열쇠는
|
|
553
|
+
* 정체를 묻는 것이다.
|
|
554
|
+
*/
|
|
555
|
+
const cellKeys = useMemo(() => {
|
|
556
|
+
const ids = (items ?? []).map(it => it.id);
|
|
557
|
+
const unique = ids.every(id => typeof id === 'string' && id.length > 0) && new Set(ids).size === ids.length;
|
|
558
|
+
if (!unique && ids.length > 0) {
|
|
559
|
+
devWarnOnce('wordTable.cellKeyFallback', '[ihab/core] WordTable: items 의 id 가 겹치거나 비어 있어 칸을 자리 번호로 센다. ' +
|
|
560
|
+
'칸을 빼거나 더할 때 뒤 칸들이 통째로 다시 그려진다(소리 주소를 다시 받아 온다). ' +
|
|
561
|
+
'id 를 표 안에서 하나뿐인 값으로 지어 주면 그 값이 사라진다.');
|
|
562
|
+
}
|
|
563
|
+
return unique ? ids : null;
|
|
564
|
+
}, [items]);
|
|
527
565
|
const baseShow = showOf(baseContentTypes ?? contentTypes);
|
|
528
566
|
const hasPairs = isEdit
|
|
529
567
|
? (editCells ?? []).some(c => c !== null && c.length > 1)
|
|
@@ -570,7 +608,7 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
570
608
|
gridTemplateRows: `repeat(${rows}, 1fr)`,
|
|
571
609
|
}, children: [isEdit ? (_jsx(_Fragment, { children: (editCells ?? []).map((cell, i) => (_jsx("div", { className: withLegacy(cx('word-table__edit-cell', cell ? 'word-table__edit-cell--filled' : 'word-table__edit-cell--empty', activeCell === i ? 'word-table__edit-cell--active' : '')), style: dotDashStyle(i, cols, rows, cutLine), children: cell ? (_jsxs(_Fragment, { children: [cell.map((e, wi) => (_jsxs(Fragment, { children: [wi > 0 && _jsx("div", { className: withLegacy("word-table__pair-divider") }), _jsx(WordCell, { outerScale: scale, label: e.word, subLabel: e.pronunciation,
|
|
572
610
|
// 편집 칸도 구어체 발음을 넘긴다 — 빠져 있어 '구어체 발음'을 켜도 편집 모드에서만 비었다.
|
|
573
|
-
colloquialLabel: e.colloquialPronunciation, homonum: e.homonum, showWord: show.word, showImage: show.image, showPronunciation: show.pron, showColloquial: show.colloq, buttonSize: buttonSize })] }, wi))), scoring && renderScore(i, cell.map(e => e.word).join(' / ')), onRemoveCell && (_jsx("div", { className: withLegacy("word-table__card-close"), children: _jsx(Button, { htmlType: "button", size: buttonSize, type: "dot", icon: "x", variant: "transparent-lightGray", useBorder: false, showTooltipInfo: cell.length > 1 ? t('wordPrint.removePair', '대립쌍 빼기') : t('wordPrint.removeWord', '단어 빼기'), ariaLabel: cell.length > 1 ? t('wordPrint.removePair', '대립쌍 빼기') : t('wordPrint.removeWord', '단어 빼기'), onClick: () => onRemoveCell(i) }) }))] })) : (onActivateCell && (_jsx("div", { style: counterScale, children: _jsx(Button, { htmlType: "button", size:
|
|
611
|
+
colloquialLabel: e.colloquialPronunciation, homonum: e.homonum, showWord: show.word, showImage: show.image, showPronunciation: show.pron, showColloquial: show.colloq, showCaption: show.caption, buttonSize: buttonSize })] }, wi))), scoring && renderScore(i, cell.map(e => e.word).join(' / ')), onRemoveCell && (_jsx("div", { className: withLegacy("word-table__card-close"), children: _jsx(Button, { htmlType: "button", size: buttonSize, type: "dot", icon: "x", variant: "transparent-lightGray", useBorder: false, showTooltipInfo: cell.length > 1 ? t('wordPrint.removePair', '대립쌍 빼기') : t('wordPrint.removeWord', '단어 빼기'), ariaLabel: cell.length > 1 ? t('wordPrint.removePair', '대립쌍 빼기') : t('wordPrint.removeWord', '단어 빼기'), onClick: () => onRemoveCell(i) }) }))] })) : (onActivateCell && (_jsx("div", { style: counterScale, children: _jsx(Button, { htmlType: "button", size: buttonSize, type: "dot", icon: "plus", variant: "default", ariaLabel: t('wordTable.addWord', '추가하기'), showTooltipInfo: t('wordTable.addWord', '추가하기'), onClick: () => onActivateCell(i) }) }))) }, i))) })) : (_jsxs(_Fragment, { children: [hasBase && baseItem && (
|
|
574
612
|
/* 걸치는 자리는 양쪽이 같은 식이다 — 가로면 왼쪽 `half.cols` 열 × 전체 `half.rows` 줄,
|
|
575
613
|
세로면 전체 `half.cols` 열 × 위 `half.rows` 줄. 둘 다 `1 / span` 으로 같게 적힌다. */
|
|
576
614
|
_jsx("div", { className: withLegacy("word-table__card word-table__card--base"), style: {
|
|
@@ -578,9 +616,9 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
578
616
|
gridRow: `1 / span ${half.rows}`,
|
|
579
617
|
/* 머리 칸과 나머지 절반을 가르는 점선 — 가로면 오른쪽, 세로면 아래쪽 */
|
|
580
618
|
...dotDashStyle(0, orientation === 'landscape' ? 2 : 1, orientation === 'landscape' ? 1 : 2, cutLine),
|
|
581
|
-
}, children: (baseItem.words ?? []).map((w, wi) => (_jsxs(Fragment, { children: [wi > 0 && _jsx("div", { className: withLegacy("word-table__pair-divider") }), _jsx(WordCell, { outerScale: scale, label: w.label, subLabel: w.subLabel, colloquialLabel: w.colloquialLabel, captionLabel: w.captionLabel, captionBadge: w.captionBadge, homonum: w.homonum, showWord: baseShow.word, showImage: baseShow.image, showPronunciation: baseShow.pron, showColloquial: baseShow.colloq, buttonSize: buttonSize, wordInfo: (w.grade || w.syllables != null || w.pos || w.wordType) ? { grade: w.grade, syllables: w.syllables, pos: w.pos, wordType: w.wordType } : undefined })] }, wi))) })), (items ?? []).map((item, index) => (_jsxs("div", { "data-wordtable-cell": onReorder ? index : undefined, className: withLegacy(`word-table__card${onReorder ? ' word-table__card--draggable' : ''}${dragOver === index ? ' word-table__card--drag-over' : ''}${dragging === index ? ' word-table__card--dragging' : ''}`), style: dotDashStyle(index, itemCols, itemRows, cutLine), draggable: !!onReorder, onPointerDown: onReorder ? (e) => longPressDrag(e, index) : undefined, onKeyDown: onReorder ? (e) => moveByKey(e, index) : undefined, onDragStart: onReorder ? () => { dragIndex.current = index; } : undefined, onDragOver: onReorder ? (e) => { e.preventDefault(); setDragOver(index); } : undefined, onDragLeave: onReorder ? () => setDragOver(null) : undefined, onDrop: onReorder ? (e) => { e.preventDefault(); if (dragIndex.current !== null && dragIndex.current !== index) {
|
|
619
|
+
}, children: (baseItem.words ?? []).map((w, wi) => (_jsxs(Fragment, { children: [wi > 0 && _jsx("div", { className: withLegacy("word-table__pair-divider") }), _jsx(WordCell, { outerScale: scale, label: w.label, subLabel: w.subLabel, colloquialLabel: w.colloquialLabel, captionLabel: w.captionLabel, captionBadge: w.captionBadge, homonum: w.homonum, showWord: baseShow.word, showImage: baseShow.image, showPronunciation: baseShow.pron, showColloquial: baseShow.colloq, showCaption: baseShow.caption, buttonSize: buttonSize, wordInfo: (w.grade || w.syllables != null || w.pos || w.wordType) ? { grade: w.grade, syllables: w.syllables, pos: w.pos, wordType: w.wordType } : undefined })] }, wi))) })), (items ?? []).map((item, index) => (_jsxs("div", { "data-wordtable-cell": onReorder ? index : undefined, className: withLegacy(`word-table__card${onReorder ? ' word-table__card--draggable' : ''}${dragOver === index ? ' word-table__card--drag-over' : ''}${dragging === index ? ' word-table__card--dragging' : ''}`), style: dotDashStyle(index, itemCols, itemRows, cutLine), draggable: !!onReorder, onPointerDown: onReorder ? (e) => longPressDrag(e, index) : undefined, onKeyDown: onReorder ? (e) => moveByKey(e, index) : undefined, onDragStart: onReorder ? () => { dragIndex.current = index; } : undefined, onDragOver: onReorder ? (e) => { e.preventDefault(); setDragOver(index); } : undefined, onDragLeave: onReorder ? () => setDragOver(null) : undefined, onDrop: onReorder ? (e) => { e.preventDefault(); if (dragIndex.current !== null && dragIndex.current !== index) {
|
|
582
620
|
onReorder(dragIndex.current, index);
|
|
583
|
-
} ; dragIndex.current = null; setDragOver(null); } : undefined, onDragEnd: onReorder ? () => { dragIndex.current = null; setDragOver(null); } : undefined, children: [(item.words ?? []).map((w, i) => (_jsxs(Fragment, { children: [i > 0 && _jsx("div", { className: withLegacy("word-table__pair-divider") }), _jsx(WordCell, { outerScale: scale, label: w.label, subLabel: w.subLabel, colloquialLabel: w.colloquialLabel, captionLabel: w.captionLabel, captionBadge: w.captionBadge, homonum: w.homonum, showWord: show.word, showImage: show.image, showPronunciation: show.pron, showColloquial: show.colloq, buttonSize: buttonSize, wordInfo: (w.grade || w.syllables != null || w.pos || w.wordType) ? { grade: w.grade, syllables: w.syllables, pos: w.pos, wordType: w.wordType } : undefined })] }, i))), scoring && renderScore(index, (item.words ?? []).map(w => w.label).join(' / ')), (renderCellAction || onRemoveItem || onReorder) && (
|
|
621
|
+
} ; dragIndex.current = null; setDragOver(null); } : undefined, onDragEnd: onReorder ? () => { dragIndex.current = null; setDragOver(null); } : undefined, children: [(item.words ?? []).map((w, i) => (_jsxs(Fragment, { children: [i > 0 && _jsx("div", { className: withLegacy("word-table__pair-divider") }), _jsx(WordCell, { outerScale: scale, label: w.label, subLabel: w.subLabel, colloquialLabel: w.colloquialLabel, captionLabel: w.captionLabel, captionBadge: w.captionBadge, homonum: w.homonum, showWord: show.word, showImage: show.image, showPronunciation: show.pron, showColloquial: show.colloq, showCaption: show.caption, buttonSize: buttonSize, wordInfo: (w.grade || w.syllables != null || w.pos || w.wordType) ? { grade: w.grade, syllables: w.syllables, pos: w.pos, wordType: w.wordType } : undefined })] }, i))), scoring && renderScore(index, (item.words ?? []).map(w => w.label).join(' / ')), (renderCellAction || onRemoveItem || onReorder) && (
|
|
584
622
|
/* **오른쪽 기둥** — 빼기 → 부르는 쪽이 얹은 것 → 옮기기 손잡이 차례로 쌓인다
|
|
585
623
|
(말귀 청 (331), 2026-10-28). 전에는 빼기와 얹은 것만 **한 줄**로 서고
|
|
586
624
|
손잡이는 왼쪽 위에 따로 섰다 — 재생 단추와 **같은 자리라 겹쳤다.**
|
|
@@ -601,7 +639,7 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
601
639
|
ariaLabel: t('wordTable.reorder.handle', {
|
|
602
640
|
word: (item.words ?? []).map(w => w.label).join(' / '),
|
|
603
641
|
defaultValue: '{{word}} 순서 바꾸기 (Alt + 화살표)',
|
|
604
|
-
}) }) }))] }))] }, index))), Array.from({ length: Math.max(0, itemCols * itemRows - (items?.length ?? 0)) }).map((_, i) => {
|
|
642
|
+
}) }) }))] }))] }, cellKeys ? cellKeys[index] : index))), Array.from({ length: Math.max(0, itemCols * itemRows - (items?.length ?? 0)) }).map((_, i) => {
|
|
605
643
|
const isWithinCount = (items?.length ?? 0) + i < (addableCount ?? cellCount);
|
|
606
644
|
return (_jsx("div", { className: withLegacy("word-table__card word-table__card--filler"), children: showFillerAdd && onActivateCell && isWithinCount && (
|
|
607
645
|
/* **점 단추 하나**(사장님 지시 2026-10-28: *"Button dot size 40 베리언트
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **줄 하나의 칸들을 열마다 가장 넓은 값으로** — 자식 번호가 아니라 **격자 번호**로 센다
|
|
3
|
+
* (말귀 청 (215), 2026-10-28).
|
|
4
|
+
*
|
|
5
|
+
* `row.children[i]` 를 그 열의 칸으로 보던 자였다. 그것은 *몇 번째 자식*이지 *몇 번째 열*이
|
|
6
|
+
* 아니다 — 여러 열을 덮는 칸(`span`)이 하나라도 있으면 둘이 갈라진다. 말귀 실측: 칸
|
|
7
|
+
* 여섯짜리 고객 표에 초대 줄(자식 넷, 첫 칸이 앞 셋을 덮음)을 하나 넣고 '칸 너비 초기화' 를
|
|
8
|
+
* 누르니 **첫 열이 94px → 254px(2.7배)** 로 부풀고, 부푼 만큼을 남은 유동 열들이 비율대로
|
|
9
|
+
* 토해 냈다 — **한 줄이 표 전체의 열 폭을 다시 짰다.**
|
|
10
|
+
*
|
|
11
|
+
* 여기 둔 것은 **재는 규칙만**이다. DOM 에서 폭과 덮는 수를 읽는 일은 `Table` 이 하고, 이
|
|
12
|
+
* 함수는 숫자만 받는다 — 그래야 격자를 못 세우는 자리에서도 규칙을 그대로 셀 수 있다.
|
|
13
|
+
*/
|
|
14
|
+
/** 줄 안의 칸 하나 — 잰 폭과 덮는 열 수 */
|
|
15
|
+
export interface MeasuredCell {
|
|
16
|
+
width: number;
|
|
17
|
+
/** 몇 열을 덮나. 1 이거나 없으면 한 열 */
|
|
18
|
+
span?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 줄들을 훑어 **열마다 가장 넓은 값**을 낸다.
|
|
22
|
+
*
|
|
23
|
+
* 덮는 칸의 폭은 **덮은 열들에 나눠 넣는다** — 안 넣으면 그 줄만 있는 표에서 열이 최소
|
|
24
|
+
* 폭으로 가라앉는다. 나눌 때 **열 사이 틈**을 먼저 뺀다(안 빼면 덮은 열마다 틈만큼 넓게
|
|
25
|
+
* 잡힌다). 나눈 값이 그 열의 제 글자보다 좁으면 넓은 쪽이 남으므로, **좁은 덮는 칸이 열을
|
|
26
|
+
* 줄이는 일은 없다.**
|
|
27
|
+
*
|
|
28
|
+
* 칸이 열보다 많으면 넘는 칸은 버린다 — 줄 하나가 표의 열 수를 바꾸지는 못한다. 덮는 수가
|
|
29
|
+
* 남은 열을 넘으면 **남은 열로 조인다**(브라우저가 그렇게 세우므로, 적힌 수로 나누면 열마다
|
|
30
|
+
* 받는 몫이 모자라게 잡힌다).
|
|
31
|
+
*
|
|
32
|
+
* @param rows 줄마다 칸 목록. 머리 줄도 한 줄로 넣는다.
|
|
33
|
+
* @param columnCount 표의 열 수
|
|
34
|
+
* @param columnGap 열 사이 틈(px). 없으면 0
|
|
35
|
+
*/
|
|
36
|
+
export declare function widestPerColumn(rows: readonly (readonly MeasuredCell[])[], columnCount: number, columnGap?: number): number[];
|
|
37
|
+
/** 덮는 수를 믿을 수 있는 정수로 — 없거나 이상한 값은 1 */
|
|
38
|
+
export declare function normalizeSpan(span: unknown): number;
|
|
39
|
+
/**
|
|
40
|
+
* 선 격자에서 덮는 수를 읽는다 — `getComputedStyle(cell)` 의 `gridColumnStart`/`End` 꼴을 받는다.
|
|
41
|
+
*
|
|
42
|
+
* **`aria-colspan` 만 믿지 않는다.** 그것은 코어가 `span` 프롭을 받아 지을 때만 붙으므로,
|
|
43
|
+
* 부르는 쪽이 `style={{ gridColumn: 'span 3' }}` 로 손수 적은 줄은 못 본다. 격자는 둘 다
|
|
44
|
+
* 똑같이 서므로 **선 격자**를 읽는 쪽이 둘을 다 본다.
|
|
45
|
+
*
|
|
46
|
+
* 브라우저에 따라 `span 3` · `span 3 / auto` · `auto / span 3` 으로 나오므로 양쪽을 다 본다.
|
|
47
|
+
*/
|
|
48
|
+
export declare function spanFromGridStyle(start?: string | null, end?: string | null): number;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **줄 하나의 칸들을 열마다 가장 넓은 값으로** — 자식 번호가 아니라 **격자 번호**로 센다
|
|
3
|
+
* (말귀 청 (215), 2026-10-28).
|
|
4
|
+
*
|
|
5
|
+
* `row.children[i]` 를 그 열의 칸으로 보던 자였다. 그것은 *몇 번째 자식*이지 *몇 번째 열*이
|
|
6
|
+
* 아니다 — 여러 열을 덮는 칸(`span`)이 하나라도 있으면 둘이 갈라진다. 말귀 실측: 칸
|
|
7
|
+
* 여섯짜리 고객 표에 초대 줄(자식 넷, 첫 칸이 앞 셋을 덮음)을 하나 넣고 '칸 너비 초기화' 를
|
|
8
|
+
* 누르니 **첫 열이 94px → 254px(2.7배)** 로 부풀고, 부푼 만큼을 남은 유동 열들이 비율대로
|
|
9
|
+
* 토해 냈다 — **한 줄이 표 전체의 열 폭을 다시 짰다.**
|
|
10
|
+
*
|
|
11
|
+
* 여기 둔 것은 **재는 규칙만**이다. DOM 에서 폭과 덮는 수를 읽는 일은 `Table` 이 하고, 이
|
|
12
|
+
* 함수는 숫자만 받는다 — 그래야 격자를 못 세우는 자리에서도 규칙을 그대로 셀 수 있다.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* 줄들을 훑어 **열마다 가장 넓은 값**을 낸다.
|
|
16
|
+
*
|
|
17
|
+
* 덮는 칸의 폭은 **덮은 열들에 나눠 넣는다** — 안 넣으면 그 줄만 있는 표에서 열이 최소
|
|
18
|
+
* 폭으로 가라앉는다. 나눌 때 **열 사이 틈**을 먼저 뺀다(안 빼면 덮은 열마다 틈만큼 넓게
|
|
19
|
+
* 잡힌다). 나눈 값이 그 열의 제 글자보다 좁으면 넓은 쪽이 남으므로, **좁은 덮는 칸이 열을
|
|
20
|
+
* 줄이는 일은 없다.**
|
|
21
|
+
*
|
|
22
|
+
* 칸이 열보다 많으면 넘는 칸은 버린다 — 줄 하나가 표의 열 수를 바꾸지는 못한다. 덮는 수가
|
|
23
|
+
* 남은 열을 넘으면 **남은 열로 조인다**(브라우저가 그렇게 세우므로, 적힌 수로 나누면 열마다
|
|
24
|
+
* 받는 몫이 모자라게 잡힌다).
|
|
25
|
+
*
|
|
26
|
+
* @param rows 줄마다 칸 목록. 머리 줄도 한 줄로 넣는다.
|
|
27
|
+
* @param columnCount 표의 열 수
|
|
28
|
+
* @param columnGap 열 사이 틈(px). 없으면 0
|
|
29
|
+
*/
|
|
30
|
+
export function widestPerColumn(rows, columnCount, columnGap = 0) {
|
|
31
|
+
const widest = Array.from({ length: Math.max(0, columnCount) }, () => 0);
|
|
32
|
+
for (const row of rows) {
|
|
33
|
+
let cursor = 0;
|
|
34
|
+
for (const cell of row) {
|
|
35
|
+
if (cursor >= widest.length)
|
|
36
|
+
break;
|
|
37
|
+
const declared = normalizeSpan(cell.span);
|
|
38
|
+
/* **남은 열로 조인다** — 브라우저도 그렇게 한다. 열이 셋인 격자에서 `span 5` 인 칸은
|
|
39
|
+
남은 두 열만 덮으므로, 적힌 5 로 나누면 열마다 받는 몫이 모자라게 잡힌다
|
|
40
|
+
(실측으로 걸렸다: 300px 짜리가 열마다 60 씩 받아 둘이 합쳐 120 밖에 못 됐다). */
|
|
41
|
+
const span = Math.min(declared, widest.length - cursor);
|
|
42
|
+
if (span === 1) {
|
|
43
|
+
widest[cursor] = Math.max(widest[cursor], cell.width);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
/* 덮은 열 하나가 받을 몫 — 사이 틈을 뺀 뒤 고르게 나눈다 */
|
|
47
|
+
const per = Math.max(0, (cell.width - columnGap * (span - 1)) / span);
|
|
48
|
+
for (let k = cursor; k < cursor + span; k++) {
|
|
49
|
+
widest[k] = Math.max(widest[k], per);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
cursor += span;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return widest;
|
|
56
|
+
}
|
|
57
|
+
/** 덮는 수를 믿을 수 있는 정수로 — 없거나 이상한 값은 1 */
|
|
58
|
+
export function normalizeSpan(span) {
|
|
59
|
+
const n = typeof span === 'number' ? span : parseInt(String(span ?? ''), 10);
|
|
60
|
+
return Number.isFinite(n) && n >= 1 ? Math.floor(n) : 1;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 선 격자에서 덮는 수를 읽는다 — `getComputedStyle(cell)` 의 `gridColumnStart`/`End` 꼴을 받는다.
|
|
64
|
+
*
|
|
65
|
+
* **`aria-colspan` 만 믿지 않는다.** 그것은 코어가 `span` 프롭을 받아 지을 때만 붙으므로,
|
|
66
|
+
* 부르는 쪽이 `style={{ gridColumn: 'span 3' }}` 로 손수 적은 줄은 못 본다. 격자는 둘 다
|
|
67
|
+
* 똑같이 서므로 **선 격자**를 읽는 쪽이 둘을 다 본다.
|
|
68
|
+
*
|
|
69
|
+
* 브라우저에 따라 `span 3` · `span 3 / auto` · `auto / span 3` 으로 나오므로 양쪽을 다 본다.
|
|
70
|
+
*/
|
|
71
|
+
export function spanFromGridStyle(start, end) {
|
|
72
|
+
const m = /span\s+(\d+)/.exec(`${start ?? ''} ${end ?? ''}`);
|
|
73
|
+
return m ? normalizeSpan(parseInt(m[1], 10)) : 1;
|
|
74
|
+
}
|
|
@@ -18,7 +18,7 @@ export type WordTableOrientation = 'landscape' | 'portrait';
|
|
|
18
18
|
*
|
|
19
19
|
* @public
|
|
20
20
|
*/
|
|
21
|
-
export type WordTableContentType = 'word' | 'image' | 'standardPron' | 'colloquialPron';
|
|
21
|
+
export type WordTableContentType = 'word' | 'image' | 'standardPron' | 'colloquialPron' | 'caption';
|
|
22
22
|
/** 칸 사이 선 — **코드다.** 보일 글은 사전(`wordTable.filter.show`·`.dotted`·`.corner`·`.hide`). @public */
|
|
23
23
|
export type WordTableCutLine = 'show' | 'dashed' | 'corner' | 'hide';
|
|
24
24
|
/** 페이지 분할 시 종이 안에 찍는 페이지 번호 위치 — 'none'이면 미표시 */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HEAD 로 파일이 있나 물었을 때, **"없다" 를 받은 것인가.**
|
|
3
|
+
*
|
|
4
|
+
* 그림·음원 확인은 답을 캐시에 담는데, **담아도 되는 답과 안 되는 답**이 갈린다.
|
|
5
|
+
* 2xx(있다)와 여기서 참을 주는 상태(없다)만 담는다. 나머지는 *확인이 안 된 것*이라
|
|
6
|
+
* 담지 않는다 — 망 끊김·타임아웃·권한 오류(401·403)·5xx 를 담으면 한 번의 장애가
|
|
7
|
+
* 그 낱말을 세션 내내 '없음' 으로 못 박아, '그림 있음'·'음성 있음' 거르개에서
|
|
8
|
+
* 통째로 빠진다.
|
|
9
|
+
*
|
|
10
|
+
* **400 이 여기 있는 까닭**(말귀 청 (336), 2026-10-28). 저장소가 *없는 파일* 에
|
|
11
|
+
* 404 가 아니라 **400** 을 준다. 400 은 404 와 410 어느 쪽도 아니라 캐시에
|
|
12
|
+
* **영영 안 담겼고**, 그래서 표가 다시 그려질 때마다 같은 글자를 또 물었다 —
|
|
13
|
+
* 스물한 칸짜리 표에서 ✕ 한 번에 HEAD 가 **스물한 번** 나갔다(말귀 실측).
|
|
14
|
+
* 400 은 *답을 받은 것*이지 망이 끊긴 것이 아니다.
|
|
15
|
+
*
|
|
16
|
+
* **대가도 적어 둔다** — 리졸버가 설정이 덜 선 때에 **엉뚱한 주소**를 지어 내면
|
|
17
|
+
* 그 400 까지 담긴다. 그 낱말은 캐시를 비울 때까지 '없음' 으로 눌러앉는다
|
|
18
|
+
* (`clearImageExistenceCache`·`clearAudioExistsCache` 가 비우는 자리다).
|
|
19
|
+
* 주소를 때에 따라 다르게 짓는 리졸버라면 표를 그리기 전에 그 때를 지나 둬야 한다.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isDefiniteAbsence(status: number): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HEAD 로 파일이 있나 물었을 때, **"없다" 를 받은 것인가.**
|
|
3
|
+
*
|
|
4
|
+
* 그림·음원 확인은 답을 캐시에 담는데, **담아도 되는 답과 안 되는 답**이 갈린다.
|
|
5
|
+
* 2xx(있다)와 여기서 참을 주는 상태(없다)만 담는다. 나머지는 *확인이 안 된 것*이라
|
|
6
|
+
* 담지 않는다 — 망 끊김·타임아웃·권한 오류(401·403)·5xx 를 담으면 한 번의 장애가
|
|
7
|
+
* 그 낱말을 세션 내내 '없음' 으로 못 박아, '그림 있음'·'음성 있음' 거르개에서
|
|
8
|
+
* 통째로 빠진다.
|
|
9
|
+
*
|
|
10
|
+
* **400 이 여기 있는 까닭**(말귀 청 (336), 2026-10-28). 저장소가 *없는 파일* 에
|
|
11
|
+
* 404 가 아니라 **400** 을 준다. 400 은 404 와 410 어느 쪽도 아니라 캐시에
|
|
12
|
+
* **영영 안 담겼고**, 그래서 표가 다시 그려질 때마다 같은 글자를 또 물었다 —
|
|
13
|
+
* 스물한 칸짜리 표에서 ✕ 한 번에 HEAD 가 **스물한 번** 나갔다(말귀 실측).
|
|
14
|
+
* 400 은 *답을 받은 것*이지 망이 끊긴 것이 아니다.
|
|
15
|
+
*
|
|
16
|
+
* **대가도 적어 둔다** — 리졸버가 설정이 덜 선 때에 **엉뚱한 주소**를 지어 내면
|
|
17
|
+
* 그 400 까지 담긴다. 그 낱말은 캐시를 비울 때까지 '없음' 으로 눌러앉는다
|
|
18
|
+
* (`clearImageExistenceCache`·`clearAudioExistsCache` 가 비우는 자리다).
|
|
19
|
+
* 주소를 때에 따라 다르게 짓는 리졸버라면 표를 그리기 전에 그 때를 지나 둬야 한다.
|
|
20
|
+
*/
|
|
21
|
+
export function isDefiniteAbsence(status) {
|
|
22
|
+
return status === 400 || status === 404 || status === 410;
|
|
23
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { timeoutSignal } from './timeoutSignal';
|
|
2
|
+
import { isDefiniteAbsence } from './headProbeStatus';
|
|
2
3
|
const GLOBAL_KEY = '__ihab_core_image_config__';
|
|
3
4
|
/** @public */
|
|
4
5
|
export function configureImageResolver(resolver) {
|
|
@@ -95,7 +96,7 @@ async function probeImageExists(word, homonum, force = false) {
|
|
|
95
96
|
// 타임아웃 없으면 HEAD 요청 하나가 응답 없이 걸릴 때 이 확인을 기다리는
|
|
96
97
|
// 검색 버튼(이미지 있음 필터)이 영구 비활성화된다
|
|
97
98
|
/* **확인이 안 된 것은 캐시하지 않는다.** 망 끊김·타임아웃·권한 오류·5xx 는 이미지가 없다는 증거가 아니다.
|
|
98
|
-
있음(2xx)과 명시적 없음(
|
|
99
|
+
있음(2xx)과 명시적 없음(`isDefiniteAbsence`)만 담는다 — 어느 상태가 '없음' 인지는 그 함수의 머리말에 적었다. */
|
|
99
100
|
let request;
|
|
100
101
|
try {
|
|
101
102
|
request = fetch(url, { method: 'HEAD', signal: timeoutSignal(8000) });
|
|
@@ -104,7 +105,7 @@ async function probeImageExists(word, homonum, force = false) {
|
|
|
104
105
|
return false;
|
|
105
106
|
}
|
|
106
107
|
const p = request
|
|
107
|
-
.then(res => (res.ok ? true : res.status
|
|
108
|
+
.then(res => (res.ok ? true : isDefiniteAbsence(res.status) ? false : null), () => null)
|
|
108
109
|
.then(ok => {
|
|
109
110
|
// 강제 재확인이 앞 요청을 대체했거나 캐시를 비웠다면 늦은 응답으로 새 값을 덮지 않는다.
|
|
110
111
|
if (inflight.get(k) !== p)
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
import { timeoutSignal } from './timeoutSignal';
|
|
24
|
+
import { isDefiniteAbsence } from './headProbeStatus';
|
|
24
25
|
const GLOBAL_KEY = '__ihab_core_tts_config__';
|
|
25
26
|
/**
|
|
26
27
|
* TTS URL 리졸버를 전역으로 설정합니다.
|
|
@@ -76,7 +77,7 @@ export async function checkAudioExists(word) {
|
|
|
76
77
|
return audioExistsCache.get(url);
|
|
77
78
|
// 타임아웃 없으면 HEAD 요청 하나가 응답 없이 걸릴 때 이 확인을 기다리는
|
|
78
79
|
// 검색 버튼(음성 있음 필터)이 영구 비활성화된다
|
|
79
|
-
// 성공(2xx)과 명시적 부재(
|
|
80
|
+
// 성공(2xx)과 명시적 부재(`isDefiniteAbsence`)만 캐시에 남긴다. 권한 오류·네트워크 실패·타임아웃·5xx 까지 캐시하면
|
|
80
81
|
// 한 번의 통신 끊김·서버 장애가 그 단어를 세션 내내 '음성 없음'으로 고정해, '음성 있음' 필터에서
|
|
81
82
|
// 통째로 빠진다. 실패는 지워서 다음 호출이 다시 물어보게 한다 — 단 **이 요청이 담은 칸일 때만**:
|
|
82
83
|
// clearAudioExistsCache() 뒤 새로 담긴 확인을 늦게 끝난 옛 요청이 지우면 같은 주소를 또 묻는다.
|
|
@@ -93,7 +94,7 @@ export async function checkAudioExists(word) {
|
|
|
93
94
|
return false;
|
|
94
95
|
}
|
|
95
96
|
const promise = request
|
|
96
|
-
.then(res => (res.ok ? true : res.status
|
|
97
|
+
.then(res => (res.ok ? true : isDefiniteAbsence(res.status) ? false : onUnconfirmed()), onUnconfirmed);
|
|
97
98
|
audioExistsCache.set(url, promise);
|
|
98
99
|
return promise;
|
|
99
100
|
}
|