Skip to content

Commit

Permalink
Merge pull request laorange#4 from laorange/dev
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
laorange authored Feb 8, 2023
2 parents 8867423 + 741ef50 commit 6d00f90
Show file tree
Hide file tree
Showing 26 changed files with 263 additions and 136 deletions.
39 changes: 15 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
# 论文助手

▶️视频介绍:[[论文工具] PDF复制-智能删除空格空行](https://www.bilibili.com/video/BV1T24y1X78w/)

## 在线使用

[GitHub Page](https://laorange.github.io/paper-assistant/)[国内镜像站(Gitee Page)](https://laorange.gitee.io/paper-assistant)
<h1 align="center">论文工具</h1>

<p align="center">
<a href="https://laorange.github.io/paper-assistant/">在线使用(GitHub)</a>
|
<a href="https://laorange.gitee.io/paper-assistant">在线使用(Gitee)</a>
|
<a href="https://www.bilibili.com/video/BV1T24y1X78w/">视频介绍</a>
|
<a href="/src/assets/UpdatedLogs.md">更新日志</a>
</p>

## 功能

### (1) 文本复制工具

在复制PDF中的文字时,有时会出现莫名其妙的空格、换行。
在复制PDF中的文字时,有时会出现莫名其妙的空格、换行、全角字符

如果手动删改,工作量巨大;如果直接全文替换,可能会误删英文单词间的空格。

因此,可以使用本程序,目前有以下可选功能:

1. 将英文标点转换为中文标点
2. 将中文标点转换为英文标点
3. 全角字符转半角字符
4. 删除重复的换行符
5. 将换行符替换为空格
6. 删除重复的空格
7. 删除非英文字母间的空格
8. 在字母与数字之间添加空格
9. 在标点符号后添加空格
10. 删除小数点和数字之间的空格
11. 删除冒号和数字之间的空格
因此,可以使用本程序去除空行空格。详细文档请在[网页](https://laorange.gitee.io/paper-assistant)中点击"使用说明"。

### (2) 英文语法检查

如果①输入的是英文 ②使用电脑访问,将自动检测输入文字的语法错误(基于[Grammarly](https://developer.grammarly.com/)
如果您在电脑上在线使用,在输入英文时,将为您检查语法✍ (基于[Grammarly](https://developer.grammarly.com/))。

## 致开发者

Expand All @@ -45,5 +37,4 @@ export interface TextHandler {
}
```

如您有好的想法,可以在以上内容的基础上修改,欢迎在GitHub仓库上发起 `pull request`😊

如您有好的想法,可以在以上内容的基础上修改,欢迎在GitHub仓库上发起 [`pull request`](https://github.com/laorange/paper-assistant/pulls)😊
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": false,
"author": "laorange",
"license": "AGPL-3.0",
"version": "1.0.0",
"version": "1.1.0",
"type": "module",
"scripts": {
"dev": "vite --host",
Expand Down
8 changes: 8 additions & 0 deletions src/assets/UpdatedLogs.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### v1.1.0 (2023-02-08)

新增:自动清空输入、复制输出的可选功能

新增:支持选择布局方式、是否实时输出

优化:离开页面后,返回时输入框自动获得焦点

### v1.0.0 (2023-02-07)

新增:可设定浅色/深色主题
Expand Down
1 change: 0 additions & 1 deletion src/assets/ts/article-copy-tool/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export const textHandlers: TextHandlers = {
if (char > 65280 && char < 65375
// 对,:;·!#¥%…这样的全角字符不做转换
&& [...",:;·!#¥%…"].indexOf(text[i]) === -1) {
console.log([...",:;·!#¥%…"].indexOf(text[i]));
result += String.fromCharCode(char - 65248);
} else result += String.fromCharCode(text.charCodeAt(i));
}
Expand Down
20 changes: 20 additions & 0 deletions src/assets/ts/article-copy-tool/useIntroducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ export default function useIntroducer() {
title: "更新日志",
intro: "查看本网站的版本迭代过程",
},
{
element: document.querySelector(".clear-input-when-leave-switch"),
title: `自动清空输入`,
intro: `(若启用该项)当离开本网页时,输入框中的内容将会被自动清空,以便返回时重新输入新内容`,
},
{
element: document.querySelector(".copy-output-when-leave-switch"),
title: `自动复制输出`,
intro: `(若启用该项)当离开本网页时,输出框中的内容将会被自动复制,以便在别处使用`,
},
{
element: document.querySelector(".auto-output-switch"),
title: `实时输出`,
intro: `若启用该项,每当修改输入框中的内容时,均会实时输出;若关闭该项,仅会在手动点击输出按钮时输出文本`,
},
{
element: document.querySelector(".horizontal-layout-switch"),
title: `布局方式`,
intro: `调整"输入框"与"输出框"之间的位置关系为水平/竖直`,
},
{
element: document.querySelector(".input-area"),
title: "输入框",
Expand Down
66 changes: 4 additions & 62 deletions src/pages/article-copy-tool/ArticleCopyTool.vue
Original file line number Diff line number Diff line change
@@ -1,73 +1,15 @@
<script setup lang="ts">
import {computed} from "vue";
import {useStore} from "../../store/useStore";
import UpdateLogDisplayUnit from "../components/UpdatedLogDisplayUnit.vue";
import InputArea from "./components/InputArea.vue";
import InputFuncButtons from "./components/InputFuncButtons.vue";
import OutputArea from "./components/OutputArea.vue";
import OutputFuncButtons from "./components/OutputFuncButtons.vue";
import TextHandlerConfig from "./components/TextHandlerConfig.vue";
import ThemeConfig from "./components/ThemeConfig.vue";
import HelpButton from "./components/HelpButton.vue";
import SelectionReplace from "./components/SelectionReplace.vue";
const store = useStore();
const cols = computed<string>(() => {
if (store.copy.inputText.length > 500) {
// 输入文本过长,转为在一行显示
return `1`;
} else if (store.copy.outputText.length === 0) {
return `1`;
} else {
return `1 850:2`;
}
});
import HeaderArea from "./components/HeaderArea/HeaderArea.vue";
import InputAndOutputArea from "./components/InputAndOutputArea/InputAndOutputArea.vue";
</script>

<template>
<div class="article-copy-tool">
<header>
<h1>论文工具</h1>
<n-space vertical>
<n-space wrap="wrap" justify="center">
<n-space>
<HelpButton/>
<TextHandlerConfig/>
</n-space>
<n-space>
<ThemeConfig/>
<UpdateLogDisplayUnit v-model:show="store.showUpdateLog"/>
</n-space>
</n-space>
<SelectionReplace/>
</n-space>
</header>

<n-grid :cols="cols" x-gap="10" y-gap="20">
<n-gi>
<InputArea/>
<InputFuncButtons/>
</n-gi>

<n-gi v-if="store.copy.outputText.length">
<OutputArea/>
<OutputFuncButtons/>
</n-gi>
</n-grid>
<HeaderArea title="论文工具"/>
<InputAndOutputArea/>
</div>
</template>

<style scoped>
h1 {
text-align: center;
}
header {
margin-bottom: 15px;
display: flex;
flex-direction: column;
justify-items: center;
align-items: center;
}
</style>
47 changes: 47 additions & 0 deletions src/pages/article-copy-tool/components/HeaderArea/HeaderArea.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script setup lang="ts">
import UpdateLogDisplayUnit from "./components/UpdatedLogDisplayUnit.vue";
import TextHandlerConfig from "./components/TextHandlerConfig.vue";
import ThemeConfig from "./components/ThemeConfig.vue";
import HelpButton from "./components/HelpButton.vue";
import SelectionReplace from "./components/SelectionReplace/SelectionReplace.vue";
import AdditionalConfig from "./components/AdditionalConfig/AdditionalConfig.vue";
import {useStore} from "../../../../store/useStore";
defineProps<{ title: string }>();
const store = useStore();
</script>

<template>
<header>
<h1>{{ title }}</h1>
<n-space vertical>
<n-space wrap="wrap" justify="center">
<n-space>
<HelpButton/>
<TextHandlerConfig/>
</n-space>
<n-space>
<ThemeConfig/>
<UpdateLogDisplayUnit v-model:show="store.showUpdateLog"/>
</n-space>
</n-space>
<AdditionalConfig/>
<SelectionReplace/>
</n-space>
</header>
</template>

<style scoped lang="scss">
header {
margin-bottom: 5px;
display: flex;
flex-direction: column;
justify-items: center;
align-items: center;
h1 {
text-align: center;
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<script setup lang="ts">
import {useStore} from "../../../../../../store/useStore";
import ConfigSwitchButton from "./components/ConfigSwitchButton.vue";
import useClipboard from "vue-clipboard3";
import {onBeforeUnmount, onMounted} from "vue";
import {useMessage} from "naive-ui";
const store = useStore();
const {toClipboard} = useClipboard();
const message = useMessage();
const THRESHOLD_WIDTH = 600;
const hasNotEnoughWidth = document.body.clientWidth < THRESHOLD_WIDTH;
function onLeavePage() {
if (document.hidden) {
if (store.storage.copy.copyOutputWhenLeave && store.copy.outputText) {
toClipboard(store.copy.outputText).then(() => message.success("复制输出文本: 成功"));
}
if (store.storage.copy.clearInputWhenLeave) store.copy.inputText = "";
}
}
onMounted(() => {
document.addEventListener("visibilitychange", onLeavePage);
if (hasNotEnoughWidth) {
store.storage.copy.horizontalLayout = false;
}
});
onBeforeUnmount(() => {
document.removeEventListener("visibilitychange", onLeavePage);
});
</script>

<template>
<n-space justify="center" align="center" wrap="wrap">
<n-space>
<ConfigSwitchButton class="clear-input-when-leave-switch" label="自动清空输入" v-model:status="store.storage.copy.clearInputWhenLeave"/>
<ConfigSwitchButton class="copy-output-when-leave-switch" label="自动复制输出" v-model:status="store.storage.copy.copyOutputWhenLeave"/>
</n-space>
<n-space>
<ConfigSwitchButton class="auto-output-switch" label="实时输出" v-model:status="store.storage.copy.autoOutput"/>
<ConfigSwitchButton class="horizontal-layout-switch" label="布局方式" v-model:status="store.storage.copy.horizontalLayout"
true-label="水平" false-label="竖直" :disabled="hasNotEnoughWidth"/>
</n-space>
</n-space>
</template>

<style scoped>
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script setup lang="ts">
import {computed} from "vue";
const props = withDefaults(defineProps<{
label: string, status: boolean, trueLabel?: string, falseLabel?: string, disabled?: boolean,
}>(), {trueLabel: "", falseLabel: ""});
const emits = defineEmits(["update:status"]);
const statusLocal = computed<boolean>({
get: () => props.status,
set: (newValue) => emits("update:status", newValue),
});
const statusString = computed(() => statusLocal.value ? props.trueLabel : props.falseLabel);
</script>

<template>
<n-button @click="statusLocal = !statusLocal"
tertiary
:disabled="!!disabled"
:type="statusLocal ? `primary` : `default`">
{{ label }}:{{ statusString }}
</n-button>
</template>

<style scoped>
</style>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import {HelpCircle} from "@vicons/ionicons5";
import useIntroducer from "../../../assets/ts/article-copy-tool/useIntroducer";
import useIntroducer from "../../../../../assets/ts/article-copy-tool/useIntroducer";
const {introduce} = useIntroducer();
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import {useStore} from "../../../store/useStore";
import SelectionReplaceEditor from "./SelectionReplaceEditor.vue";
import {useStore} from "../../../../../../store/useStore";
import SelectionReplaceEditor from "./components/SelectionReplaceEditor.vue";
import {watch} from "vue";
import {HelpCircle} from "@vicons/ionicons5";
import useIntroducer from "../../../assets/ts/article-copy-tool/useIntroducer";
import useIntroducer from "../../../../../../assets/ts/article-copy-tool/useIntroducer";
const store = useStore();
const {introduceSelectionReplace} = useIntroducer();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<script setup lang="ts">
import {textHandlers, TextHandlerWithName} from "../../../assets/ts/article-copy-tool/handlers";
import {textHandlers, TextHandlerWithName} from "../../../../../assets/ts/article-copy-tool/handlers";
import {ref, watch} from "vue";
import {useStore} from "../../../store/useStore";
import {useStore} from "../../../../../store/useStore";
import Draggable from "vuedraggable";
import {SettingsSharp, HelpCircle} from "@vicons/ionicons5";
import useIntroducer from "../../../assets/ts/article-copy-tool/useIntroducer";
import useIntroducer from "../../../../../assets/ts/article-copy-tool/useIntroducer";
const store = useStore();
const {introduceTextHandler} = useIntroducer();
const showConfigDrawer = ref(false);
const refTextHandlerArray = ref<TextHandlerWithName[]>(store.textHandlerArray);
watch(() => store.copy.inputText, store.transformText);
watch(() => refTextHandlerArray.value, (ths) => {
let handlerOptions: typeof store.storage.copy.handlerOptions = {};
ths.map((th, index) => handlerOptions[th.handlerName] = {order: index, activate: th.activate});
Expand Down Expand Up @@ -45,7 +44,7 @@ function turnOffAllTextHandler() {
</n-badge>
</div>

<n-drawer v-model:show="showConfigDrawer" :height="`${Object.keys(textHandlers).length * 50 + 125}px`" placement="bottom">
<n-drawer v-model:show="showConfigDrawer" :height="`min(${Object.keys(textHandlers).length * 50 + 125}px, 100vh)`" placement="bottom">
<n-drawer-content :closable="true">
<template #header>
<n-space align="center">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import {useStore} from "../../../store/useStore";
import {useStore} from "../../../../../store/useStore";
import {Moon, Sunny} from "@vicons/ionicons5";
const store = useStore();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import {computed} from "vue";
import UpdatedLogs from "../../assets/UpdatedLogs.md";
import UpdatedLogs from "../../../../../assets/UpdatedLogs.md";
import {AnalyticsOutline} from "@vicons/ionicons5";
const props = defineProps<{ show: boolean }>();
Expand Down
Loading

0 comments on commit 6d00f90

Please sign in to comment.