Skip to content

Commit 0de2ed1

Browse files
committed
fix: use Plurimath as asset
Plurimath opal cannot be minified, esbuilded and bundled without causing unexpected exceptions So copy js in public folder and import plurimath from here
1 parent fd8b975 commit 0de2ed1

File tree

7 files changed

+75
-23
lines changed

7 files changed

+75
-23
lines changed

components.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,24 @@ declare module '@vue/runtime-core' {
147147
IcalParser: typeof import('./src/tools/ical-parser/ical-parser.vue')['default']
148148
IcoConverter: typeof import('./src/tools/ico-converter/ico-converter.vue')['default']
149149
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
150+
'IconMdi:contentCopy': typeof import('~icons/mdi/content-copy')['default']
150151
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
152+
IconMdiArrowDown: typeof import('~icons/mdi/arrow-down')['default']
153+
IconMdiArrowRightBottom: typeof import('~icons/mdi/arrow-right-bottom')['default']
154+
IconMdiCamera: typeof import('~icons/mdi/camera')['default']
151155
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
152156
IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
153157
IconMdiClose: typeof import('~icons/mdi/close')['default']
154158
IconMdiContentCopy: typeof import('~icons/mdi/content-copy')['default']
159+
IconMdiDeleteOutline: typeof import('~icons/mdi/delete-outline')['default']
160+
IconMdiDownload: typeof import('~icons/mdi/download')['default']
155161
IconMdiEye: typeof import('~icons/mdi/eye')['default']
156162
IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default']
157163
IconMdiHeart: typeof import('~icons/mdi/heart')['default']
164+
IconMdiPause: typeof import('~icons/mdi/pause')['default']
165+
IconMdiPlay: typeof import('~icons/mdi/play')['default']
166+
IconMdiRecord: typeof import('~icons/mdi/record')['default']
167+
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
158168
IconMdiSearch: typeof import('~icons/mdi/search')['default']
159169
IconMdiTranslate: typeof import('~icons/mdi/translate')['default']
160170
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
@@ -242,20 +252,30 @@ declare module '@vue/runtime-core' {
242252
NanoMemo: typeof import('./src/tools/nano-memo/nano-memo.vue')['default']
243253
'NanoMemo.content': typeof import('./src/tools/nano-memo/nano-memo.content.md')['default']
244254
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
255+
NCheckbox: typeof import('naive-ui')['NCheckbox']
245256
NCode: typeof import('naive-ui')['NCode']
246257
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
258+
NColorPicker: typeof import('naive-ui')['NColorPicker']
247259
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
260+
NDatePicker: typeof import('naive-ui')['NDatePicker']
248261
NDivider: typeof import('naive-ui')['NDivider']
262+
NDynamicInput: typeof import('naive-ui')['NDynamicInput']
249263
NEllipsis: typeof import('naive-ui')['NEllipsis']
264+
NForm: typeof import('naive-ui')['NForm']
250265
NFormItem: typeof import('naive-ui')['NFormItem']
251266
NginxFormatter: typeof import('./src/tools/nginx-formatter/nginx-formatter.vue')['default']
252267
NH1: typeof import('naive-ui')['NH1']
268+
NH2: typeof import('naive-ui')['NH2']
253269
NH3: typeof import('naive-ui')['NH3']
254270
NIcon: typeof import('naive-ui')['NIcon']
271+
NImage: typeof import('naive-ui')['NImage']
272+
NInputGroup: typeof import('naive-ui')['NInputGroup']
273+
NInputGroupLabel: typeof import('naive-ui')['NInputGroupLabel']
255274
NInputNumber: typeof import('naive-ui')['NInputNumber']
256275
NLayout: typeof import('naive-ui')['NLayout']
257276
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
258277
NMenu: typeof import('naive-ui')['NMenu']
278+
NProgress: typeof import('naive-ui')['NProgress']
259279
NScrollbar: typeof import('naive-ui')['NScrollbar']
260280
NSwitch: typeof import('naive-ui')['NSwitch']
261281
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"@it-tools/oggen": "^1.3.0",
4848
"@kenjiuno/decompressrtf": "^0.1.4",
4949
"@kenjiuno/msgreader": "^1.22.0",
50-
"@plurimath/plurimath": "^0.2.0",
5150
"@regexper/render": "^1.0.0",
5251
"@sindresorhus/slugify": "^2.2.1",
5352
"@tabler/icons-vue": "^3.20.0",

pnpm-lock.yaml

Lines changed: 7 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/plurimath/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import "./plurimath-opal.js";
2+
Opal.require("plurimath");
3+
window.Plurimath = class Plurimath {
4+
constructor(data, format) {
5+
this.data = Opal.Plurimath.Math.$parse(data, format);
6+
}
7+
toAsciimath() {
8+
return this.data.$to_asciimath();
9+
}
10+
toLatex() {
11+
return this.data.$to_latex();
12+
}
13+
toMathml() {
14+
return this.data.$to_mathml();
15+
}
16+
toHtml() {
17+
return this.data.$to_html();
18+
}
19+
toOmml() {
20+
return this.data.$to_omml();
21+
}
22+
toDisplay(lang) {
23+
return this.data.$to_display(lang);
24+
}
25+
}

public/plurimath/plurimath-opal.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/math-formats-converter/math-formats-converter.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script setup lang="ts">
2-
import Plurimath from '@plurimath/plurimath';
2+
import { useScriptTag } from '@vueuse/core';
33
import { useQueryParamOrStorage } from '@/composable/queryParams';
44
5+
const { load: loadPlurimath } = useScriptTag('/plurimath/index.js', undefined, { type: 'module', manual: true });
6+
57
const formats = [
68
{ value: 'asciimath', label: 'AsciiMath' },
79
{ value: 'latex', label: 'Latex' },
@@ -17,12 +19,13 @@ const target = computedAsync(async () => {
1719
const sourceValue = source.value;
1820
const sourceFormatValue = sourceFormat.value;
1921
const targetFormatValue = targetFormat.value;
20-
if (sourceValue === '') {
22+
if (!sourceValue) {
2123
return '';
2224
}
2325
if (sourceFormatValue === targetFormatValue) {
2426
return sourceValue;
2527
}
28+
await loadPlurimath();
2629
return new Promise<string>((resolve, _reject) => {
2730
try {
2831
const formula = new Plurimath(sourceValue, sourceFormatValue);
@@ -80,6 +83,6 @@ const target = computedAsync(async () => {
8083
:options="formats"
8184
placeholder="Source format"
8285
/>
83-
<textarea-copyable v-if="target !== ''" :value="target" :language="targetFormat" />
86+
<textarea-copyable v-if="target" :value="target" :language="targetFormat" word-wrap />
8487
</div>
8588
</template>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Plurimath {
2+
constructor(data: string, format: string);
3+
toAsciimath(): string;
4+
toLatex(): string;
5+
toMathml(): string;
6+
toHtml(): string;
7+
toOmml(): string;
8+
toDisplay(lang: string): string;
9+
}
10+
11+
declare global {
12+
interface Window {
13+
Plurimath: Plurimath
14+
}
15+
}

0 commit comments

Comments
 (0)