Demo:支持粘贴md内容进行导入
This commit is contained in:
parent
be38eb2ca6
commit
c12189ca87
@ -197,7 +197,10 @@ export default {
|
|||||||
fileContentError: 'The file content is incorrect',
|
fileContentError: 'The file content is incorrect',
|
||||||
importSuccess: 'Import success',
|
importSuccess: 'Import success',
|
||||||
fileParsingFailed: 'File parsing failed',
|
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: {
|
navigatorToolbar: {
|
||||||
openMiniMap: 'Open mini map',
|
openMiniMap: 'Open mini map',
|
||||||
|
|||||||
@ -191,7 +191,10 @@ export default {
|
|||||||
fileContentError: '文件内容有误',
|
fileContentError: '文件内容有误',
|
||||||
importSuccess: '导入成功',
|
importSuccess: '导入成功',
|
||||||
fileParsingFailed: '文件解析失败',
|
fileParsingFailed: '文件解析失败',
|
||||||
xmindCanvasSelectDialogTitle: '选择要导入的画布'
|
xmindCanvasSelectDialogTitle: '选择要导入的画布',
|
||||||
|
mdImportDialogTitle: '粘贴Markdown内容导入',
|
||||||
|
mdPlaceholder: '请输入Markdown格式的内容',
|
||||||
|
mdEmptyTip: '内容不能为空'
|
||||||
},
|
},
|
||||||
navigatorToolbar: {
|
navigatorToolbar: {
|
||||||
openMiniMap: '开启小地图',
|
openMiniMap: '开启小地图',
|
||||||
|
|||||||
@ -192,7 +192,10 @@ export default {
|
|||||||
fileContentError: '檔案內容有誤',
|
fileContentError: '檔案內容有誤',
|
||||||
importSuccess: '匯入成功',
|
importSuccess: '匯入成功',
|
||||||
fileParsingFailed: '檔案解析失敗',
|
fileParsingFailed: '檔案解析失敗',
|
||||||
xmindCanvasSelectDialogTitle: '選擇要匯入的畫布'
|
xmindCanvasSelectDialogTitle: '選擇要匯入的畫布',
|
||||||
|
mdImportDialogTitle: '粘貼Markdown內容導入',
|
||||||
|
mdPlaceholder: '請輸入Markdown格式的內容',
|
||||||
|
mdEmptyTip: '內容不能爲空'
|
||||||
},
|
},
|
||||||
navigatorToolbar: {
|
navigatorToolbar: {
|
||||||
openMiniMap: '開啟小地圖',
|
openMiniMap: '開啟小地圖',
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
class="nodeImportDialog"
|
class="nodeImportDialog"
|
||||||
:title="$t('import.title')"
|
:title="$t('import.title')"
|
||||||
:visible.sync="dialogVisible"
|
:visible.sync="dialogVisible"
|
||||||
width="300px"
|
width="350px"
|
||||||
>
|
>
|
||||||
<el-upload
|
<el-upload
|
||||||
ref="upload"
|
ref="upload"
|
||||||
@ -21,6 +21,12 @@
|
|||||||
<el-button slot="trigger" size="small" type="primary">{{
|
<el-button slot="trigger" size="small" type="primary">{{
|
||||||
$t('import.selectFile')
|
$t('import.selectFile')
|
||||||
}}</el-button>
|
}}</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">
|
<div slot="tip" class="el-upload__tip">
|
||||||
{{ $t('import.support') }}{{ supportFileStr }}{{ $t('import.file') }}
|
{{ $t('import.support') }}{{ supportFileStr }}{{ $t('import.file') }}
|
||||||
</div>
|
</div>
|
||||||
@ -53,6 +59,27 @@
|
|||||||
}}</el-button>
|
}}</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-dialog>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -71,7 +98,9 @@ export default {
|
|||||||
selectPromiseResolve: null,
|
selectPromiseResolve: null,
|
||||||
xmindCanvasSelectDialogVisible: false,
|
xmindCanvasSelectDialogVisible: false,
|
||||||
selectCanvas: '',
|
selectCanvas: '',
|
||||||
canvasList: []
|
canvasList: [],
|
||||||
|
mdImportDialogVisible: false,
|
||||||
|
mdStr: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -321,6 +350,27 @@ export default {
|
|||||||
})
|
})
|
||||||
if (this.fileList.length <= 0) return
|
if (this.fileList.length <= 0) return
|
||||||
this.confirm()
|
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'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user