mirror of
https://github.com/hydra-synth/hydra.git
synced 2025-12-05 22:40:15 +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:
|
// to add:
|
||||||
// flash block, flash line, format code
|
// flash block, flash line, format code
|
||||||
|
import { syntaxTree } from "@codemirror/language"
|
||||||
|
|
||||||
|
|
||||||
export default function editorStore(state, emitter) {
|
export default function editorStore(state, emitter) {
|
||||||
emitter.on('editor: randomize', function (evt) {
|
emitter.on('editor: randomize', function (evt) {
|
||||||
const editor = state.editor.editor
|
const editor = state.editor.editor
|
||||||
if (evt.shiftKey) {
|
|
||||||
editor.mutator.doUndo();
|
const view = editor.cm
|
||||||
} else {
|
let text = view.state.doc.toString()
|
||||||
editor.mutator.mutate({ reroll: false, changeTransform: evt.metaKey });
|
let tree = syntaxTree(view.state)
|
||||||
editor.formatCode()
|
// arguments of CallExpression and arguments of Member Expressiong
|
||||||
emitter.emit('gallery: save to URL', editor.getValue())
|
// 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) => {
|
emitter.on('editor: add code to top', (code) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user