Skip to content

Commit

Permalink
chore: rename CodeMirror to LakeCodeMirror
Browse files Browse the repository at this point in the history
  • Loading branch information
luolonghao committed Apr 25, 2024
1 parent 2c70057 commit 124f3e7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"eslint-config-prettier": "^9.1.0",
"execa": "^8.0.1",
"express": "^4.19.2",
"lake-codemirror": "^1.0.2",
"lake-codemirror": "^2.0.0",
"mocha": "^10.4.0",
"multer": "1.4.5-lts.1",
"npm-run-all": "^4.1.5",
Expand Down
42 changes: 25 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/boxes/code-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ export const codeBlockBox: BoxComponent = {
return;
}
// begin to create CodeMirror
const CodeMirror = window.CodeMirror;
const CodeMirror = window.LakeCodeMirror;
if (!CodeMirror) {
codeBlockNode.addClass('lake-code-block-error');
codeBlockNode.text(`
The code cannot be displayed because window.CodeMirror is not found.
Please check if the CodeMirror file is added to this page.
The code cannot be displayed because window.LakeCodeMirror is not found.
Please check if the "lake-codemirror" library is added to this page.
`.trim());
codeBlockNode.on('click', () => {
editor.selection.range.selectBox(box.node);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/code-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const langList = [
];

export default (editor: Editor) => {
if (!window.CodeMirror) {
if (!window.LakeCodeMirror) {
return;
}
editor.setPluginConfig('codeBlock', {
Expand Down
2 changes: 1 addition & 1 deletion src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare global {
LAKE_DEBUG: boolean;
LAKE_TEST: boolean;
LAKE_ERROR: boolean;
CodeMirror: any;
LakeCodeMirror: any;
}

interface Element {
Expand Down
6 changes: 3 additions & 3 deletions tests/boxes/code-block-ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ describe('boxes / code-block-ui', () => {
});

it('codeBlock: error status', () => {
const CodeMirror = window.CodeMirror;
window.CodeMirror = undefined;
const CodeMirror = window.LakeCodeMirror;
window.LakeCodeMirror = undefined;
showBox('codeBlock', {
lang: 'javascript',
code: javascriptCode,
}, box => {
expect(box.getContainer().find('.lake-code-block-error').length).to.equal(1);
window.CodeMirror = CodeMirror;
window.LakeCodeMirror = CodeMirror;
});
});

Expand Down
6 changes: 3 additions & 3 deletions tests/boxes/code-block.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ describe('boxes / code-block', () => {
});

it('error status: should focus on box after clicking', done => {
const CodeMirror = window.CodeMirror;
window.CodeMirror = undefined;
const CodeMirror = window.LakeCodeMirror;
window.LakeCodeMirror = undefined;
box = editor.insertBox('codeBlock', {
lang: 'css',
code: '.hello { }',
Expand All @@ -75,7 +75,7 @@ describe('boxes / code-block', () => {
click(boxContainer.find('.lake-code-block'));
editor.event.once('boxselectionstylechange', () => {
expect(boxContainer.hasClass('lake-box-focused')).to.equal(true);
window.CodeMirror = CodeMirror;
window.LakeCodeMirror = CodeMirror;
done();
});
});
Expand Down

0 comments on commit 124f3e7

Please sign in to comment.