mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
fix(markdown-editor, unicode-formatter, pomodoro-timer): bundle editor extensions and fonts
md-editor-v3 loaded highlight.js, katex, mermaid, prettier, cropper, screenfull and echarts from unpkg.com; the two other tools loaded Google Fonts. All of them now come from the app. Refs sharevb/it-tools#571 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4a80283786
commit
b536f040be
4 files changed
+52
-8
No files matched your search
@@ -3,6 +3,7 @@ import type { Themes } from 'md-editor-v3';
|
||||
import { MdEditor } from 'md-editor-v3';
|
||||
|
||||
import 'md-editor-v3/lib/style.css';
|
||||
import './md-editor-extensions';
|
||||
import { useStyleStore } from '@/stores/style.store';
|
||||
|
||||
const theme = ref<Themes>('light');
|
||||
@@ -21,3 +22,14 @@ const markdown = ref('Sample _formatted_ *text*');
|
||||
<MdEditor v-model="markdown" :theme="theme" language="en-US" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less">
|
||||
// highlight.js theme for code blocks. md-editor-v3 would fetch it from a CDN, but not once it
|
||||
// is given a highlight.js instance. With its default props (codeTheme 'atom', codeStyleReverse
|
||||
// on the 'default' preview theme) code blocks always use the dark variant, in both app themes.
|
||||
// Scoped to the editor with :where() so the rules keep their original specificity and don't
|
||||
// restyle highlight.js output elsewhere in the app.
|
||||
:where(.md-editor) {
|
||||
@import (less) 'highlight.js/styles/atom-one-dark.css';
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,31 @@
|
||||
import { config } from 'md-editor-v3';
|
||||
import hljs from 'highlight.js/lib/common';
|
||||
import katex from 'katex';
|
||||
import mermaid from 'mermaid';
|
||||
import * as echarts from 'echarts';
|
||||
import * as prettier from 'prettier/standalone';
|
||||
import * as prettierMarkdown from 'prettier/plugins/markdown';
|
||||
import Cropper from 'cropperjs';
|
||||
import screenfull from 'screenfull';
|
||||
|
||||
import 'cropperjs/dist/cropper.css';
|
||||
|
||||
// md-editor-v3 injects <script>/<link> tags from unpkg.com for every editor extension it
|
||||
// has no instance for. Hand it bundled instances instead, so the editor works offline and
|
||||
// never contacts a CDN. This module is only imported by the lazily loaded tool component,
|
||||
// and evaluating it (before the component renders) is what makes the instances available.
|
||||
//
|
||||
// With an instance set, md-editor-v3 also skips the matching stylesheets: katex.css is
|
||||
// already loaded globally (src/main.ts), the cropper styles are imported above and the
|
||||
// highlight.js theme is provided by markdown-editor.vue.
|
||||
config({
|
||||
editorExtensions: {
|
||||
highlight: { instance: hljs },
|
||||
prettier: { prettierInstance: prettier, parserMarkdownInstance: prettierMarkdown },
|
||||
cropper: { instance: Cropper },
|
||||
screenfull: { instance: screenfull },
|
||||
mermaid: { instance: mermaid },
|
||||
katex: { instance: katex },
|
||||
echarts: { instance: echarts },
|
||||
},
|
||||
});
|
||||
@@ -6,6 +6,10 @@ import { startTimer } from './storeUtils';
|
||||
import PomodoroAbout from './views/PomodoroAbout.vue';
|
||||
import PomodoroHome from './views/Home.vue';
|
||||
import PomodoroSettings from './views/Settings.vue';
|
||||
import { appBaseUrl as base } from '@/utils/base-url';
|
||||
|
||||
// Bundled instead of fetched from Google Fonts (the font only comes in this one weight).
|
||||
import '@fontsource/varela-round/400.css';
|
||||
|
||||
const store = useStore('pomodoro-store');
|
||||
|
||||
@@ -62,7 +66,6 @@ const currentTab = computed({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<link href="//fonts.googleapis.com/css2?family=Varela+Round&display=swap" rel="stylesheet" />
|
||||
<div class="pomodoro-timer-app">
|
||||
<Header />
|
||||
<div class="page-container">
|
||||
@@ -80,13 +83,11 @@ const currentTab = computed({
|
||||
</div>
|
||||
<!-- <Footer /> -->
|
||||
<FinishedPopup />
|
||||
<audio id="alarmPlayer" src="/Beep.mp3" loop />
|
||||
<audio id="alarmPlayer" :src="`${base}Beep.mp3`" loop />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@import url('//fonts.googleapis.com/css2?family=Varela+Round&display=swap');
|
||||
|
||||
:root {
|
||||
--pomodoro-app-accent-color: #3b83b0;
|
||||
--pomodoro-dark-text-color: #303030;
|
||||
|
||||
@@ -8,6 +8,10 @@ import { formatSelection } from './unicode-formatter.service';
|
||||
|
||||
import { useCopy } from '@/composable/copy';
|
||||
|
||||
// Bundled instead of fetched from Google Fonts. Only the regular weight is used; its unicode-range
|
||||
// subsets are only downloaded when the text needs them.
|
||||
import '@fontsource/open-sans/400.css';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const textArea = ref<HTMLTextAreaElement>();
|
||||
@@ -29,10 +33,6 @@ const { copy: copyFormattedText } = useCopy({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Google Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet" />
|
||||
|
||||
<div
|
||||
max-w-600
|
||||
style="
|
||||
|
||||
Reference in new issue
Block a user