mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 14:04:47 +08:00
Demo:支持粘贴md内容进行导入
This commit is contained in:
@@ -197,7 +197,10 @@ export default {
|
||||
fileContentError: 'The file content is incorrect',
|
||||
importSuccess: 'Import success',
|
||||
fileParsingFailed: 'File parsing failed',
|
||||
xmindCanvasSelectDialogTitle: 'Select the canvas to import'
|
||||
xmindCanvasSelectDialogTitle: 'Select the canvas to import',
|
||||
mdImportDialogTitle: 'Paste Markdown content to import',
|
||||
mdPlaceholder: 'Please enter the content in Markdown format',
|
||||
mdEmptyTip: 'The content cannot be empty'
|
||||
},
|
||||
navigatorToolbar: {
|
||||
openMiniMap: 'Open mini map',
|
||||
|
||||
@@ -191,7 +191,10 @@ export default {
|
||||
fileContentError: '文件内容有误',
|
||||
importSuccess: '导入成功',
|
||||
fileParsingFailed: '文件解析失败',
|
||||
xmindCanvasSelectDialogTitle: '选择要导入的画布'
|
||||
xmindCanvasSelectDialogTitle: '选择要导入的画布',
|
||||
mdImportDialogTitle: '粘贴Markdown内容导入',
|
||||
mdPlaceholder: '请输入Markdown格式的内容',
|
||||
mdEmptyTip: '内容不能为空'
|
||||
},
|
||||
navigatorToolbar: {
|
||||
openMiniMap: '开启小地图',
|
||||
|
||||
@@ -192,7 +192,10 @@ export default {
|
||||
fileContentError: '檔案內容有誤',
|
||||
importSuccess: '匯入成功',
|
||||
fileParsingFailed: '檔案解析失敗',
|
||||
xmindCanvasSelectDialogTitle: '選擇要匯入的畫布'
|
||||
xmindCanvasSelectDialogTitle: '選擇要匯入的畫布',
|
||||
mdImportDialogTitle: '粘貼Markdown內容導入',
|
||||
mdPlaceholder: '請輸入Markdown格式的內容',
|
||||
mdEmptyTip: '內容不能爲空'
|
||||
},
|
||||
navigatorToolbar: {
|
||||
openMiniMap: '開啟小地圖',
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
class="nodeImportDialog"
|
||||
:title="$t('import.title')"
|
||||
:visible.sync="dialogVisible"
|
||||
width="300px"
|
||||
width="350px"
|
||||
>
|
||||
<el-upload
|
||||
ref="upload"
|
||||
@@ -21,6 +21,12 @@
|
||||
<el-button slot="trigger" size="small" type="primary">{{
|
||||
$t('import.selectFile')
|
||||
}}</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
style="margin-left: 10px;"
|
||||
@click="mdImportDialogVisible = true"
|
||||
>{{ $t('import.mdImportDialogTitle') }}</el-button
|
||||
>
|
||||
<div slot="tip" class="el-upload__tip">
|
||||
{{ $t('import.support') }}{{ supportFileStr }}{{ $t('import.file') }}
|
||||
</div>
|
||||
@@ -53,6 +59,27 @@
|
||||
}}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
class="mdImportDialog"
|
||||
:title="$t('import.mdImportDialogTitle')"
|
||||
:visible.sync="mdImportDialogVisible"
|
||||
width="500px"
|
||||
:show-close="false"
|
||||
>
|
||||
<el-input
|
||||
type="textarea"
|
||||
:rows="10"
|
||||
:placeholder="$t('import.mdPlaceholder')"
|
||||
v-model="mdStr"
|
||||
>
|
||||
</el-input>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancelImportMd">{{ $t('dialog.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="confirmImportFromMd">{{
|
||||
$t('dialog.confirm')
|
||||
}}</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -71,7 +98,9 @@ export default {
|
||||
selectPromiseResolve: null,
|
||||
xmindCanvasSelectDialogVisible: false,
|
||||
selectCanvas: '',
|
||||
canvasList: []
|
||||
canvasList: [],
|
||||
mdImportDialogVisible: false,
|
||||
mdStr: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -321,6 +350,27 @@ export default {
|
||||
})
|
||||
if (this.fileList.length <= 0) return
|
||||
this.confirm()
|
||||
},
|
||||
|
||||
cancelImportMd() {
|
||||
this.mdImportDialogVisible = false
|
||||
this.mdStr = ''
|
||||
},
|
||||
|
||||
confirmImportFromMd() {
|
||||
if (!this.mdStr.trim()) {
|
||||
this.$message.warning(this.$t('import.mdEmptyTip'))
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = markdown.transformMarkdownTo(this.mdStr.trim())
|
||||
this.$bus.$emit('setData', data)
|
||||
this.$message.success(this.$t('import.importSuccess'))
|
||||
this.cancelImportMd()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
this.$message.error(this.$t('import.fileParsingFailed'))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user