mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
use loc as slider id
This commit is contained in:
parent
276cf858fc
commit
2731e70fb7
@ -152,6 +152,6 @@ function updateSliderValue(view, e) {
|
||||
let change = { from: draggedSlider.from, to: draggedSlider.to, insert };
|
||||
draggedSlider.to = draggedSlider.from + insert.length;
|
||||
view.dispatch({ changes: change });
|
||||
window.postMessage({ type: 'slider-change', value: next });
|
||||
window.postMessage({ type: 'cm-slider', value: next, loc: draggedSlider.from });
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -35,6 +35,10 @@ export function transpiler(input, options = {}) {
|
||||
emitMiniLocations && collectMiniLocations(value, node);
|
||||
return this.replace(miniWithLocation(value, node));
|
||||
}
|
||||
if (isWidgetFunction(node)) {
|
||||
// collectSliderLocations?
|
||||
return this.replace(widgetWithLocation(node));
|
||||
}
|
||||
// TODO: remove pseudo note variables?
|
||||
if (node.type === 'Identifier' && isNoteWithOctave(node.name)) {
|
||||
this.skip();
|
||||
@ -68,11 +72,10 @@ export function transpiler(input, options = {}) {
|
||||
}
|
||||
|
||||
function isStringWithDoubleQuotes(node, locations, code) {
|
||||
const { raw, type } = node;
|
||||
if (type !== 'Literal') {
|
||||
if (node.type !== 'Literal') {
|
||||
return false;
|
||||
}
|
||||
return raw[0] === '"';
|
||||
return node.raw[0] === '"';
|
||||
}
|
||||
|
||||
function isBackTickString(node, parent) {
|
||||
@ -94,3 +97,19 @@ function miniWithLocation(value, node) {
|
||||
optional: false,
|
||||
};
|
||||
}
|
||||
|
||||
function isWidgetFunction(node) {
|
||||
return node.type === 'CallExpression' && node.callee.name === 'slider';
|
||||
}
|
||||
|
||||
function widgetWithLocation(node) {
|
||||
const loc = node.arguments[0].start;
|
||||
// add loc as identifier to first argument
|
||||
// the slider function is assumed to be slider(loc, value, min?, max?)
|
||||
node.arguments.unshift({
|
||||
type: 'Literal',
|
||||
value: loc,
|
||||
raw: loc + '',
|
||||
});
|
||||
return node;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user