Frontend: Removed the search component entirely

This commit is contained in:
Natty 2023-07-20 16:05:33 +02:00
parent 0bd60f4e41
commit 7c871cd886
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
2 changed files with 24 additions and 102 deletions

View File

@ -1,59 +0,0 @@
<template>
<div class="mk-google" @click.stop>
<input v-model="query" type="search" :placeholder="q" />
<button @click="search">
<i class="ph-magnifying-glass ph-bold ph-lg"></i>
{{ i18n.ts.searchByGoogle }}
</button>
</div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { i18n } from "@/i18n";
const props = defineProps<{
q: string;
}>();
const query = ref(props.q);
const search = () => {
window.open(
`https://search.annoyingorange.xyz/search?q=${query.value}`,
"_blank"
);
};
</script>
<style lang="scss" scoped>
.mk-google {
display: flex;
margin: 8px 0;
> input {
flex-shrink: 1;
padding: 10px;
width: 100%;
height: 40px;
font-size: 16px;
border: solid 1px var(--divider);
border-radius: 4px 0 0 4px;
-webkit-appearance: none;
-webkit-border-radius: 4px 0 0 4px;
}
> button {
flex-shrink: 0;
margin: 0;
padding: 0 16px;
border: solid 1px var(--divider);
border-left: none;
border-radius: 0 4px 4px 0;
&:active {
box-shadow: 0 2px 4px rgba(#000, 0.15) inset;
}
}
}
</style>

View File

@ -8,7 +8,6 @@ import MkEmoji from "@/components/global/MkEmoji.vue";
import { concat } from "@/scripts/array"; import { concat } from "@/scripts/array";
import MkFormula from "@/components/MkFormula.vue"; import MkFormula from "@/components/MkFormula.vue";
import MkCode from "@/components/MkCode.vue"; import MkCode from "@/components/MkCode.vue";
import MkGoogle from "@/components/MkGoogle.vue";
import MkSparkle from "@/components/MkSparkle.vue"; import MkSparkle from "@/components/MkSparkle.vue";
import MkA from "@/components/global/MkA.vue"; import MkA from "@/components/global/MkA.vue";
import { host } from "@/config"; import { host } from "@/config";
@ -494,53 +493,35 @@ export default defineComponent({
} }
case "search": { case "search": {
// Disable "search" keyword
// (see the issue #9816 on Codeberg)
if (token.props.content.slice(-6).toLowerCase() === "search") {
const sentinel = "#";
let ast2 = (isPlain ? mfm.parseSimple : mfm.parse)(
token.props.content.slice(0, -6) + sentinel,
);
if (
ast2[ast2.length - 1].type === "text" &&
ast2[ast2.length - 1].props.text.endsWith(sentinel)
) {
ast2[ast2.length - 1].props.text = ast2[
ast2.length - 1
].props.text.slice(0, -1);
} else {
// I don't think this scope is reachable
console.warn(
"Something went wrong while parsing MFM. Please send a bug report, if possible.",
);
}
let prefix = "\n"; const sentinel = "#";
if ( let ast2 = (isPlain ? mfm.parseSimple : mfm.parse)(
index === 0 || token.props.content + sentinel,
[ );
"blockCode", if (
"center", ast2[ast2.length - 1].type === "text" &&
"mathBlock", ast2[ast2.length - 1].props.text.endsWith(sentinel)
"quote", ) {
"search", ast2[ast2.length - 1].props.text = ast2[ast2.length - 1].props.text.slice(0, -1);
].includes(ast[index - 1].type) }
) {
prefix = "";
}
return [ let prefix = "\n";
prefix, if (
...genEl(ast2), index === 0 ||
`${token.props.content.slice(-6)}\n`, [
]; "blockCode",
"center",
"mathBlock",
"quote",
"search",
].includes(ast[index - 1].type)
) {
prefix = "";
} }
return [ return [
h(MkGoogle, { prefix,
key: Math.random(), ...genEl(ast2)
q: token.props.query,
}),
]; ];
} }