mirror of
https://github.com/marktext/marktext.git
synced 2025-05-02 11:32:13 +08:00

* feat: image setting * opti: inline image * add imageSelectAction * remove axios from muya * update image selector * finish image selector ui * add load success style * delete image by click delete icon * opti structure of image html * handle arrow key * enter to edit * image preview by press space * handle backspace when the previous element is image wrapper * update codes for change another PC * emable select all in input * handle arrow and backspace key * create a new paragraph after the last paragraph if its not empty * handle backspace when the previous element is image wrapper * handle enter event in image selector * rewrite auto show image selector * modify image folder * copy file to folder * select image * handle paste image * picgo * guess image path from clipboard * drag and drop image to Mark Text * add github uploader * remove unused codes * remove unused codes * rewrite image path auto complete * support `path` imageInsertAction * doc: add image uploader doc * remove debug codes * set init value in image uploader page * fix typo * remove unused codes * drag web image to Mark Text * add save notification * opti uploading process * fix did not close image selector bug * check image content type when drag web link image * fix: unable to preview relative path image. * emit change event after paste/drop image * add url map in image selector * feat: screenshot and auto insert the screenshot image * update error handler * feat: use the native screencapture command line on macOs system * opti: drop image * fix: handle enter error when cursor is after a image * fix: hasOwnProperty error * remove debug codes * fix: backspace when the previous ele is image * fix: CI error and optimize some codes * use hash of file path to generate the copied filename * change default imageInsertAction to `path` * fix: typo * remove some unused codes and opti get image file name * fix some bugs and opti codes * update image edit icon * romove screen capture on Linux and Windows * fix: conflict * fix error that can not insert image after the existed image or before existed image
160 lines
4.1 KiB
Vue
160 lines
4.1 KiB
Vue
<template>
|
|
<div class="pref-image-uploader">
|
|
<h4>Image Uploader</h4>
|
|
<section class="current-uploader">
|
|
<div>The current image uploader is <span class="uploader">{{currentUploader}}</span>.</div>
|
|
</section>
|
|
<separator></separator>
|
|
<section class="configration">
|
|
<el-tabs v-model="activeTab">
|
|
<el-tab-pane label="SM.MS" name="smms">
|
|
<div class="description">Thank you <span class="link" @click="open('https://sm.ms/')">SM.MS</span> for providing free uploading services.</div>
|
|
<el-button size="mini" @click="setCurrentUploader('smms')">Set As default Uploader</el-button>
|
|
</el-tab-pane>
|
|
<el-tab-pane label="Github" name="github">
|
|
<div class="form-group">
|
|
<div class="label">GitHub token:</div>
|
|
<el-input v-model="githubToken" placeholder="Input token" size="mini"></el-input>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="label">Owner name:</div>
|
|
<el-input v-model="github.owner" placeholder="owner" size="mini"></el-input>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="label">Repo name:</div>
|
|
<el-input v-model="github.repo" placeholder="repo" size="mini"></el-input>
|
|
</div>
|
|
<div class="form-group button-group">
|
|
<el-button size="mini" :disabled="githubDisable" @click="save('github')">Save</el-button>
|
|
<el-button size="mini" :disabled="githubDisable" @click="setCurrentUploader('github')">Set As default Uploader</el-button>
|
|
</div>
|
|
</el-tab-pane>
|
|
</el-tabs>
|
|
</section>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import Separator from '../common/separator'
|
|
import { shell } from 'electron'
|
|
export default {
|
|
components: {
|
|
Separator
|
|
},
|
|
data () {
|
|
return {
|
|
activeTab: 'smms',
|
|
githubToken: '',
|
|
github: {
|
|
owner: '',
|
|
repo: ''
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
currentUploader: {
|
|
get: function () {
|
|
return this.$store.state.preferences.currentUploader
|
|
}
|
|
},
|
|
imageBed: {
|
|
get: function () {
|
|
return this.$store.state.preferences.imageBed
|
|
}
|
|
},
|
|
prefGithubToken: {
|
|
get: function () {
|
|
return this.$store.state.preferences.githubToken
|
|
}
|
|
},
|
|
githubDisable () {
|
|
return !this.githubToken || !this.github.owner || !this.github.repo
|
|
}
|
|
},
|
|
watch: {
|
|
imageBed: function (value, oldValue) {
|
|
if (value !== oldValue) {
|
|
this.github = value.github
|
|
}
|
|
}
|
|
},
|
|
created () {
|
|
this.$nextTick(() => {
|
|
this.github = this.imageBed.github
|
|
this.githubToken = this.prefGithubToken
|
|
})
|
|
},
|
|
methods: {
|
|
handleImageChange (value) {
|
|
// console.log(value)
|
|
},
|
|
open (link) {
|
|
shell.openExternal(link)
|
|
},
|
|
save (type) {
|
|
const newImageBedConfig = Object.assign({}, this.imageBed, {[type]: this[type]})
|
|
this.$store.dispatch('SET_USER_DATA', {
|
|
type: 'imageBed',
|
|
value: newImageBedConfig
|
|
})
|
|
if (type === 'github') {
|
|
this.$store.dispatch('SET_USER_DATA', {
|
|
type: 'githubToken',
|
|
value: this.githubToken
|
|
})
|
|
}
|
|
new Notification('Save Image Uploader', {
|
|
body: `The Github configration has been saved.`
|
|
})
|
|
},
|
|
setCurrentUploader (value) {
|
|
const type = 'currentUploader'
|
|
this.$store.dispatch('SET_USER_DATA', { type, value })
|
|
|
|
new Notification('Set Image Uploader', {
|
|
body: `Set ${value} as the default image uploader successfully.`
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.pref-image-uploader {
|
|
& h4 {
|
|
text-transform: uppercase;
|
|
margin: 0;
|
|
font-weight: 100;
|
|
}
|
|
& .current-uploader {
|
|
font-size: 14px;
|
|
margin: 20px 0;
|
|
color: var(--editorColor);
|
|
& .uploader {
|
|
color: var(--editorColor80);
|
|
font-size: 600;
|
|
}
|
|
}
|
|
& .link {
|
|
color: var(--themeColor);
|
|
cursor: pointer;
|
|
}
|
|
& .description {
|
|
margin-top: 20px;
|
|
margin-bottom: 20px;
|
|
}
|
|
& .form-group {
|
|
margin: 20px 0 0 0;
|
|
}
|
|
& .label {
|
|
margin-bottom: 10px;
|
|
}
|
|
& .el-input {
|
|
max-width: 242px;
|
|
}
|
|
& .button-group {
|
|
margin-top: 30px;
|
|
}
|
|
}
|
|
</style>
|