Skip to content

Commit

Permalink
Align demo UI, format and integration with build
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w committed Oct 4, 2023
1 parent dc088b3 commit 6c95494
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 54 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- run: npm install --legacy-peer-deps
- run: npm --prefix=reactjs install --legacy-peer-deps
- run: npm --prefix=nextjs install --legacy-peer-deps
- run: npm --prefix=vuejs install
- run: npm run demo
- uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
"start.reactjs": "npm --prefix=reactjs start",
"start.nextjs": "npm --prefix=nextjs start",
"start": "reload --port 8080 --browser --dir .",
"lint.js": "eslint --ext js .",
"lint.js": "eslint --ext js \"*.js\"",
"lint.css": "stylelint \"*.css\"",
"lint.md": "markdownlint \"*.md\"",
"lint.prettier": "prettier --check \"**/*.js\"",
"lint.prettier": "prettier --check \"*.js\"",
"lint": "run-s lint.js lint.css lint.md lint.prettier",
"demo.vanillajs": "shx cp index.{html,js,css} mathquill4quill.{js,css} demo",
"demo.reactjs": "npm --prefix=reactjs run build",
"demo.nextjs": "npm --prefix=nextjs run build",
"demo.vuejs": "npm --prefix=vuejs run build",
"postdemo.reactjs": "shx mv reactjs/build demo/reactjs",
"postdemo.nextjs": "shx mv nextjs/out demo/nextjs",
"postdemo.vuejs": "shx mv vuejs/dist demo/vuejs",
"predemo": "shx mkdir -p demo",
"demo": "run-s demo.vanillajs demo.reactjs demo.nextjs",
"demo": "run-s demo.vanillajs demo.reactjs demo.nextjs demo.vuejs",
"prebuild": "shx mkdir -p build",
"build.babel": "babel mathquill4quill.js > build/mathquill4quill.js",
"build.uglify": "uglifyjs --compress --mangle -- build/mathquill4quill.js > build/mathquill4quill.min.js",
Expand Down
2 changes: 1 addition & 1 deletion vuejs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
.vscode/
.vscode/
2 changes: 1 addition & 1 deletion vuejs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rvuejs",
"name": "vuejs",
"private": true,
"version": "0.0.0",
"type": "module",
Expand Down
122 changes: 86 additions & 36 deletions vuejs/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,57 +1,51 @@
<script setup>
import './jquery'
import "./jquery";
// KaTeX dependency
import katex from 'katex';
import katex from "katex";
window.katex = katex;
import { QuillEditor, Quill } from '@vueup/vue-quill';
import { QuillEditor, Quill } from "@vueup/vue-quill";
import '@edtr-io/mathquill/build/mathquill.js';
import '@edtr-io/mathquill/build/mathquill.css';
import "@edtr-io/mathquill/build/mathquill.js";
import "@edtr-io/mathquill/build/mathquill.css";
// mathquill4quill include
import mathquill4quill from 'mathquill4quill';
import 'mathquill4quill/mathquill4quill.css';
import mathquill4quill from "mathquill4quill";
import "mathquill4quill/mathquill4quill.css";
import { onMounted, ref } from 'vue';
import { onMounted, ref } from "vue";
const operators = [
['\\pm', '\\pm'],
['\\sqrt{x}', '\\sqrt'],
['\\sqrt[3]{x}', '\\sqrt[3]{}'],
['\\sqrt[n]{x}', '\\nthroot'],
['\\frac{x}{y}', '\\frac'],
['\\sum^{s}_{x}{d}', '\\sum'],
['\\prod^{s}_{x}{d}', '\\prod'],
['\\coprod^{s}_{x}{d}', '\\coprod'],
['\\int^{s}_{x}{d}', '\\int'],
['\\binom{n}{k}', '\\binom'],
["\\pm", "\\pm"],
["\\sqrt{x}", "\\sqrt"],
["\\sqrt[3]{x}", "\\sqrt[3]{}"],
["\\sqrt[n]{x}", "\\nthroot"],
["\\frac{x}{y}", "\\frac"],
["\\sum^{s}_{x}{d}", "\\sum"],
["\\prod^{s}_{x}{d}", "\\prod"],
["\\coprod^{s}_{x}{d}", "\\coprod"],
["\\int^{s}_{x}{d}", "\\int"],
["\\binom{n}{k}", "\\binom"]
];
const quill = ref();
const content = ref('');
const content = ref("");
onMounted(() => {
// For this line, refer to the following issue comment:
// https://github.com/c-w/mathquill4quill/issues/97#issuecomment-1740482856
quill.value.container = quill.value.getEditor();
const enableMathQuillFormulaAuthoring = mathquill4quill({ Quill, katex });
enableMathQuillFormulaAuthoring(quill.value, {
operators,
operators
});
});
const textChange = (prop) => {
console.log('textChange', content.value);
};
</script>

<template>
<div class="wrapper">
<main class="demo-container">
<QuillEditor
id="quill-editor"
v-model:content="content"
Expand All @@ -61,18 +55,74 @@ const textChange = (prop) => {
:options="{
modules: {
formula: true,
toolbar: [['bold', 'italic', 'underline'], ['formula']],
},
toolbar: [['bold', 'italic', 'underline'], ['formula']]
}
}"
@editorChange="textChange"
/>
</div>

<footer>
<a href="https://github.com/c-w/mathquill4quill">
<p>Fork me on Github</p>
<img
width="149"
height="149"
src="https://github.blog/wp-content/uploads/2008/12/forkme_right_darkblue_121621.png?resize=149%2C149"
alt="Fork me on GitHub"
/>
</a>
</footer>
</main>
</template>

<style scoped>
.wrapper {
width: 80%;
margin: 50px auto;
height: 100%;
footer {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #121621;
text-align: center;
}
footer a {
color: #fff;
font-family: sans-serif;
}
footer p {
margin: 0.5em;
}
footer img {
position: fixed;
top: 0;
right: 0;
z-index: 99999;
display: none;
}
main {
width: 100%;
height: 200px;
}
@media (min-width: 500px) {
main {
max-width: 400px;
margin: 50px auto;
}
footer p {
display: none;
}
footer img {
display: block;
}
}
label {
padding-top: 0.5em;
display: block;
}
</style>
</style>
2 changes: 1 addition & 1 deletion vuejs/src/jquery.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import $ from 'jquery';
import $ from "jquery";

window.jQuery = window.$ = $;
14 changes: 7 additions & 7 deletions vuejs/src/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createApp } from 'vue'
import 'katex/dist/katex.css';
import '@vueup/vue-quill/dist/vue-quill.bubble.css';
import '@vueup/vue-quill/dist/vue-quill.snow.css';
import { createApp } from "vue";
import "katex/dist/katex.css";
import "@vueup/vue-quill/dist/vue-quill.bubble.css";
import "@vueup/vue-quill/dist/vue-quill.snow.css";

import 'mathquill4quill/mathquill4quill.css';
import "mathquill4quill/mathquill4quill.css";

import App from './App.vue'
import App from "./App.vue";

createApp(App).mount('#app')
createApp(App).mount("#app");
9 changes: 4 additions & 5 deletions vuejs/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
})
plugins: [vue()]
});

0 comments on commit 6c95494

Please sign in to comment.