mirror of
https://github.com/heyman/heynote.git
synced 2025-06-20 09:37:50 +02:00
Minor formatting
This commit is contained in:
parent
1b3665b7b6
commit
662a234377
@ -58,7 +58,7 @@ const blockState = StateField.define({
|
|||||||
class NoteBlockStart extends WidgetType {
|
class NoteBlockStart extends WidgetType {
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
eq(other) {
|
eq(other) {
|
||||||
//return other.checked == this.checked
|
//return other.checked == this.checked
|
||||||
return true
|
return true
|
||||||
@ -87,14 +87,14 @@ const noteBlockWidget = () => {
|
|||||||
});
|
});
|
||||||
//console.log("deco range:", delimiter.from === 0 ? delimiter.from : delimiter.from+1,delimiter.to-1)
|
//console.log("deco range:", delimiter.from === 0 ? delimiter.from : delimiter.from+1,delimiter.to-1)
|
||||||
widgets.push(deco.range(
|
widgets.push(deco.range(
|
||||||
delimiter.from === 0 ? delimiter.from : delimiter.from+1,
|
delimiter.from === 0 ? delimiter.from : delimiter.from + 1,
|
||||||
delimiter.to-1,
|
delimiter.to - 1,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
return widgets.length > 0 ? RangeSet.of(widgets) : Decoration.none;
|
return widgets.length > 0 ? RangeSet.of(widgets) : Decoration.none;
|
||||||
};
|
};
|
||||||
|
|
||||||
const noteBlockStartField = StateField.define({
|
const noteBlockStartField = StateField.define({
|
||||||
create(state) {
|
create(state) {
|
||||||
return decorate(state);
|
return decorate(state);
|
||||||
@ -103,7 +103,7 @@ const noteBlockWidget = () => {
|
|||||||
if (transaction.docChanged) {
|
if (transaction.docChanged) {
|
||||||
return decorate(transaction.state);
|
return decorate(transaction.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
//return widgets.map(transaction.changes);
|
//return widgets.map(transaction.changes);
|
||||||
return widgets
|
return widgets
|
||||||
},
|
},
|
||||||
@ -111,8 +111,8 @@ const noteBlockWidget = () => {
|
|||||||
return EditorView.decorations.from(field);
|
return EditorView.decorations.from(field);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return [noteBlockStartField];
|
return noteBlockStartField;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ function atomicRanges(view) {
|
|||||||
view.state.facet(blockState).forEach(block => {
|
view.state.facet(blockState).forEach(block => {
|
||||||
builder.add(
|
builder.add(
|
||||||
block.delimiter.from,
|
block.delimiter.from,
|
||||||
block.delimiter.to,
|
block.delimiter.to,
|
||||||
{},
|
{},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -134,16 +134,16 @@ const atomicNoteBlock = ViewPlugin.fromClass(
|
|||||||
constructor(view) {
|
constructor(view) {
|
||||||
this.atomicRanges = atomicRanges(view)
|
this.atomicRanges = atomicRanges(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
update(update) {
|
update(update) {
|
||||||
if (update.docChanged) {
|
if (update.docChanged) {
|
||||||
this.atomicRanges = atomicRanges(update.view)
|
this.atomicRanges = atomicRanges(update.view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: plugin => EditorView.atomicRanges.of(view => {
|
provide: plugin => EditorView.atomicRanges.of(view => {
|
||||||
return view.plugin(plugin)?.atomicRanges || []
|
return view.plugin(plugin)?.atomicRanges || []
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -180,10 +180,10 @@ const blockLayer = () => {
|
|||||||
const fromCoords = view.coordsAtPos(Math.max(block.content.from, view.visibleRanges[0].from))
|
const fromCoords = view.coordsAtPos(Math.max(block.content.from, view.visibleRanges[0].from))
|
||||||
const toCoords = view.coordsAtPos(Math.min(block.content.to, view.visibleRanges[view.visibleRanges.length - 1].to))
|
const toCoords = view.coordsAtPos(Math.min(block.content.to, view.visibleRanges[view.visibleRanges.length - 1].to))
|
||||||
markers.push(new RectangleMarker(
|
markers.push(new RectangleMarker(
|
||||||
idx++ % 2 == 0 ? "block-even" : "block-odd",
|
idx++ % 2 == 0 ? "block-even" : "block-odd",
|
||||||
0,
|
0,
|
||||||
fromCoords.top - (view.documentTop - view.documentPadding.top) - 1,
|
fromCoords.top - (view.documentTop - view.documentPadding.top) - 1,
|
||||||
editorWidth,
|
editorWidth,
|
||||||
(toCoords.bottom - fromCoords.top) + 2,
|
(toCoords.bottom - fromCoords.top) + 2,
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
@ -233,11 +233,10 @@ const preventSelectionBeforeFirstBlock = EditorState.transactionFilter.of((tr) =
|
|||||||
export const noteBlockExtension = () => {
|
export const noteBlockExtension = () => {
|
||||||
return [
|
return [
|
||||||
blockState,
|
blockState,
|
||||||
|
noteBlockWidget(),
|
||||||
noteBlockWidget(),
|
atomicNoteBlock,
|
||||||
atomicNoteBlock,
|
blockLayer(),
|
||||||
blockLayer(),
|
preventFirstBlockFromBeingDeleted,
|
||||||
preventFirstBlockFromBeingDeleted,
|
|
||||||
preventSelectionBeforeFirstBlock,
|
preventSelectionBeforeFirstBlock,
|
||||||
lineNumbers({
|
lineNumbers({
|
||||||
formatNumber(lineNo, state) {
|
formatNumber(lineNo, state) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user