@adecore/editor 0.23.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine.js +5 -0
- package/dist/fake.d.ts +2 -0
- package/dist/fake.js +4 -0
- package/dist/types.d.ts +2 -0
- package/dist/view.d.ts +1 -0
- package/dist/view.js +3 -0
- package/package.json +2 -2
- package/src/engine.ts +6 -0
- package/src/fake.ts +5 -0
- package/src/types.ts +4 -0
- package/src/view.ts +5 -0
package/dist/engine.js
CHANGED
|
@@ -50,6 +50,7 @@ class SmartEditor {
|
|
|
50
50
|
messages: options.messages ?? {},
|
|
51
51
|
label: options.label ?? DEFAULT_LABEL,
|
|
52
52
|
guides: options.guides !== false,
|
|
53
|
+
stickyScroll: options.stickyScroll !== false,
|
|
53
54
|
whitespace: options.whitespace === true,
|
|
54
55
|
rightMargin: options.rightMargin ?? null,
|
|
55
56
|
foldOutline: options.foldOutline ?? 'hover',
|
|
@@ -641,6 +642,10 @@ class SmartEditor {
|
|
|
641
642
|
this.settings.guides = guides;
|
|
642
643
|
this.view.applySettings();
|
|
643
644
|
}
|
|
645
|
+
setStickyScroll(sticky) {
|
|
646
|
+
this.settings.stickyScroll = sticky;
|
|
647
|
+
this.view.applySettings();
|
|
648
|
+
}
|
|
644
649
|
setWhitespace(whitespace) {
|
|
645
650
|
this.settings.whitespace = whitespace;
|
|
646
651
|
this.view.applySettings();
|
package/dist/fake.d.ts
CHANGED
|
@@ -119,9 +119,11 @@ export declare class FakeEditor implements Editor {
|
|
|
119
119
|
enterScope(scope: readonly EditorBlock[]): void;
|
|
120
120
|
smartKeys: Partial<EditorSmartKeys>;
|
|
121
121
|
guides: boolean;
|
|
122
|
+
stickyScroll: boolean;
|
|
122
123
|
whitespace: boolean;
|
|
123
124
|
rightMargin: number | null;
|
|
124
125
|
setGuides(guides: boolean): void;
|
|
126
|
+
setStickyScroll(sticky: boolean): void;
|
|
125
127
|
setWhitespace(whitespace: boolean): void;
|
|
126
128
|
setRightMargin(column: number | null): void;
|
|
127
129
|
foldOutline: EditorFoldOutline;
|
package/dist/fake.js
CHANGED
|
@@ -380,11 +380,15 @@ export class FakeEditor {
|
|
|
380
380
|
}
|
|
381
381
|
smartKeys;
|
|
382
382
|
guides = true;
|
|
383
|
+
stickyScroll = true;
|
|
383
384
|
whitespace = false;
|
|
384
385
|
rightMargin = null;
|
|
385
386
|
setGuides(guides) {
|
|
386
387
|
this.guides = guides;
|
|
387
388
|
}
|
|
389
|
+
setStickyScroll(sticky) {
|
|
390
|
+
this.stickyScroll = sticky;
|
|
391
|
+
}
|
|
388
392
|
setWhitespace(whitespace) {
|
|
389
393
|
this.whitespace = whitespace;
|
|
390
394
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface EditorOptions {
|
|
|
26
26
|
readonly indentation?: EditorIndentation;
|
|
27
27
|
readonly smartKeys?: Partial<EditorSmartKeys>;
|
|
28
28
|
readonly guides?: boolean;
|
|
29
|
+
readonly stickyScroll?: boolean;
|
|
29
30
|
readonly whitespace?: boolean;
|
|
30
31
|
readonly rightMargin?: number | null;
|
|
31
32
|
readonly foldOutline?: EditorFoldOutline;
|
|
@@ -319,6 +320,7 @@ export interface Editor {
|
|
|
319
320
|
setIndentation(indentation: EditorIndentation): void;
|
|
320
321
|
setSmartKeys(keys: Partial<EditorSmartKeys>): void;
|
|
321
322
|
setGuides(guides: boolean): void;
|
|
323
|
+
setStickyScroll?(sticky: boolean): void;
|
|
322
324
|
setWhitespace(whitespace: boolean): void;
|
|
323
325
|
setRightMargin(column: number | null): void;
|
|
324
326
|
setFoldOutline(outline: EditorFoldOutline): void;
|
package/dist/view.d.ts
CHANGED
package/dist/view.js
CHANGED
|
@@ -2294,6 +2294,9 @@ export class EditorView {
|
|
|
2294
2294
|
return Math.min(STICKY_MAX_LINES, Math.floor(this.viewportHeight / this.layout.metrics.lineHeight / STICKY_ROW_SHARE));
|
|
2295
2295
|
}
|
|
2296
2296
|
stickyAt(scrollTop) {
|
|
2297
|
+
if (this.settings.stickyScroll === false) {
|
|
2298
|
+
return [];
|
|
2299
|
+
}
|
|
2297
2300
|
const { layout } = this;
|
|
2298
2301
|
const bottomOf = (line) => {
|
|
2299
2302
|
const row = layout.rowForLine(line);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adecore/editor",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"test": "bun test --conditions=source"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@adecore/editor-core": "0.23.
|
|
57
|
+
"@adecore/editor-core": "0.23.1",
|
|
58
58
|
"linkedom": "^0.18.13",
|
|
59
59
|
"shiki": "^4.4.3"
|
|
60
60
|
},
|
package/src/engine.ts
CHANGED
|
@@ -106,6 +106,7 @@ class SmartEditor implements Editor {
|
|
|
106
106
|
messages: options.messages ?? {},
|
|
107
107
|
label: options.label ?? DEFAULT_LABEL,
|
|
108
108
|
guides: options.guides !== false,
|
|
109
|
+
stickyScroll: options.stickyScroll !== false,
|
|
109
110
|
whitespace: options.whitespace === true,
|
|
110
111
|
rightMargin: options.rightMargin ?? null,
|
|
111
112
|
foldOutline: options.foldOutline ?? 'hover',
|
|
@@ -806,6 +807,11 @@ class SmartEditor implements Editor {
|
|
|
806
807
|
this.view.applySettings();
|
|
807
808
|
}
|
|
808
809
|
|
|
810
|
+
setStickyScroll(sticky: boolean): void {
|
|
811
|
+
this.settings.stickyScroll = sticky;
|
|
812
|
+
this.view.applySettings();
|
|
813
|
+
}
|
|
814
|
+
|
|
809
815
|
setWhitespace(whitespace: boolean): void {
|
|
810
816
|
this.settings.whitespace = whitespace;
|
|
811
817
|
this.view.applySettings();
|
package/src/fake.ts
CHANGED
|
@@ -509,6 +509,7 @@ export class FakeEditor implements Editor {
|
|
|
509
509
|
smartKeys: Partial<EditorSmartKeys>;
|
|
510
510
|
|
|
511
511
|
guides = true;
|
|
512
|
+
stickyScroll = true;
|
|
512
513
|
whitespace = false;
|
|
513
514
|
rightMargin: number | null = null;
|
|
514
515
|
|
|
@@ -516,6 +517,10 @@ export class FakeEditor implements Editor {
|
|
|
516
517
|
this.guides = guides;
|
|
517
518
|
}
|
|
518
519
|
|
|
520
|
+
setStickyScroll(sticky: boolean): void {
|
|
521
|
+
this.stickyScroll = sticky;
|
|
522
|
+
}
|
|
523
|
+
|
|
519
524
|
setWhitespace(whitespace: boolean): void {
|
|
520
525
|
this.whitespace = whitespace;
|
|
521
526
|
}
|
package/src/types.ts
CHANGED
|
@@ -63,6 +63,8 @@ export interface EditorOptions {
|
|
|
63
63
|
readonly smartKeys?: Partial<EditorSmartKeys>;
|
|
64
64
|
/* A line at each indentation level, the one of the scope around the caret stronger; on unless false. */
|
|
65
65
|
readonly guides?: boolean;
|
|
66
|
+
/* The headers of the blocks scrolled out of sight stay pinned on top; on unless false. */
|
|
67
|
+
readonly stickyScroll?: boolean;
|
|
66
68
|
/* Spaces drawn as dots and tabs as arrows; off unless true. */
|
|
67
69
|
readonly whitespace?: boolean;
|
|
68
70
|
/* The column to draw a line at, such as the `max_line_length` of a project; none by default. */
|
|
@@ -615,6 +617,8 @@ export interface Editor {
|
|
|
615
617
|
/* Changes what it does as a person types; the keys left out stay as they are. */
|
|
616
618
|
setSmartKeys(keys: Partial<EditorSmartKeys>): void;
|
|
617
619
|
setGuides(guides: boolean): void;
|
|
620
|
+
/* Optional so an editor from before it still fits. */
|
|
621
|
+
setStickyScroll?(sticky: boolean): void;
|
|
618
622
|
setWhitespace(whitespace: boolean): void;
|
|
619
623
|
/* The column to draw a line at; null takes it away. */
|
|
620
624
|
setRightMargin(column: number | null): void;
|
package/src/view.ts
CHANGED
|
@@ -114,6 +114,8 @@ export interface ViewSettings {
|
|
|
114
114
|
/* When the arrow that folds a block shows in the gutter. */
|
|
115
115
|
foldOutline: 'off' | 'hover' | 'always';
|
|
116
116
|
folding?: boolean;
|
|
117
|
+
/* The headers of the blocks scrolled out of sight stay pinned on top; on unless false. */
|
|
118
|
+
stickyScroll?: boolean;
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
/* The lines past the visible ones that are colored ahead of the scroll, and how long one slice of that work may take. */
|
|
@@ -2654,6 +2656,9 @@ export class EditorView {
|
|
|
2654
2656
|
}
|
|
2655
2657
|
|
|
2656
2658
|
private stickyAt(scrollTop: number): StickyPlacement[] {
|
|
2659
|
+
if (this.settings.stickyScroll === false) {
|
|
2660
|
+
return [];
|
|
2661
|
+
}
|
|
2657
2662
|
const { layout } = this;
|
|
2658
2663
|
const bottomOf = (line: number): number => {
|
|
2659
2664
|
const row = layout.rowForLine(line);
|