* [ui] add method to import file to doc editor.

This commit is contained in:
sunhao
2025-01-02 08:31:10 +08:00
committed by 丁永亮
parent 2c0eb4d620
commit b5453790ca
+13
View File
@@ -578,6 +578,19 @@ function renameDocFile(file, doc)
});
}
/* Import markdown or json file to editor. */
function importFileToEditor(type)
{
const accept = type === 'markdown' ? '.md' : '.json';
return zui.selectFile(accept).then(file => {
if(!file) return;
zui.readFile(file).then(content => {
if(typeof content !== 'string' || !content.length) return;
return getDocApp().importDoc(content, type, file.name.split('.').shift());
});
});
}
/**
* 定义文档各个试图和 UI 元素的上的操作方法。
* Define the operation methods on the views and UI elements of the doc.