mirror of
https://github.com/hydra-synth/hydra.git
synced 2025-12-05 14:30:03 +01:00
randomizer
This commit is contained in:
6
src/lib/editor-extension.js
Normal file
6
src/lib/editor-extension.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// example editor extension file
|
||||
import { syntaxTree } from "@codemirror/language"
|
||||
|
||||
export function randomize (view) {
|
||||
|
||||
}
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user