Skip to content

Commit dde5866

Browse files
committed
moving query-builder-vue-3 from package.json to utils, adding shiki to replace vue-code-highlight module
1 parent b24eeda commit dde5866

15 files changed

Lines changed: 4945 additions & 524 deletions

File tree

package-lock.json

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

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"lodash": "^4.17.21",
3939
"lodash-es": "^4.18.1",
4040
"moment": "^2.29.1",
41-
"query-builder-vue-3": "^1.0.1",
4241
"roboto-fontface": "^0.10.0",
42+
"shiki": "^4.1.0",
4343
"sigma": "^2.4.0",
4444
"simple-analytics-vue": "^3.0.2",
4545
"trace-unhandled": "^2.0.1",
@@ -48,7 +48,6 @@
4848
"vike-vue": "^0.9.11",
4949
"vue": "^3.4.35",
5050
"vue-3-sanitize": "^0.1.4",
51-
"vue-code-highlight": "^0.7.8",
5251
"vue-country-flag-next": "^2.3.2",
5352
"vue-eslint-parser": "^9.4.3",
5453
"vue-gtag": "^2.1.0",
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<template>
2+
<div class="code-block-wrapper">
3+
<div class="code-header">
4+
<span class="dot bg-red"></span>
5+
<span class="dot bg-yellow"></span>
6+
<span class="dot bg-green"></span>
7+
<span class="lang-label">{{ lang }}</span>
8+
</div>
9+
10+
<div v-safe-html="highlightedHtml" class="shiki-container"></div>
11+
12+
<div ref="sourceElement" style="display: none"><slot></slot></div>
13+
</div>
14+
</template>
15+
16+
<script setup>
17+
import {nextTick, onMounted, ref} from "vue";
18+
import {codeToHtml} from "shiki";
19+
20+
const props = defineProps({
21+
lang: { type: String, default: "javascript" },
22+
theme: { type: String, default: "tokyo-night" },
23+
});
24+
25+
const sourceElement = ref(null);
26+
const highlightedHtml = ref("");
27+
28+
onMounted(async () => {
29+
await nextTick();
30+
// Extract text content after Vue fills variables like {{ loginUrl }}
31+
let rawCode =
32+
sourceElement.value?.innerText || sourceElement.value?.textContent || "";
33+
34+
// Clean up initial and trailing whitespace artifacts from <pre> tags
35+
rawCode = rawCode.replace(/^\s*[\r\n]/, "").trimEnd();
36+
37+
try {
38+
highlightedHtml.value = await codeToHtml(rawCode, {
39+
lang: props.lang,
40+
theme: props.theme,
41+
});
42+
}
43+
catch (err) {
44+
console.error("Shiki highlighting failed:", err);
45+
highlightedHtml.value = `<pre><code>${rawCode}</code></pre>`;
46+
}
47+
});
48+
</script>
49+
50+
<style scoped>
51+
.code-block-wrapper {
52+
border-radius: 8px;
53+
overflow: hidden;
54+
margin: 1.5rem 0;
55+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
56+
}
57+
.code-header {
58+
background: #16161e;
59+
padding: 0.6rem 1rem;
60+
display: flex;
61+
align-items: center;
62+
gap: 0.5rem;
63+
border-bottom: 1px solid #24283b;
64+
}
65+
.dot {
66+
width: 12px;
67+
height: 12px;
68+
border-radius: 50%;
69+
}
70+
.red {
71+
background: #ff5f56;
72+
}
73+
.yellow {
74+
background: #ffbd2e;
75+
}
76+
.green {
77+
background: #27c93f;
78+
}
79+
.lang-label {
80+
margin-left: auto;
81+
color: #565f89;
82+
font-size: 0.75rem;
83+
text-transform: uppercase;
84+
font-family: monospace;
85+
font-weight: bold;
86+
}
87+
:deep(.shiki) {
88+
margin: 0 !important;
89+
padding: 1.2rem !important;
90+
overflow-x: auto;
91+
font-family: "Fira Code", Consolas, Monaco, monospace;
92+
font-size: 0.9rem;
93+
line-height: 1.5;
94+
}
95+
</style>

