Skip to content

Commit

Permalink
Merge pull request #6 from JerryI/dev
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
JerryI authored Jul 17, 2024
2 parents a475d67 + 4cb399c commit f9993d7
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
node_modules_copy
package-lock.json
.cache
.parcel-cache
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# WLJS-Editor
**A cell editor for wolfram-frontend project written in JS with Codemirror 6. Support mathematical expressions rendered inline, Mathematica's boxes and many more...**
**A cell editor & supporting packages for wolfram-frontend project written in JS with Codemirror 6. Support mathematical expressions rendered inline, Mathematica's boxes and many more...**

__This is a core component of [Wolfram JS Frontend](https://github.com/JerryI/wolfram-js-frontend) project__
For now it might not be very usefull being used separately from the frontend.

However, one can an editor it separately. Please check for it

```
npm i
npm run demo
```

It does not need to have Wolfram Kernel.

Check out **[live demo](https://jerryi.github.io/cm6/)** on github pages

## License

Expand Down
Binary file removed dist/.DS_Store
Binary file not shown.
15 changes: 8 additions & 7 deletions dist/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -63096,13 +63096,13 @@ var compactCMEditor$5;
applyChanges(update) {

//const args = this.visibleValue.args;
const data = "Sqrt[" + update + "]";
const data = update;

//const old = this.visibleValue.str;

//console.log(this.visibleValue.pos);
const changes = {from: this.visibleValue.argsPos, to: this.visibleValue.argsPos + this.length, insert: data};
//console.log(args);
const changes = {from: this.visibleValue.argsPos + 5, to: this.visibleValue.argsPos + this.length - 1, insert: data};
console.log(this.visibleValue);
//const changes = {from: this.visibleValue.argsPos + args[0], to: this.visibleValue.argsPos + args[0].from + args[0].body.length - 1, insert: data};
//console.warn('changes will be applied to...');
//console.log(this.view.viewState.state.doc.toString().slice(changes.from, changes.to));
Expand All @@ -63113,7 +63113,8 @@ var compactCMEditor$5;

//console.log('insert change');
//console.log(changes);
const delta = this.length - data.length;
//console.log({oldLength: this.length, newLength: (data.length + 6)});
const delta = (data.length + 6) - this.length;
this.length = this.length + delta;
this.visibleValue.length = this.visibleValue.length + delta;

Expand Down Expand Up @@ -72630,7 +72631,7 @@ compactWLEditor = (args) => {
ViewBoxWidget(),
BoxBoxWidget(compactWLEditor),
TemplateBoxWidget(compactWLEditor),
//bracketMatching(),
bracketMatching(),
//rainbowBrackets(),
Greekholder,
extras,
Expand Down Expand Up @@ -72720,7 +72721,7 @@ let editorCustomTheme = EditorView.theme({
".cm-activeLine": {
'background-color': 'transparent'
},

/*
".rainbow-bracket-red": { color: 'var(--editor-bracket-1)' },
".rainbow-bracket-orange": { color: 'var(--editor-bracket-2)' },
".rainbow-bracket-yellow": { color: 'var(--editor-bracket-3)' },
Expand All @@ -72736,7 +72737,7 @@ let editorCustomTheme = EditorView.theme({
".rainbow-bracket-blue > span": { color: 'var(--editor-bracket-5-a)' },
".rainbow-bracket-indigo > span": { color: 'var(--editor-bracket-6-a)' },
".rainbow-bracket-violet > span": { color: 'var(--editor-bracket-7-a)' }

*/
});

let editorCustomThemeCompact = EditorView.theme({
Expand Down
2 changes: 1 addition & 1 deletion dist/kernel.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions github-pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!DOCTYPE html><html><head><title>Playground for testing</title><link rel="stylesheet" href="https://jerryi.github.io/cm6/styles.4e25ce1f.css"><script type="module" src="https://cdn.jsdelivr.net/gh/JerryI/wljs-interpreter@dev/src/interpreter.js"></script><script type="module" src="https://cdn.jsdelivr.net/gh/JerryI/wljs-interpreter@dev/src/core.js"></script><script type="module" src="https://cdn.jsdelivr.net/gh/JerryI/wljs-cells@dev/src/module.js"></script><script type="module" src="https://jerryi.github.io/cm6/kernel.da81e14c.js"></script></head><body style="padding:5rem"> <script type="module">
new window.SupportedCells['codemirror'].view({element: document.body, save:()=>{}}, `n = (*SqB[*)Sqrt[1 - (*FB[*)(((*SpB[*)Power[(*SbB[*)Subscript[\\[Omega](*|*),(*|*)p](*]SbB*)(*|*),(*|*)2](*]SpB*))(*,*)/(*,*)((*SpB[*)Power[((*SbB[*)Subscript[\\[Omega](*|*),(*|*)0](*]SbB*) - \\[Omega])(*|*),(*|*)2](*]SpB*) - I \\[Gamma] \\[Omega]))(*]FB*) ](*]SqB*) `)
</script> </body></html>
21 changes: 21 additions & 0 deletions github-pages/kernel.da81e14c.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions github-pages/kernel.da81e14c.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions github-pages/styles.4e25ce1f.css

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

1 change: 1 addition & 0 deletions github-pages/styles.4e25ce1f.css.map

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

9 changes: 5 additions & 4 deletions libs/priceless-mathematica/src/boxes/sqrtbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ import {
applyChanges(update) {

//const args = this.visibleValue.args;
const data = "Sqrt[" + update + "]";
const data = update;

//const old = this.visibleValue.str;

//console.log(this.visibleValue.pos);
const changes = {from: this.visibleValue.argsPos, to: this.visibleValue.argsPos + this.length, insert: data};
//console.log(args);
const changes = {from: this.visibleValue.argsPos + 5, to: this.visibleValue.argsPos + this.length - 1, insert: data};
console.log(this.visibleValue);
//const changes = {from: this.visibleValue.argsPos + args[0], to: this.visibleValue.argsPos + args[0].from + args[0].body.length - 1, insert: data};
//console.warn('changes will be applied to...');
//console.log(this.view.viewState.state.doc.toString().slice(changes.from, changes.to));
Expand All @@ -119,7 +119,8 @@ import {

//console.log('insert change');
//console.log(changes);
const delta = this.length - data.length;
//console.log({oldLength: this.length, newLength: (data.length + 6)});
const delta = (data.length + 6) - this.length;
this.length = this.length + delta;
this.visibleValue.length = this.visibleValue.length + delta;

Expand Down
11 changes: 9 additions & 2 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "wljs-editor",
"version": "0.9.2",
"version": "0.9.3",
"description": "WLJS Code editor",
"scripts": {
"build": "node --max-old-space-size=8192 ./node_modules/.bin/rollup --config rollup.config.mjs",
"demo": "parcel ./playground/index.html",
"demo-dist": "parcel build ./playground/index.html --out-dir ./github-pages/ --public-url https://jerryi.github.io/cm6/",
"restore": "mkdir _temp && cd _temp && git clone --branch dev https://github.com/JerryI/wljs-editor && mv wljs-editor/.git ../.git && cd .. && rm -rf _temp"
},
"defaultPackage": true,
Expand Down Expand Up @@ -82,7 +84,7 @@
"label": "Hidden comment",
"event": "comment_selected",
"visible": "selection"
}
}
]
},
"repository": {
Expand All @@ -107,6 +109,7 @@
"mma-uncompress": "^1.0.1",
"node-balanced": "^0.0.14",
"parcel-bundler": "1.12.5",
"parsel": "^0.3.0",
"priceless-mathematica": "^1.2.1",
"rainbowbrackets": "^2.0.2",
"rollup": "^3.21.6"
Expand Down
16 changes: 16 additions & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Playground for testing</title>
<link rel="stylesheet" href="./../src/styles.css">
<script type="module" src="https://cdn.jsdelivr.net/gh/JerryI/wljs-interpreter@dev/src/interpreter.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/JerryI/wljs-interpreter@dev/src/core.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/JerryI/wljs-cells@dev/src/module.js"></script>
<script type="module" src="./../dist/kernel.js"></script>
</head>
<body style="padding: 5rem">
<script type="module">
new window.SupportedCells['codemirror'].view({element: document.body, save:()=>{}}, `n = (*SqB[*)Sqrt[1 - (*FB[*)(((*SpB[*)Power[(*SbB[*)Subscript[\\[Omega](*|*),(*|*)p](*]SbB*)(*|*),(*|*)2](*]SpB*))(*,*)/(*,*)((*SpB[*)Power[((*SbB[*)Subscript[\\[Omega](*|*),(*|*)0](*]SbB*) - \\[Omega])(*|*),(*|*)2](*]SpB*) - I \\[Gamma] \\[Omega]))(*]FB*) ](*]SqB*) `)
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/FileUpload.wl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pasteFileNames["wl", cli_, files_] := With[{},

pasteFileNames["md", cli_, files_] := With[{},
WLJSTransportSend[
FrontEditorSelected["Set", "\n"<>StringRiffle[StringJoin["![](attachments/", URLEncode[#], ")"] &/@ Keys[files], "\n"]<>"\n" ]
FrontEditorSelected["Set", "\n"<>StringRiffle[StringJoin["![](/attachments/", URLEncode[#], ")"] &/@ Keys[files], "\n"]<>"\n" ]
, cli]
]

Expand Down
6 changes: 3 additions & 3 deletions src/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ compactWLEditor = (args) => {
ViewBoxWidget(compactWLEditor),
BoxBoxWidget(compactWLEditor),
TemplateBoxWidget(compactWLEditor),
//bracketMatching(),
bracketMatching(),
//rainbowBrackets(),
Greekholder,
extras,
Expand Down Expand Up @@ -421,7 +421,7 @@ let editorCustomTheme = EditorView.theme({
".cm-activeLine": {
'background-color': 'transparent'
},

/*
".rainbow-bracket-red": { color: 'var(--editor-bracket-1)' },
".rainbow-bracket-orange": { color: 'var(--editor-bracket-2)' },
".rainbow-bracket-yellow": { color: 'var(--editor-bracket-3)' },
Expand All @@ -437,7 +437,7 @@ let editorCustomTheme = EditorView.theme({
".rainbow-bracket-blue > span": { color: 'var(--editor-bracket-5-a)' },
".rainbow-bracket-indigo > span": { color: 'var(--editor-bracket-6-a)' },
".rainbow-bracket-violet > span": { color: 'var(--editor-bracket-7-a)' }

*/
});

let editorCustomThemeCompact = EditorView.theme({
Expand Down

0 comments on commit f9993d7

Please sign in to comment.