mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-22 11:08:35 +00:00
move stuff for less changes
This commit is contained in:
parent
4319c43ceb
commit
b5312c27dc
@ -2,26 +2,9 @@ import { ref, pure } from '@strudel/core';
|
|||||||
import { WidgetType, ViewPlugin, Decoration } from '@codemirror/view';
|
import { WidgetType, ViewPlugin, Decoration } from '@codemirror/view';
|
||||||
import { StateEffect } from '@codemirror/state';
|
import { StateEffect } from '@codemirror/state';
|
||||||
|
|
||||||
export const setSliderWidgets = StateEffect.define();
|
|
||||||
|
|
||||||
export const updateSliderWidgets = (view, widgets) => {
|
|
||||||
view.dispatch({ effects: setSliderWidgets.of(widgets) });
|
|
||||||
};
|
|
||||||
|
|
||||||
export let sliderValues = {};
|
export let sliderValues = {};
|
||||||
const getSliderID = (from) => `slider_${from}`;
|
const getSliderID = (from) => `slider_${from}`;
|
||||||
|
|
||||||
function getSliders(widgetConfigs, view) {
|
|
||||||
return widgetConfigs
|
|
||||||
.filter((w) => w.type === 'slider')
|
|
||||||
.map(({ from, to, value, min, max, step }) => {
|
|
||||||
return Decoration.widget({
|
|
||||||
widget: new SliderWidget(value, min, max, from, to, step, view),
|
|
||||||
side: 0,
|
|
||||||
}).range(from /* , to */);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export class SliderWidget extends WidgetType {
|
export class SliderWidget extends WidgetType {
|
||||||
constructor(value, min, max, from, to, step, view) {
|
constructor(value, min, max, from, to, step, view) {
|
||||||
super();
|
super();
|
||||||
@ -77,6 +60,23 @@ export class SliderWidget extends WidgetType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const setSliderWidgets = StateEffect.define();
|
||||||
|
|
||||||
|
export const updateSliderWidgets = (view, widgets) => {
|
||||||
|
view.dispatch({ effects: setSliderWidgets.of(widgets) });
|
||||||
|
};
|
||||||
|
|
||||||
|
function getSliders(widgetConfigs, view) {
|
||||||
|
return widgetConfigs
|
||||||
|
.filter((w) => w.type === 'slider')
|
||||||
|
.map(({ from, to, value, min, max, step }) => {
|
||||||
|
return Decoration.widget({
|
||||||
|
widget: new SliderWidget(value, min, max, from, to, step, view),
|
||||||
|
side: 0,
|
||||||
|
}).range(from /* , to */);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const sliderPlugin = ViewPlugin.fromClass(
|
export const sliderPlugin = ViewPlugin.fromClass(
|
||||||
class {
|
class {
|
||||||
decorations; //: DecorationSet
|
decorations; //: DecorationSet
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user