randomizer

This commit is contained in:
ojack
2023-12-13 16:36:50 -06:00
parent 57c62e92fe
commit 0a1c9950cd
2 changed files with 30 additions and 7 deletions

View File

@@ -0,0 +1,6 @@
// example editor extension file
import { syntaxTree } from "@codemirror/language"
export function randomize (view) {
}

View File

@@ -1,16 +1,33 @@
// to add:
// flash block, flash line, format code
import { syntaxTree } from "@codemirror/language"
export default function editorStore(state, emitter) {
emitter.on('editor: randomize', function (evt) {
const editor = state.editor.editor
if (evt.shiftKey) {
editor.mutator.doUndo();
} else {
editor.mutator.mutate({ reroll: false, changeTransform: evt.metaKey });
editor.formatCode()
emitter.emit('gallery: save to URL', editor.getValue())
}
const view = editor.cm
let text = view.state.doc.toString()
let tree = syntaxTree(view.state)
// arguments of CallExpression and arguments of Member Expressiong
// find all numbers /// nodes of interest
// find all of the numbers
//.resolveInner(next, -1)
console.log('RANDIMIZING', editor, text, tree)
//
// if (evt.shiftKey) {
// editor.mutator.doUndo();
// } else {
// // editor.mutator.mutate({ reroll: false, changeTransform: evt.metaKey });
// editor.formatCode()
// emitter.emit('gallery: save to URL', editor.getValue())
// }
})
emitter.on('editor: add code to top', (code) => {