@sigma-studio/editor 0.467.1 → 0.468.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/README.md +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +481 -476
- package/dist/styles.css +1 -1
- package/dist/tex-import.d.ts +14 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ SigmaDoc教材のWeb編集をReactサイトへ組み込むEditorパッケージ
|
|
|
14
14
|
- `SigmaDocViewer`: 問題・解答・コメントの出し分け、問題番号上書き、高さ制限を持つRead専用表示
|
|
15
15
|
- `SigmaDocEditor`: デスクトップ版と同じ編集UIを組み込み、`onChange` / `onSave`へ完全なSigmaDocumentを返すcontrolled editor
|
|
16
16
|
- `parseSigmaDocument`: 外部JSONを正規スキーマで検証
|
|
17
|
+
- `importTexDocument` / `importTexProblem`: TeX文書、または問題文・解説の別フィールドをSigmaDocへ変換
|
|
17
18
|
|
|
18
19
|
教材一覧、認証、データ取得、永続化、AI/MCP、Electron API、デスクトップ専用の教材import機能は含みません。これらは組み込み先のアプリが担当します。
|
|
19
20
|
|
|
@@ -74,6 +75,28 @@ export function AnswerPage({ document }: { document: SigmaDocument }) {
|
|
|
74
75
|
|
|
75
76
|
`visibleParts`は`problem`、`solution`、`comments`を自由に組み合わせられます。未指定なら完全版です。`maxHeightPx`を超えた場合だけFadeと「すべて表示」を出します。
|
|
76
77
|
|
|
78
|
+
## TeXの問題を取り込む
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { importTexDocument, importTexProblem } from "@sigma-studio/editor";
|
|
82
|
+
|
|
83
|
+
// .texファイル全体、または本文だけのTeX
|
|
84
|
+
const document = importTexDocument(texSource, "入試問題.tex");
|
|
85
|
+
|
|
86
|
+
// 問題投稿フォームなどの、別々に管理された問題文と解説
|
|
87
|
+
const problem = importTexProblem({
|
|
88
|
+
title: "二次関数の最小値",
|
|
89
|
+
preamble: String.raw`\providecommand{\sq}[1]{#1^2}`,
|
|
90
|
+
prompt: String.raw`$f(x)=\sq{x}+1$ の最小値を求めよ。`,
|
|
91
|
+
solution: String.raw`$\sq{x}\geq0$ より、最小値は $1$。`,
|
|
92
|
+
tags: ["数と式"],
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
返り値を `SigmaDocEditor.document` または `SigmaDocViewer.document` に渡せます。変換ごとに新しい文書IDを発行します。`prompt` と `solution`、任意の `hints` はSigmaDocの問題エリアに分かれ、マクロは同じ問題内で共有されます。変換時のエラーは例外として返すため、呼び出し元で表示してください。
|
|
97
|
+
|
|
98
|
+
受験数学研究所のTeXに使われる必須引数マクロ、`enumerate` の数字付き小問、`label=(\arabic*)`、`start=`、`\item[(1)]`、別行数式、`aligned` / `cases` / 行列に対応します。任意のLaTeXパッケージは実行しません。TikZや未対応の表・環境は、描画の代わりに編集可能なTeXソースとして残します。
|
|
99
|
+
|
|
77
100
|
## Editorを使う
|
|
78
101
|
|
|
79
102
|
```tsx
|
package/dist/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import "./styles.css";
|
|
|
2
2
|
export { SigmaDocEditor, type SigmaDocEditorChange, type SigmaDocEditorHandle, type SigmaDocEditorProps, type SigmaDocEditorSaveState, } from "./SigmaDocEditor.js";
|
|
3
3
|
export { SigmaDocParseError, SigmaDocViewer, parseSigmaDocument, type SigmaDocViewerError, type SigmaDocViewerPart, type SigmaDocViewerProps, } from "@sigma-studio/viewer";
|
|
4
4
|
export type * from "@sigma-studio/viewer";
|
|
5
|
+
export { importTexDocument, importTexProblem, type TexProblemInput } from "./tex-import.js";
|