Skip to content

Commit 72f44cc

Browse files
authored
Restore colormode (#393)
* lexical: css placeholder * bump: jupyter-react * fix: lexical theme list * lexical: favor jupyter cell output * lexical: favor code input cell * lexical: favor code input cell * prune: lexical jupyter components * fix enter * fix: codemirror shift-run * wip: dark theme * add colormode to cellsidebar extension
1 parent a099c3a commit 72f44cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+984
-907
lines changed

packages/lexical/babel.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33
*
44
* MIT License
55
*/
6-
7-
module.exports = require('@jupyterlab/testutils/lib/babel.config');

packages/lexical/src/components/JupyterCellComponent.tsx

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/lexical/src/components/JupyterOutputComponent.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

packages/lexical/src/components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export * from './DropDown';
1313
export * from './EquationEditor';
1414
export * from './FileInput';
1515
export * from './ImageResizer';
16-
export * from './JupyterOutputComponent';
1716
export * from './KatexEquationAlterer';
1817
export * from './KatexEquationAlterer';
1918
export * from './KatexRenderer';

packages/lexical/src/convert/LexicalToNbformat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@jupyterlab/nbformat';
1818
import EquationNode, { $isEquationNode } from './../nodes/EquationNode';
1919
import { $isYouTubeNode } from './../nodes/YouTubeNode';
20-
import { $isJupyterCodeNode } from './../nodes/JupyterCodeNode';
20+
import { $isJupyterInputNode } from './../nodes/JupyterInputNode';
2121
import { exportTopLevelElements } from './markdown/MarkdownExport';
2222
import { transformersByType } from './markdown/utils';
2323
import { TRANSFORMERS } from './markdown/index';
@@ -49,7 +49,7 @@ export const lexicalToNbformat = (nodes: LexicalNode[]) => {
4949
cells: [],
5050
};
5151
nodes.map(node => {
52-
if ($isJupyterCodeNode(node)) {
52+
if ($isJupyterInputNode(node)) {
5353
nb.cells.push(newCodeCell(node.getTextContent()));
5454
} else if (
5555
$isParagraphNode(node) &&

packages/lexical/src/convert/NbformatToLexical.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
import { LexicalEditor, INSERT_PARAGRAPH_COMMAND } from 'lexical';
88
import { INotebookContent, IOutput } from '@jupyterlab/nbformat';
9-
// import { INSERT_JUPYTER_CELL_OUTPUT_COMMAND } from "../plugins/JupyterCellOutputPlugin";
10-
import { INSERT_JUPYTER_CELL_COMMAND } from '../plugins/JupyterCellPlugin';
9+
// import { INSERT_JUPYTER_CELL_COMMAND } from '../plugins/JupyterCellPlugin';
10+
import { INSERT_JUPYTER_INPUT_OUTPUT_COMMAND } from '../plugins/JupyterInputOutputPlugin';
1111
import { $convertFromMarkdownString, TRANSFORMERS } from './markdown';
1212

1313
export const nbformatToLexical = (
@@ -28,11 +28,11 @@ export const nbformatToLexical = (
2828
}
2929
if (cell.cell_type === 'code') {
3030
const outputs = cell.outputs as IOutput[];
31-
editor.dispatchCommand(INSERT_JUPYTER_CELL_COMMAND, {
31+
editor.dispatchCommand(INSERT_JUPYTER_INPUT_OUTPUT_COMMAND, {
3232
code,
3333
outputs,
3434
loading: 'Loading...',
35-
autoStart: false,
35+
// autoStart: false,
3636
});
3737
}
3838
editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);

packages/lexical/src/convert/markdown/MarkdownImport.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import type {
1313
import type { LexicalNode, RootNode, TextNode } from 'lexical';
1414

1515
import {
16-
JupyterCodeNode,
17-
$createJupyterCodeNode,
18-
} from './../../nodes/JupyterCodeNode';
16+
JupyterInputNode,
17+
$createJupyterInputNode,
18+
} from './../../nodes/JupyterInputNode';
1919
import { $isListItemNode, $isListNode } from '@lexical/list';
2020
import { $isQuoteNode } from '@lexical/rich-text';
2121
import { $findMatchingParent } from '@lexical/utils';
@@ -167,7 +167,7 @@ function importCodeBlock(
167167
lines: Array<string>,
168168
startLineIndex: number,
169169
rootNode: RootNode,
170-
): [JupyterCodeNode | null, number] {
170+
): [JupyterInputNode | null, number] {
171171
const openMatch = lines[startLineIndex].match(CODE_BLOCK_REG_EXP);
172172

173173
if (openMatch) {
@@ -178,7 +178,7 @@ function importCodeBlock(
178178
const closeMatch = lines[endLineIndex].match(CODE_BLOCK_REG_EXP);
179179

180180
if (closeMatch) {
181-
const codeBlockNode = $createJupyterCodeNode(openMatch[1]);
181+
const codeBlockNode = $createJupyterInputNode(openMatch[1]);
182182
const textNode = $createTextNode(
183183
lines.slice(startLineIndex + 1, endLineIndex).join('\n'),
184184
);

packages/lexical/src/convert/markdown/MarkdownShortcuts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
} from '.';
1313
import type { ElementNode, LexicalEditor, TextNode } from 'lexical';
1414

15-
import { $isJupyterCodeNode } from './../../nodes/JupyterCodeNode';
15+
import { $isJupyterInputNode } from './../../nodes/JupyterInputNode';
1616
import {
1717
$createRangeSelection,
1818
$getSelection,
@@ -417,7 +417,7 @@ export function registerMarkdownShortcuts(
417417

418418
const parentNode = anchorNode.getParent();
419419

420-
if (parentNode === null || $isJupyterCodeNode(parentNode)) {
420+
if (parentNode === null || $isJupyterInputNode(parentNode)) {
421421
return;
422422
}
423423

packages/lexical/src/convert/markdown/MarkdownTransformers.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import type {
1515
} from 'lexical';
1616

1717
import {
18-
$createJupyterCodeNode,
19-
$isJupyterCodeNode,
20-
JupyterCodeNode,
21-
} from './../../nodes/JupyterCodeNode';
18+
$createJupyterInputNode,
19+
$isJupyterInputNode,
20+
JupyterInputNode,
21+
} from './../../nodes/JupyterInputNode';
2222
import { $createLinkNode, $isLinkNode, LinkNode } from '@lexical/link';
2323
import {
2424
$createListItemNode,
@@ -212,9 +212,9 @@ export const QUOTE: ElementTransformer = {
212212
};
213213

214214
export const CODE: ElementTransformer = {
215-
dependencies: [JupyterCodeNode],
215+
dependencies: [JupyterInputNode],
216216
export: (node: LexicalNode) => {
217-
if (!$isJupyterCodeNode(node)) {
217+
if (!$isJupyterInputNode(node)) {
218218
return null;
219219
}
220220
const textContent = node.getTextContent();
@@ -228,7 +228,7 @@ export const CODE: ElementTransformer = {
228228
},
229229
regExp: /^```(\w{1,10})?\s/,
230230
replace: replaceWithBlock(match => {
231-
return $createJupyterCodeNode(match ? match[1] : undefined);
231+
return $createJupyterInputNode(match ? match[1] : undefined);
232232
}),
233233
type: 'element',
234234
};

packages/lexical/src/convert/markdown/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
} from '.';
1414
import type { ElementNode, LexicalNode, TextFormatType } from 'lexical';
1515

16-
import { $isJupyterCodeNode } from './../../nodes/JupyterCodeNode';
16+
import { $isJupyterInputNode } from './../../nodes/JupyterInputNode';
1717
import { $isListItemNode, $isListNode } from '@lexical/list';
1818
import { $isHeadingNode, $isQuoteNode } from '@lexical/rich-text';
1919

@@ -379,7 +379,7 @@ function blockQuoteExport(
379379
}
380380

381381
function codeBlockExport(node: LexicalNode) {
382-
if (!$isJupyterCodeNode(node)) {
382+
if (!$isJupyterInputNode(node)) {
383383
return null;
384384
}
385385

0 commit comments

Comments
 (0)