Skip to content

Commit

Permalink
更新lakex-doc到1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ilimei committed Dec 10, 2023
1 parent 5a978df commit 5d4b2b8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
36 changes: 29 additions & 7 deletions scripts/preset-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,37 @@ const urllib = require('urllib');
const {
promises: fs,
mkdirSync,
readFileSync,
writeFileSync,
copyFileSync,
createWriteStream,
} = require('fs');

const { distFolder, sleep } = require('./common');

const LAKE_EDITOR_VERSION = '1.0.1-dev6';
const LAKE_EDITOR_VERSION = '1.11.0';

const remoteAssetsUrls = {
lakejs: `https://gw.alipayobjects.com/render/p/yuyan_npm/@alipay_lakex-doc/${LAKE_EDITOR_VERSION}/umd/doc.umd.js`,
lakejs: {
src: `https://gw.alipayobjects.com/render/p/yuyan_npm/@alipay_lakex-doc/${LAKE_EDITOR_VERSION}/umd/doc.umd.js`,
after: (content) => {
return content.replace(`https://mdn.alipayobjects.com/design_kitchencore/afts/file/HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr`, './HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr');
},
},
lakecss: `https://gw.alipayobjects.com/render/p/yuyan_npm/@alipay_lakex-doc/${LAKE_EDITOR_VERSION}/umd/doc.css`,
antdcss: 'https://gw.alipayobjects.com/os/lib/antd/4.24.13/dist/antd.css',
lakeIcon: 'https://mdn.alipayobjects.com/design_kitchencore/afts/file/HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr',
codemirror: 'https://gw.alipayobjects.com/render/p/yuyan_v/180020010000005484/7.1.4/CodeMirror.js',
tracert_a385: 'https://app.nlark.com/yuque-chrome-extension/tracert_a385.js',
tracert_a385: 'https://ur.alipay.com/tracert_a385.js',
};

const localAssetsPaths = {
katex: require.resolve('katex/dist/katex.min.js'),
react: require.resolve('react').replace('/index.js', '/umd/react.production.min.js'),
reactDOM: require.resolve('react-dom').replace('/index.js', '/umd/react-dom.production.min.js'),
};

async function downloadFile(remoteURL, localFilename) {
async function downloadFile(remoteURL, localFilename, afterLoad) {
console.log(`# downaload file to ${chalk.cyan(localFilename)} from ${remoteURL}`);
const fd = await fs.open(localFilename, 'w', 0o644);
await sleep(100);
Expand All @@ -35,25 +46,36 @@ async function downloadFile(remoteURL, localFilename) {
fd,
}),
});
if(afterLoad) {
const data = readFileSync(localFilename, 'utf-8');
const newData = afterLoad(data);
writeFileSync(localFilename, newData);
}
}

module.exports.webpackCleanIgnorePatterns = Object.values({
...remoteAssetsUrls,
...localAssetsPaths,
})
.map(url => url.split('/').pop())
.map(url => (typeof url === 'string' ? url : url.src).split('/').pop())
.map(fileName => `!${fileName}`);

module.exports.presetEditor = async function main() {
console.log('start preset editor ...');

const urls = Object.values(remoteAssetsUrls);
for (let i = 0; i < urls.length; i++) {
const url = urls[i];
let url = urls[i];
let afterLoad = null;
if(typeof url !== 'string') {
afterLoad = url.after;
url = url.src;
}
console.info('url', url);
const fileName = url.split('/').pop();
const localFilename = path.resolve(distFolder, fileName);
mkdirSync(distFolder, { recursive: true });
await downloadFile(url, localFilename);
await downloadFile(url, localFilename, afterLoad);
}

const localAssets = Object.values(localAssetsPaths);
Expand Down
12 changes: 9 additions & 3 deletions src/components/lake-editor/template-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const templateHtml = `
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="./doc.css"/>
<link rel="stylesheet" type="text/css" href="./antd.css"/>
<style>
body {
display: flex;
Expand Down Expand Up @@ -54,16 +55,19 @@ export const templateHtml = `
padding: 16px 16px 0;
height: 100%;
}
.ne-layout-mode-fixed .ne-engine {
padding: 0;
min-height: calc(100vh - 34px)
.ne-layout-mode-fixed .ne-engine, .ne-layout-mode-adapt .ne-engine {
padding: 16px 16px 0;
}
.ne-layout-mode-fixed .ne-editor-wrap-content {
min-width: 317px;
}
.ne-layout-mode-fixed .ne-editor-outer-wrap-box {
min-width: 317px;
}
.ne-layout-mode-fixed .ne-editor-outer-wrap-box, .ne-layout-mode-adapt .ne-editor-outer-wrap-box,
.ne-layout-mode-fixed .ne-editor-wrap-content, .ne-layout-mode-adapt .ne-editor-wrap-content {
min-width: 317px;
}
</style>
</head>
<body>
Expand All @@ -72,6 +76,8 @@ export const templateHtml = `
<div id="child"></div>
</div>
<div id="root"></div>
<script src="./react.production.min.js"></script>
<script src="./react-dom.production.min.js"></script>
<script src="./doc.umd.js"></script>
</body>
</html>
Expand Down
4 changes: 4 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"CodeMirror.js",
"katex.min.js",
"tracert_a385.js",
"antd.css",
"HWy0Q7LuuV0AAAAAAAAAAAAADhulAQBr",
"react.production.min.js",
"react-dom.production.min.js",
"yuque-transform-script.js"
],
"matches": [
Expand Down

0 comments on commit 5d4b2b8

Please sign in to comment.