myst-demo 0.5.6 → 0.5.8
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/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +1 -4
- package/package.json +27 -26
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -281
- package/dist/esm/index.d.ts +0 -16
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -16
- package/dist/types/index.d.ts.map +0 -1
- /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAyK1D,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,eAAe,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7E,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAoMA;AAED,eAAO,MAAM,gBAAgB,EAAE,YAE9B,CAAC"}
|
|
@@ -16,10 +16,7 @@ import { ReferencesProvider } from '@myst-theme/providers';
|
|
|
16
16
|
import { CopyIcon, CodeBlock, MyST } from 'myst-to-react';
|
|
17
17
|
import { useEffect, useRef, useState } from 'react';
|
|
18
18
|
import classnames from 'classnames';
|
|
19
|
-
import ExclamationTriangleIcon from '@heroicons/react/24/outline
|
|
20
|
-
import ExclamationCircleIcon from '@heroicons/react/24/outline/ExclamationCircleIcon';
|
|
21
|
-
import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon';
|
|
22
|
-
import ArrowDownTrayIcon from '@heroicons/react/24/outline/ArrowDownTrayIcon';
|
|
19
|
+
import { ExclamationTriangleIcon, ExclamationCircleIcon, InformationCircleIcon, ArrowDownTrayIcon, } from '@heroicons/react/24/outline';
|
|
23
20
|
function downloadBlob(filename, blob) {
|
|
24
21
|
const a = document.createElement('a');
|
|
25
22
|
const url = URL.createObjectURL(blob);
|
package/package.json
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "myst-demo",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"types": "dist/
|
|
3
|
+
"version": "0.5.8",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=16"
|
|
12
|
+
},
|
|
10
13
|
"license": "MIT",
|
|
11
14
|
"scripts": {
|
|
12
15
|
"clean": "rimraf dist",
|
|
13
|
-
"lint": "eslint \"src/**/*.ts*\" \"src/**/*.tsx\" -c ./.eslintrc.
|
|
16
|
+
"lint": "eslint \"src/**/*.ts*\" \"src/**/*.tsx\" -c ./.eslintrc.cjs",
|
|
14
17
|
"lint:format": "prettier --check \"src/**/*.{ts,tsx,md}\"",
|
|
15
18
|
"dev": "npm-run-all --parallel \"build:* -- --watch\"",
|
|
16
|
-
"build:
|
|
17
|
-
"build
|
|
18
|
-
"build:types": "tsc --declaration --emitDeclarationOnly --declarationMap --outDir dist/types",
|
|
19
|
-
"build": "npm-run-all -l clean -p build:cjs build:esm build:types"
|
|
19
|
+
"build:esm": "tsc",
|
|
20
|
+
"build": "npm-run-all -l clean -p build:esm"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"@heroicons/react": "^2.0.18",
|
|
23
24
|
"classnames": "^2.3.2",
|
|
24
25
|
"js-yaml": "^4.1.0",
|
|
25
|
-
"myst-common": "^1.1.
|
|
26
|
-
"myst-config": "^1.1.
|
|
27
|
-
"myst-directives": "^1.0.
|
|
28
|
-
"myst-ext-card": "^1.0.
|
|
29
|
-
"myst-ext-exercise": "^1.0.
|
|
30
|
-
"myst-ext-grid": "^1.0.
|
|
31
|
-
"myst-ext-proof": "^1.0.
|
|
32
|
-
"myst-ext-tabs": "^1.0.
|
|
33
|
-
"myst-frontmatter": "^1.1.
|
|
34
|
-
"myst-parser": "^1.0.
|
|
26
|
+
"myst-common": "^1.1.8",
|
|
27
|
+
"myst-config": "^1.1.8",
|
|
28
|
+
"myst-directives": "^1.0.8",
|
|
29
|
+
"myst-ext-card": "^1.0.4",
|
|
30
|
+
"myst-ext-exercise": "^1.0.4",
|
|
31
|
+
"myst-ext-grid": "^1.0.4",
|
|
32
|
+
"myst-ext-proof": "^1.0.4",
|
|
33
|
+
"myst-ext-tabs": "^1.0.4",
|
|
34
|
+
"myst-frontmatter": "^1.1.8",
|
|
35
|
+
"myst-parser": "^1.0.8",
|
|
35
36
|
"myst-spec": "^0.0.4",
|
|
36
|
-
"myst-to-docx": "^1.0.
|
|
37
|
-
"myst-to-html": "^1.0.
|
|
38
|
-
"myst-to-jats": "^1.0.
|
|
39
|
-
"myst-to-react": "^0.5.
|
|
40
|
-
"myst-to-tex": "^1.0.
|
|
41
|
-
"myst-to-typst": "^0.0.
|
|
42
|
-
"myst-transforms": "^1.1.
|
|
37
|
+
"myst-to-docx": "^1.0.5",
|
|
38
|
+
"myst-to-html": "^1.0.8",
|
|
39
|
+
"myst-to-jats": "^1.0.13",
|
|
40
|
+
"myst-to-react": "^0.5.8",
|
|
41
|
+
"myst-to-tex": "^1.0.7",
|
|
42
|
+
"myst-to-typst": "^0.0.5",
|
|
43
|
+
"myst-transforms": "^1.1.2",
|
|
43
44
|
"unified": "^10.1.2",
|
|
44
45
|
"unist-util-visit": "^4.1.2",
|
|
45
46
|
"vfile": "^5.3.7",
|
package/dist/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAuK1D,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,eAAe,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7E,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAoMA;AAED,eAAO,MAAM,gBAAgB,EAAE,YAE9B,CAAC"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.MystDemoRenderer = exports.MySTRenderer = void 0;
|
|
39
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
40
|
-
const vfile_1 = require("vfile");
|
|
41
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
42
|
-
const myst_spec_ext_1 = require("myst-spec-ext");
|
|
43
|
-
const myst_frontmatter_1 = require("myst-frontmatter");
|
|
44
|
-
const providers_1 = require("@myst-theme/providers");
|
|
45
|
-
const myst_to_react_1 = require("myst-to-react");
|
|
46
|
-
const react_1 = require("react");
|
|
47
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
48
|
-
const ExclamationTriangleIcon_1 = __importDefault(require("@heroicons/react/24/outline/ExclamationTriangleIcon"));
|
|
49
|
-
const ExclamationCircleIcon_1 = __importDefault(require("@heroicons/react/24/outline/ExclamationCircleIcon"));
|
|
50
|
-
const InformationCircleIcon_1 = __importDefault(require("@heroicons/react/24/outline/InformationCircleIcon"));
|
|
51
|
-
const ArrowDownTrayIcon_1 = __importDefault(require("@heroicons/react/24/outline/ArrowDownTrayIcon"));
|
|
52
|
-
function downloadBlob(filename, blob) {
|
|
53
|
-
const a = document.createElement('a');
|
|
54
|
-
const url = URL.createObjectURL(blob);
|
|
55
|
-
a.href = url;
|
|
56
|
-
a.download = filename;
|
|
57
|
-
a.click();
|
|
58
|
-
}
|
|
59
|
-
function saveDocxFile(filename, mdast) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const { unified } = yield Promise.resolve().then(() => __importStar(require('unified')));
|
|
62
|
-
const { mystToDocx, fetchImagesAsBuffers } = yield Promise.resolve().then(() => __importStar(require('myst-to-docx')));
|
|
63
|
-
// Clone the tree
|
|
64
|
-
const tree = JSON.parse(JSON.stringify(mdast));
|
|
65
|
-
const opts = yield fetchImagesAsBuffers(tree);
|
|
66
|
-
const docxBlob = yield unified()
|
|
67
|
-
.use(mystToDocx, opts)
|
|
68
|
-
.stringify(tree).result;
|
|
69
|
-
downloadBlob(filename, docxBlob);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function parse(text, defaultFrontmatter, options) {
|
|
73
|
-
var _a, _b, _c, _d;
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
// Ensure that any imports from myst are async and scoped to this function
|
|
76
|
-
const { visit } = yield Promise.resolve().then(() => __importStar(require('unist-util-visit')));
|
|
77
|
-
const { unified } = yield Promise.resolve().then(() => __importStar(require('unified')));
|
|
78
|
-
const { mystParse } = yield Promise.resolve().then(() => __importStar(require('myst-parser')));
|
|
79
|
-
const { mathPlugin, footnotesPlugin, keysPlugin, basicTransformationsPlugin, enumerateTargetsPlugin, resolveReferencesPlugin, WikiTransformer, GithubTransformer, DOITransformer, RRIDTransformer, linksPlugin, ReferenceState, getFrontmatter, abbreviationPlugin, glossaryPlugin, joinGatesPlugin, } = yield Promise.resolve().then(() => __importStar(require('myst-transforms')));
|
|
80
|
-
const { default: mystToTex } = yield Promise.resolve().then(() => __importStar(require('myst-to-tex')));
|
|
81
|
-
const { default: mystToTypst } = yield Promise.resolve().then(() => __importStar(require('myst-to-typst')));
|
|
82
|
-
const { default: mystToJats } = yield Promise.resolve().then(() => __importStar(require('myst-to-jats'))).catch(() => ({ default: null }));
|
|
83
|
-
const { mystToHtml } = yield Promise.resolve().then(() => __importStar(require('myst-to-html')));
|
|
84
|
-
const { cardDirective } = yield Promise.resolve().then(() => __importStar(require('myst-ext-card')));
|
|
85
|
-
const { gridDirective } = yield Promise.resolve().then(() => __importStar(require('myst-ext-grid')));
|
|
86
|
-
const { tabDirectives } = yield Promise.resolve().then(() => __importStar(require('myst-ext-tabs')));
|
|
87
|
-
const { proofDirective } = yield Promise.resolve().then(() => __importStar(require('myst-ext-proof')));
|
|
88
|
-
const { exerciseDirectives } = yield Promise.resolve().then(() => __importStar(require('myst-ext-exercise')));
|
|
89
|
-
const file = new vfile_1.VFile();
|
|
90
|
-
const mdast = mystParse(text, {
|
|
91
|
-
markdownit: { linkify: true },
|
|
92
|
-
directives: [
|
|
93
|
-
cardDirective,
|
|
94
|
-
gridDirective,
|
|
95
|
-
...tabDirectives,
|
|
96
|
-
proofDirective,
|
|
97
|
-
...exerciseDirectives,
|
|
98
|
-
],
|
|
99
|
-
// roles: [reactiveRole],
|
|
100
|
-
vfile: file,
|
|
101
|
-
});
|
|
102
|
-
const linkTransforms = [
|
|
103
|
-
new WikiTransformer(),
|
|
104
|
-
new GithubTransformer(),
|
|
105
|
-
new DOITransformer(),
|
|
106
|
-
new RRIDTransformer(),
|
|
107
|
-
];
|
|
108
|
-
// For the mdast that we show, duplicate, strip positions and dump to yaml
|
|
109
|
-
// Also run some of the transforms, like the links
|
|
110
|
-
const mdastPre = JSON.parse(JSON.stringify(mdast));
|
|
111
|
-
unified().use(linksPlugin, { transformers: linkTransforms }).runSync(mdastPre);
|
|
112
|
-
visit(mdastPre, (n) => delete n.position);
|
|
113
|
-
const mdastString = js_yaml_1.default.dump(mdastPre);
|
|
114
|
-
const htmlString = mystToHtml(mdastPre);
|
|
115
|
-
const references = {
|
|
116
|
-
cite: { order: [], data: {} },
|
|
117
|
-
footnotes: {},
|
|
118
|
-
};
|
|
119
|
-
const { frontmatter: frontmatterRaw } = getFrontmatter(file, mdast, {
|
|
120
|
-
removeYaml: true,
|
|
121
|
-
removeHeading: (_a = options === null || options === void 0 ? void 0 : options.removeHeading) !== null && _a !== void 0 ? _a : false,
|
|
122
|
-
});
|
|
123
|
-
const frontmatter = (0, myst_frontmatter_1.validatePageFrontmatter)(frontmatterRaw, {
|
|
124
|
-
property: 'frontmatter',
|
|
125
|
-
messages: {},
|
|
126
|
-
});
|
|
127
|
-
const state = new ReferenceState({
|
|
128
|
-
numbering: (_b = frontmatter.numbering) !== null && _b !== void 0 ? _b : defaultFrontmatter === null || defaultFrontmatter === void 0 ? void 0 : defaultFrontmatter.numbering,
|
|
129
|
-
file,
|
|
130
|
-
});
|
|
131
|
-
unified()
|
|
132
|
-
.use(basicTransformationsPlugin)
|
|
133
|
-
.use(mathPlugin, { macros: (_c = frontmatter === null || frontmatter === void 0 ? void 0 : frontmatter.math) !== null && _c !== void 0 ? _c : {} }) // This must happen before enumeration, as it can add labels
|
|
134
|
-
.use(glossaryPlugin, { state }) // This should be before the enumerate plugins
|
|
135
|
-
.use(abbreviationPlugin, { abbreviations: frontmatter.abbreviations })
|
|
136
|
-
.use(enumerateTargetsPlugin, { state })
|
|
137
|
-
.use(linksPlugin, { transformers: linkTransforms })
|
|
138
|
-
.use(footnotesPlugin)
|
|
139
|
-
.use(joinGatesPlugin)
|
|
140
|
-
.use(resolveReferencesPlugin, { state })
|
|
141
|
-
.use(keysPlugin)
|
|
142
|
-
.runSync(mdast, file);
|
|
143
|
-
const texFile = new vfile_1.VFile();
|
|
144
|
-
const tex = unified()
|
|
145
|
-
.use(mystToTex, { references })
|
|
146
|
-
.stringify(mdast, texFile).result;
|
|
147
|
-
const typstFile = new vfile_1.VFile();
|
|
148
|
-
let typst;
|
|
149
|
-
try {
|
|
150
|
-
typst = unified()
|
|
151
|
-
.use(mystToTypst)
|
|
152
|
-
.stringify(mdast, typstFile).result;
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
console.error(error);
|
|
156
|
-
typst = {
|
|
157
|
-
value: `Problem with typst conversion: ${error.message || 'Unknown Error'}`,
|
|
158
|
-
macros: [],
|
|
159
|
-
commands: {},
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
const jatsFile = new vfile_1.VFile();
|
|
163
|
-
const jats = mystToJats
|
|
164
|
-
? unified()
|
|
165
|
-
.use(mystToJats, myst_spec_ext_1.SourceFileKind.Article, frontmatter, undefined, '', {
|
|
166
|
-
spaces: 2,
|
|
167
|
-
writeFullArticle: (_d = options === null || options === void 0 ? void 0 : options.jats) === null || _d === void 0 ? void 0 : _d.fullArticle,
|
|
168
|
-
})
|
|
169
|
-
.stringify(mdast, jatsFile).result
|
|
170
|
-
: 'Problem loading myst-to-jats';
|
|
171
|
-
return {
|
|
172
|
-
frontmatter,
|
|
173
|
-
yaml: mdastString,
|
|
174
|
-
references: Object.assign(Object.assign({}, references), { article: mdast }),
|
|
175
|
-
html: htmlString,
|
|
176
|
-
tex: tex.value,
|
|
177
|
-
texWarnings: texFile.messages,
|
|
178
|
-
typst: typst.value,
|
|
179
|
-
typstWarnings: typstFile.messages,
|
|
180
|
-
jats: jats,
|
|
181
|
-
jatsWarnings: jatsFile.messages,
|
|
182
|
-
warnings: file.messages,
|
|
183
|
-
};
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
function MySTRenderer({ value, column, fullscreen, numbering, TitleBlock, captureTab, className, }) {
|
|
187
|
-
var _a;
|
|
188
|
-
const area = (0, react_1.useRef)(null);
|
|
189
|
-
const [text, setText] = (0, react_1.useState)(value.trim());
|
|
190
|
-
const [references, setReferences] = (0, react_1.useState)({});
|
|
191
|
-
const [frontmatter, setFrontmatter] = (0, react_1.useState)({});
|
|
192
|
-
const [mdastYaml, setYaml] = (0, react_1.useState)('Loading...');
|
|
193
|
-
const [html, setHtml] = (0, react_1.useState)('Loading...');
|
|
194
|
-
const [tex, setTex] = (0, react_1.useState)('Loading...');
|
|
195
|
-
const [texWarnings, setTexWarnings] = (0, react_1.useState)([]);
|
|
196
|
-
const [typst, setTypst] = (0, react_1.useState)('Loading...');
|
|
197
|
-
const [typstWarnings, setTypstWarnings] = (0, react_1.useState)([]);
|
|
198
|
-
const [jats, setJats] = (0, react_1.useState)('Loading...');
|
|
199
|
-
const [jatsWarnings, setJatsWarnings] = (0, react_1.useState)([]);
|
|
200
|
-
const [warnings, setWarnings] = (0, react_1.useState)([]);
|
|
201
|
-
const [previewType, setPreviewType] = (0, react_1.useState)('DEMO');
|
|
202
|
-
(0, react_1.useEffect)(() => {
|
|
203
|
-
const ref = { current: true };
|
|
204
|
-
parse(text, { numbering }, { removeHeading: !!TitleBlock, jats: { fullArticle: !!TitleBlock } }).then((result) => {
|
|
205
|
-
if (!ref.current)
|
|
206
|
-
return;
|
|
207
|
-
setFrontmatter(result.frontmatter);
|
|
208
|
-
setYaml(result.yaml);
|
|
209
|
-
setReferences(result.references);
|
|
210
|
-
setHtml(result.html);
|
|
211
|
-
setTex(result.tex);
|
|
212
|
-
setTexWarnings(result.texWarnings);
|
|
213
|
-
setTypst(result.typst);
|
|
214
|
-
setTypstWarnings(result.typstWarnings);
|
|
215
|
-
setJats(result.jats);
|
|
216
|
-
setJatsWarnings(result.jatsWarnings);
|
|
217
|
-
setWarnings(result.warnings);
|
|
218
|
-
});
|
|
219
|
-
return () => {
|
|
220
|
-
ref.current = false;
|
|
221
|
-
};
|
|
222
|
-
}, [text]);
|
|
223
|
-
(0, react_1.useEffect)(() => {
|
|
224
|
-
if (!area.current)
|
|
225
|
-
return;
|
|
226
|
-
if (column) {
|
|
227
|
-
area.current.style.height = '';
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
area.current.style.height = 'auto'; // for the scroll area in the next step!
|
|
231
|
-
area.current.style.height = `${area.current.scrollHeight}px`;
|
|
232
|
-
}, [text, column]);
|
|
233
|
-
// Bit of a hack for now while still a basic text editor
|
|
234
|
-
(0, react_1.useEffect)(() => {
|
|
235
|
-
if (!area.current || !captureTab)
|
|
236
|
-
return;
|
|
237
|
-
area.current.addEventListener('keydown', (ev) => {
|
|
238
|
-
if (ev.key !== 'Tab')
|
|
239
|
-
return;
|
|
240
|
-
ev.preventDefault();
|
|
241
|
-
ev.stopPropagation();
|
|
242
|
-
});
|
|
243
|
-
}, [area, captureTab]);
|
|
244
|
-
let currentWarnings = [];
|
|
245
|
-
switch (previewType) {
|
|
246
|
-
case 'DEMO':
|
|
247
|
-
currentWarnings = warnings;
|
|
248
|
-
break;
|
|
249
|
-
case 'LaTeX':
|
|
250
|
-
currentWarnings = texWarnings;
|
|
251
|
-
break;
|
|
252
|
-
case 'Typst':
|
|
253
|
-
currentWarnings = typstWarnings;
|
|
254
|
-
break;
|
|
255
|
-
case 'JATS':
|
|
256
|
-
currentWarnings = jatsWarnings;
|
|
257
|
-
break;
|
|
258
|
-
default:
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
const demoMenu = ((0, jsx_runtime_1.jsx)("div", { className: "self-center text-sm border cursor-pointer dark:border-slate-600", children: ['DEMO', 'AST', 'HTML', 'LaTeX', 'Typst', 'JATS', 'DOCX'].map((show) => ((0, jsx_runtime_1.jsx)("button", { className: (0, classnames_1.default)('px-2 py-1', {
|
|
262
|
-
'bg-white hover:bg-slate-200 dark:bg-slate-500 dark:hover:bg-slate-700': previewType !== show,
|
|
263
|
-
'bg-blue-800 text-white': previewType === show,
|
|
264
|
-
}), title: `Show the ${show}`, "aria-label": `Show the ${show}`, "aria-pressed": previewType === show ? 'true' : 'false', onClick: () => setPreviewType(show), children: show }, show))) }));
|
|
265
|
-
return ((0, jsx_runtime_1.jsxs)("figure", { className: (0, classnames_1.default)('relative', {
|
|
266
|
-
'grid grid-cols-2 gap-0 grid-rows-[3rem_1fr]': column,
|
|
267
|
-
'shadow-lg rounded': !fullscreen,
|
|
268
|
-
'm-0': fullscreen,
|
|
269
|
-
}, className), children: [column && ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-row items-stretch h-full col-span-2 px-2 border dark:border-slate-600", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-grow" }), demoMenu] })), (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('myst relative', { 'overflow-auto': column }), children: [(0, jsx_runtime_1.jsx)(myst_to_react_1.CopyIcon, { text: text, className: "absolute right-0 p-1" }), (0, jsx_runtime_1.jsxs)("label", { children: [(0, jsx_runtime_1.jsx)("span", { className: "sr-only", children: "Edit the MyST Markdown text" }), (0, jsx_runtime_1.jsx)("textarea", { ref: area, value: text, className: (0, classnames_1.default)('block p-6 shadow-inner resize-none w-full font-mono bg-slate-50/50 dark:bg-slate-800/50 outline-none', { 'text-sm': !column }, { 'h-full': column }), onChange: (e) => setText(e.target.value) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('exclude-from-outline relative min-h-1 dark:bg-slate-900', {
|
|
270
|
-
'overflow-auto': column,
|
|
271
|
-
}), children: [!column && (0, jsx_runtime_1.jsx)("div", { className: "absolute top-0 left-0", children: demoMenu }), (0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('px-6 pb-6', { 'pt-[40px]': !column, 'pt-4': column }), children: [previewType === 'DEMO' && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(providers_1.ReferencesProvider, { references: references, frontmatter: frontmatter, children: [TitleBlock && (0, jsx_runtime_1.jsx)(TitleBlock, { frontmatter: frontmatter }), (0, jsx_runtime_1.jsx)(myst_to_react_1.MyST, { ast: (_a = references.article) === null || _a === void 0 ? void 0 : _a.children })] }) })), previewType === 'AST' && (0, jsx_runtime_1.jsx)(myst_to_react_1.CodeBlock, { lang: "yaml", value: mdastYaml, showCopy: false }), previewType === 'HTML' && (0, jsx_runtime_1.jsx)(myst_to_react_1.CodeBlock, { lang: "xml", value: html, showCopy: false }), previewType === 'LaTeX' && (0, jsx_runtime_1.jsx)(myst_to_react_1.CodeBlock, { lang: "latex", value: tex, showCopy: false }), previewType === 'Typst' && (0, jsx_runtime_1.jsx)(myst_to_react_1.CodeBlock, { lang: "typst", value: typst, showCopy: false }), previewType === 'JATS' && (0, jsx_runtime_1.jsx)(myst_to_react_1.CodeBlock, { lang: "xml", value: jats, showCopy: false }), previewType === 'DOCX' && ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("button", { className: "p-3 border rounded", onClick: () => saveDocxFile('demo.docx', references.article), title: `Download Micorsoft Word`, "aria-label": `Download Micorsoft Word`, children: [(0, jsx_runtime_1.jsx)(ArrowDownTrayIcon_1.default, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" }), ' ', "Download as Microsoft Word"] }) }))] }), currentWarnings.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('w-full', { 'absolute bottom-0': column }), children: currentWarnings.map((m, i) => ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('p-1 shadow-inner text-white not-prose', {
|
|
272
|
-
'bg-red-500 dark:bg-red-800': m.fatal === true,
|
|
273
|
-
'bg-orange-500 dark:bg-orange-700': m.fatal === false,
|
|
274
|
-
'bg-slate-500 dark:bg-slate-800': m.fatal === null,
|
|
275
|
-
}), children: [m.fatal === true && ((0, jsx_runtime_1.jsx)(ExclamationCircleIcon_1.default, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" })), m.fatal === false && ((0, jsx_runtime_1.jsx)(ExclamationTriangleIcon_1.default, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" })), m.fatal === null && ((0, jsx_runtime_1.jsx)(InformationCircleIcon_1.default, { width: "1.3rem", height: "1.3rem", className: "inline mr-1" })), (0, jsx_runtime_1.jsx)("code", { children: m.ruleId || m.source }), ": ", m.message] }, i))) }))] })] }));
|
|
276
|
-
}
|
|
277
|
-
exports.MySTRenderer = MySTRenderer;
|
|
278
|
-
const MystDemoRenderer = ({ node }) => {
|
|
279
|
-
return (0, jsx_runtime_1.jsx)(MySTRenderer, { value: node.value, numbering: node.numbering });
|
|
280
|
-
};
|
|
281
|
-
exports.MystDemoRenderer = MystDemoRenderer;
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { PageFrontmatter } from 'myst-frontmatter';
|
|
3
|
-
import type { NodeRenderer } from '@myst-theme/providers';
|
|
4
|
-
export declare function MySTRenderer({ value, column, fullscreen, numbering, TitleBlock, captureTab, className, }: {
|
|
5
|
-
value: string;
|
|
6
|
-
column?: boolean;
|
|
7
|
-
fullscreen?: boolean;
|
|
8
|
-
captureTab?: boolean;
|
|
9
|
-
TitleBlock?: (props: {
|
|
10
|
-
frontmatter: PageFrontmatter;
|
|
11
|
-
}) => JSX.Element | null;
|
|
12
|
-
numbering?: any;
|
|
13
|
-
className?: string;
|
|
14
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare const MystDemoRenderer: NodeRenderer;
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAuK1D,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,eAAe,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7E,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAoMA;AAED,eAAO,MAAM,gBAAgB,EAAE,YAE9B,CAAC"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { PageFrontmatter } from 'myst-frontmatter';
|
|
3
|
-
import type { NodeRenderer } from '@myst-theme/providers';
|
|
4
|
-
export declare function MySTRenderer({ value, column, fullscreen, numbering, TitleBlock, captureTab, className, }: {
|
|
5
|
-
value: string;
|
|
6
|
-
column?: boolean;
|
|
7
|
-
fullscreen?: boolean;
|
|
8
|
-
captureTab?: boolean;
|
|
9
|
-
TitleBlock?: (props: {
|
|
10
|
-
frontmatter: PageFrontmatter;
|
|
11
|
-
}) => JSX.Element | null;
|
|
12
|
-
numbering?: any;
|
|
13
|
-
className?: string;
|
|
14
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare const MystDemoRenderer: NodeRenderer;
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAuK1D,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,eAAe,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IAC7E,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAoMA;AAED,eAAO,MAAM,gBAAgB,EAAE,YAE9B,CAAC"}
|
|
File without changes
|