* [misc] support for importing confluence content to editor.

This commit is contained in:
sunhao
2025-03-10 10:00:22 +08:00
committed by 刘刚
parent b4a6d11980
commit 55899d3d21
5 changed files with 26 additions and 6 deletions
+22 -6
View File
@@ -673,10 +673,24 @@ function renameDocFile(file, doc)
});
}
/* Import markdown or json file to editor. */
function importFileToEditor(type)
async function importContentToEditor(type)
{
const accept = type === 'markdown' ? '.md' : '.json';
const docApp = getDocApp();
if(!docApp) return;
const editor = docApp.editor.$;
if(!editor) return;
let content = '';
if(navigator.clipboard) content = await navigator.clipboard.readText();
content = await zui.Modal.prompt({size: 'lg', message: `Import ${type}`, defaultValue: content, placeholder: 'Paste content here...', multiline: true});
return getDocApp().importDoc(content, type);
}
/* Import markdown or json file to editor. */
function importFileToEditor(type, options)
{
if(options && options.fromText) return importContentToEditor(type);
const accept = type === 'markdown' ? '.md' : (type === 'confluence' ? '.html,.txt' : '.json');
return zui.selectFile(accept).then(file => {
if(!file) return;
zui.readFile(file).then(content => {
@@ -981,6 +995,7 @@ const actionsMap =
const moreItems = [];
if((doc.contentType === 'doc' || doc.contentType === 'markdown') && !isApiDoc(doc))
{
if(config.debug > 5) moreItems.push({text: lang.importConfluence, command: 'importFile/confluence'});
moreItems.push(
{text: lang.importMarkdown, command: 'importFile/markdown'},
{text: lang.importJSON, command: 'importFile/json'},
@@ -1365,14 +1380,15 @@ const commands =
const url = $.createLink('api', 'export', `libID=${libID}&version=0&release=${release}&moduleID=${moduleID}`);
zui.Modal.open({url: url, size: 'sm'});
},
importFile: function(_, args)
importFile: function(info, args)
{
const type = args[0] || 'markdown';
const docApp = getDocApp();
const editor = docApp.editor.$;
if(editor.isEmpty) return importFileToEditor(type);
const altKey = info.event.altKey;
if(editor.isEmpty) return importFileToEditor(type, {fromText: altKey});
zui.Modal.confirm({message: getLang('importConfirm')})
.then((result) => result && importFileToEditor(type));
.then((result) => result && importFileToEditor(type, {fromText: altKey}));
},
showDocSettingModal: function(_, args)
{
+1
View File
@@ -510,6 +510,7 @@ $lang->doc->docLang->exportHtml = "Export HTML";
$lang->doc->docLang->exportMarkdown = "Export Markdown";
$lang->doc->docLang->exportJSON = "Export Backup(.json)";
$lang->doc->docLang->importMarkdown = "Import Markdown";
$lang->doc->docLang->importConfluence = "Import Confluence Storage";
$lang->doc->docLang->importJSON = "Import Backup(.json)";
$lang->doc->docLang->importConfirm = "Import will overwrite the current document content. Are you sure you want to import?";
$lang->doc->docLang->settings = $lang->settings;
+1
View File
@@ -510,6 +510,7 @@ $lang->doc->docLang->exportHtml = "Export HTML";
$lang->doc->docLang->exportMarkdown = "Export Markdown";
$lang->doc->docLang->exportJSON = "Export Backup(.json)";
$lang->doc->docLang->importMarkdown = "Import Markdown";
$lang->doc->docLang->importConfluence = "Import Confluence Storage";
$lang->doc->docLang->importJSON = "Import Backup(.json)";
$lang->doc->docLang->importConfirm = "Import will overwrite the current document content. Are you sure you want to import?";
$lang->doc->docLang->settings = $lang->settings;
+1
View File
@@ -510,6 +510,7 @@ $lang->doc->docLang->exportHtml = "Export HTML";
$lang->doc->docLang->exportMarkdown = "Export Markdown";
$lang->doc->docLang->exportJSON = "Export Backup(.json)";
$lang->doc->docLang->importMarkdown = "Import Markdown";
$lang->doc->docLang->importConfluence = "Import Confluence Storage";
$lang->doc->docLang->importJSON = "Import Backup(.json)";
$lang->doc->docLang->importConfirm = "Import will overwrite the current document content. Are you sure you want to import?";
$lang->doc->docLang->settings = $lang->settings;
+1
View File
@@ -511,6 +511,7 @@ $lang->doc->docLang->exportMarkdown = "导出 Markdown";
$lang->doc->docLang->exportJSON = "导出备份(.json)";
$lang->doc->docLang->importMarkdown = "导入 Markdown";
$lang->doc->docLang->importJSON = "导入备份(.json)";
$lang->doc->docLang->importConfluence = "导入 Confluence 存储格式";
$lang->doc->docLang->importConfirm = "导入将覆盖当前文档内容,确定导入吗?";
$lang->doc->docLang->settings = $lang->settings;
$lang->doc->docLang->save = $lang->save;