* [bug #66435] fix zentao list url in doc with diffence rquest type.
This commit is contained in:
@@ -2325,6 +2325,39 @@ function initOfficePreview(options)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理导入的文档快照。
|
||||
* Handle the imported doc snapshot.
|
||||
*/
|
||||
function handleImportDocSnapshot(snapshot)
|
||||
{
|
||||
const forEachBlock = (blocks, callback) =>
|
||||
{
|
||||
blocks.forEach(block =>
|
||||
{
|
||||
callback(block);
|
||||
if(block.children) forEachBlock(block.children, callback);
|
||||
});
|
||||
};
|
||||
const requestType = config.requestType.toUpperCase();
|
||||
const fixUrl = (url, method, paramList) =>
|
||||
{
|
||||
const link = $.parseLink(url, 'auto');
|
||||
if(link.requestType.toUpperCase() === requestType || method.toLowerCase() !== link.methodName.toLowerCase()) return url;
|
||||
return $.createLink('doc', method, paramList.map((p, i) => [p, link.vars[i][1]]));
|
||||
};
|
||||
/* Fix custom block with fetcher in difference request type. */
|
||||
forEachBlock(snapshot.blocks.children, block =>
|
||||
{
|
||||
if(block.flavour !== 'affine:embed-zui-custom') return;
|
||||
const content = block.props.content;
|
||||
if(!content || typeof content !== 'object') return;
|
||||
if(content.fetcher) content.fetcher = fixUrl(content.fetcher, 'zentaoList', ['type', 'blockID']);
|
||||
if(content.exportUrl) content.exportUrl = fixUrl(content.exportUrl, 'ajaxExportZentaoList', ['blockID']);
|
||||
});
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置文档应用组件选项。
|
||||
* Set the doc app options.
|
||||
@@ -2340,6 +2373,7 @@ window.setDocAppOptions = function(_, options)
|
||||
|
||||
return $.extend(
|
||||
{
|
||||
editorProps : {onImportSnapshot: handleImportDocSnapshot},
|
||||
defaultState : {listType: '', libReleaseMap: {}},
|
||||
commands : commands,
|
||||
customRenders : customRenders,
|
||||
|
||||
Reference in New Issue
Block a user