src/pages/+onCreateApp.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
/* Directives & Plugins Imports */
2-
import "vue-code-highlight/themes/prism-twilight.css";
3-
import "vue-code-highlight/themes/window.css";
42
import linkify from "vue-3-linkify";
53
import {createMetaManager} from "vue-meta";
64
import Vue3Sanitize from "vue-3-sanitize";
75
import DOMPurify from "dompurify";
8-
9-
/* App Core Imports - CHANGE THESE TO FACTORY FUNCTIONS */
106
import {createMyRouter} from "@/router";
117
import {createMyStore} from "@/store";
128
import createVuetify from "@/plugins/vuetify";
139
import {bootstrapApp, globalFilters} from "@/utils/setupUtils";
14-
1510
/* Styles */
11+
import CodeBlock from "@/components/Static/APIDoc/CodeBlock.vue";
1612
import "roboto-fontface/css/roboto/roboto-fontface.css";
1713
import "@fortawesome/fontawesome-free/css/all.css";
1814
import "vue-json-pretty/lib/styles.css";
@@ -21,7 +17,7 @@ export default async (pageContext) => {
2117
const { app } = pageContext;
2218
const isServer = typeof window === "undefined";
2319

24-
// 1. Create unique, isolated instances for this specific request
20+
// Create unique, isolated instances for this specific request
2521
const store = createMyStore();
2622
const router = createMyRouter(store);
2723

@@ -30,15 +26,19 @@ export default async (pageContext) => {
3026

3127
await bootstrapApp(store, router);
3228

33-
// 2. Safely sync the unique router instance to the current URL
29+
// Safely sync the unique router instance to the current URL
3430
if (isServer) {
3531
router.push(pageContext.urlPathname);
3632
}
3733

3834
// 3. Plugins that are SAFE for both Server and Client
39-
app.use(createVuetify).use(createMetaManager()).use(Vue3Sanitize);
35+
const vuetifyPlugin =
36+
typeof createVuetify === "function" ? createVuetify() : createVuetify;
37+
app.use(vuetifyPlugin).use(createMetaManager()).use(Vue3Sanitize);
38+
39+
app.component("CodeBlock", CodeBlock);
4040

41-
// 4. Plugins that MUST ONLY run in the Browser (Client)
41+
// Plugins that MUST ONLY run in the Browser (Client)
4242
if (!isServer) {
4343
const { default: HighchartsVue } = await import("highcharts-vue");
4444
const { default: Highcharts } = await import("highcharts");
@@ -47,7 +47,6 @@ export default async (pageContext) => {
4747
);
4848
const { default: SimpleAnalytics } = await import("simple-analytics-vue");
4949
// const { default: VueGtag } = await import("vue-gtag");
50-
const { default: VueCodeHighlight } = await import("vue-code-highlight");
5150
const { default: VueScrollTo } = await import("vue-scrollto");
5251
const { default: Particles } = await import("@tsparticles/vue3");
5352
const { loadFull } = await import("tsparticles");
@@ -63,7 +62,6 @@ export default async (pageContext) => {
6362
})
6463
.use(HighchartsVue)
6564
.use(VueScrollTo)
66-
.use(VueCodeHighlight)
6765
// .use(VueGtag, {
6866
// config: { id: import.meta.env.VUE_APP_ANALYTICS_ID },
6967
// })
@@ -81,6 +79,6 @@ export default async (pageContext) => {
8179
// Global Properties
8280
app.config.globalProperties.$filters = globalFilters;
8381

84-
// 5. Await the isolated router so the server waits for route components to resolve
82+
// Await the isolated router so the server waits for route components to resolve
8583
await router.isReady();
8684
};

src/router/routes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export const Record = () => import("@/views/Records/Record");
55
export const Records = () => import("@/views/Records/Records");
66
export const NewRecord = () => import("@/views/CreateRecord/NewRecord");
77
export const Editor = () => import("@/views/CreateRecord/Editor");
8-
export const Login = () => import("@/views/Users/Login/Login");
8+
// export const Login = () => import("@/views/Users/Login/Login");
9+
export { default as Login } from "@/views/Users/Login/Login.vue";
910
export const Signup = () => import("@/views/Users/Signup");
1011
export const ConfirmAccount = () => import("@/views/Users/ConfirmAccount.vue");
1112
export const ResendConfirmation = () =>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Rudolf Tucek
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[![CI Testing](https://github.com/rtucek/vue-query-builder/actions/workflows/ci-testing.yml/badge.svg)](https://github.com/rtucek/vue-query-builder/actions/workflows/ci-testing.yml)
2+
[![CI Build](https://github.com/rtucek/vue-query-builder/actions/workflows/ci-build.yml/badge.svg)](https://github.com/rtucek/vue-query-builder/actions/workflows/ci-build.yml)
3+
[![Lint](https://github.com/rtucek/vue-query-builder/actions/workflows/lint.yml/badge.svg)](https://github.com/rtucek/vue-query-builder/actions/workflows/lint.yml)
4+
[![npm version](https://img.shields.io/npm/v/query-builder-vue-3)](https://www.npmjs.com/package/query-builder-vue-3)
5+
[![MIT LICENSE](https://img.shields.io/npm/l/query-builder-vue-3)](https://github.com/rtucek/vue-query-builder/blob/master/LICENSE)
6+
7+
# Vue 3 Query Builder
8+
9+
A query-builder for Vue ported to Vue 3.
10+
11+
12+
## Demos
13+
14+
Plenty of samples and use cases are covered in the
15+
[documentation](https://rtucek.github.io/vue-query-builder/demos.html).
16+
17+
18+
## Features
19+
20+
Key features:
21+
22+
- Re-ordering of rules and groups with drag'n'drop.
23+
- Emphasizing groups with configurable colors.
24+
- Control maximum depth of nested groups.
25+
- Easy to customize with pure CSS and slots.
26+
- Layout can be serialized and restored.
27+
- Vuex compatible.
28+
- TypeScript support.
29+
30+
31+
## Installation
32+
33+
```bash
34+
yarn add query-builder-vue-3
35+
npm install query-builder-vue-3
36+
```
37+
38+
Follow the docs for [minimum
39+
configuration](https://rtucek.github.io/vue-query-builder/getting-started.html#usage).
40+
41+
42+
## Contribution
43+
44+
[Contribution guidelines](https://rtucek.github.io/vue-query-builder/contributing.html) are located
45+
in the documentation.
46+
47+
## Major Props To
48+
49+
- https://github.com/rtucek/vue-query-builder/pull/93
50+
- @kwesterfeld2

0 commit comments

Comments
 (0)