add pianoroll widget

This commit is contained in:
Felix Roos 2024-03-15 01:40:21 +01:00
parent 094b30cd26
commit 48e0691eec
8 changed files with 62 additions and 23 deletions

View file

@ -14,13 +14,18 @@ export const updateWidgets = (view, widgets) => {
};
function getWidgets(widgetConfigs) {
return widgetConfigs.map(({ to, type }) => {
return Decoration.widget({
widget: new BlockWidget(to, type),
side: 0,
block: true,
}).range(to);
});
return (
widgetConfigs
// codemirror throws an error if we don't sort
.sort((a, b) => a.to - b.to)
.map(({ to, type }) => {
return Decoration.widget({
widget: new BlockWidget(to, type),
side: 0,
block: true,
}).range(to);
})
);
}
const widgetField = StateField.define(