@adecore/editor 0.70.1 → 0.71.0

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 CHANGED
@@ -49,6 +49,7 @@ class SmartEditor {
49
49
  this.model = new DocumentModel(options.text);
50
50
  this.language = options.language;
51
51
  this.theme = options.theme;
52
+ const whole = options.partial !== true;
52
53
  this.settings = {
53
54
  searchWorker: engine.searchWorker,
54
55
  language: options.language,
@@ -60,15 +61,19 @@ class SmartEditor {
60
61
  smartKeys: resolveSmartKeys(options.smartKeys),
61
62
  messages: options.messages ?? {},
62
63
  label: options.label ?? DEFAULT_LABEL,
63
- guides: options.guides !== false,
64
- stickyScroll: options.stickyScroll !== false,
64
+ guides: whole && options.guides !== false,
65
+ brackets: whole,
66
+ stickyScroll: whole && options.stickyScroll !== false,
65
67
  whitespace: options.whitespace === true,
66
68
  rightMargin: options.rightMargin ?? null,
67
- foldOutline: options.foldOutline ?? 'hover',
68
- folding: options.folding !== false,
69
+ foldOutline: whole ? (options.foldOutline ?? 'hover') : 'off',
70
+ folding: whole && options.folding !== false,
69
71
  todoWords: options.todoWords
70
72
  };
71
73
  this.view = new EditorView(element, this.model, this.settings);
74
+ if (!whole) {
75
+ this.view.setBlocks([]);
76
+ }
72
77
  this.grammarPreparation = new GrammarPreparation(this.model, () => this.view.grammarChanged());
73
78
  const engineHandBack = live(engine.handBack ?? []);
74
79
  const mountHandBack = live(options.handBack ?? []);
package/dist/types.d.ts CHANGED
@@ -31,6 +31,7 @@ export interface EditorOptions {
31
31
  readonly indentation?: EditorIndentation;
32
32
  readonly smartKeys?: Partial<EditorSmartKeys>;
33
33
  readonly guides?: boolean;
34
+ readonly partial?: boolean;
34
35
  readonly stickyScroll?: boolean;
35
36
  readonly whitespace?: boolean;
36
37
  readonly rightMargin?: number | null;
package/dist/view.d.ts CHANGED
@@ -18,6 +18,7 @@ export interface ViewSettings {
18
18
  messages: Partial<EditorMessages>;
19
19
  label: string;
20
20
  guides: boolean;
21
+ brackets: boolean;
21
22
  whitespace: boolean;
22
23
  rightMargin: number | null;
23
24
  foldOutline: 'off' | 'hover' | 'always';
package/dist/view.js CHANGED
@@ -1227,7 +1227,7 @@ export class EditorView {
1227
1227
  }
1228
1228
  }
1229
1229
  bracketAt({ anchor, head }) {
1230
- if (Math.abs(head - anchor) > 1) {
1230
+ if (!this.settings.brackets || Math.abs(head - anchor) > 1) {
1231
1231
  return undefined;
1232
1232
  }
1233
1233
  const candidates = anchor !== head ? [Math.min(anchor, head)] : [head, head - 1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/editor",
3
- "version": "0.70.1",
3
+ "version": "0.71.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -54,8 +54,8 @@
54
54
  "test": "bun test --conditions=source"
55
55
  },
56
56
  "dependencies": {
57
- "@adecore/editor-core": "0.70.1",
58
- "@adecore/utils": "0.70.1",
57
+ "@adecore/editor-core": "0.71.0",
58
+ "@adecore/utils": "0.71.0",
59
59
  "linkedom": "^0.18.15",
60
60
  "shiki": "^4.6.0"
61
61
  },
package/src/engine.ts CHANGED
@@ -116,6 +116,8 @@ class SmartEditor implements Editor {
116
116
  this.language = options.language;
117
117
  this.theme = options.theme;
118
118
 
119
+ const whole = options.partial !== true;
120
+
119
121
  this.settings = {
120
122
  searchWorker: engine.searchWorker,
121
123
  language: options.language,
@@ -127,16 +129,21 @@ class SmartEditor implements Editor {
127
129
  smartKeys: resolveSmartKeys(options.smartKeys),
128
130
  messages: options.messages ?? {},
129
131
  label: options.label ?? DEFAULT_LABEL,
130
- guides: options.guides !== false,
131
- stickyScroll: options.stickyScroll !== false,
132
+ guides: whole && options.guides !== false,
133
+ brackets: whole,
134
+ stickyScroll: whole && options.stickyScroll !== false,
132
135
  whitespace: options.whitespace === true,
133
136
  rightMargin: options.rightMargin ?? null,
134
- foldOutline: options.foldOutline ?? 'hover',
135
- folding: options.folding !== false,
137
+ foldOutline: whole ? (options.foldOutline ?? 'hover') : 'off',
138
+ folding: whole && options.folding !== false,
136
139
  todoWords: options.todoWords
137
140
  };
138
141
 
139
142
  this.view = new EditorView(element, this.model, this.settings);
143
+
144
+ if (!whole) {
145
+ this.view.setBlocks([]);
146
+ }
140
147
  this.grammarPreparation = new GrammarPreparation(this.model, () => this.view.grammarChanged());
141
148
 
142
149
  const engineHandBack = live(engine.handBack ?? []);
package/src/types.ts CHANGED
@@ -82,6 +82,12 @@ export interface EditorOptions {
82
82
  readonly smartKeys?: Partial<EditorSmartKeys>;
83
83
  /* A line at each indentation level, the one of the scope around the caret stronger; on unless false. */
84
84
  readonly guides?: boolean;
85
+ /*
86
+ * The text is a fragment of a file, such as the hunks of a diff, so whatever the editor would read from the whole
87
+ * text is wrong: no bracket marks, guides, folds or sticky blocks, and no blocks for the breadcrumb until the host
88
+ * sets them. A setter turns one back on. Off unless true.
89
+ */
90
+ readonly partial?: boolean;
85
91
  /* The headers of the blocks scrolled out of sight stay pinned on top; on unless false. */
86
92
  readonly stickyScroll?: boolean;
87
93
  /* Spaces drawn as dots and tabs as arrows; off unless true. */
package/src/view.ts CHANGED
@@ -111,6 +111,7 @@ export interface ViewSettings {
111
111
  messages: Partial<EditorMessages>;
112
112
  label: string;
113
113
  guides: boolean;
114
+ brackets: boolean;
114
115
  whitespace: boolean;
115
116
  rightMargin: number | null;
116
117
  foldOutline: 'off' | 'hover' | 'always';
@@ -1647,7 +1648,7 @@ export class EditorView {
1647
1648
  }
1648
1649
 
1649
1650
  private bracketAt({ anchor, head }: EditorSelection): number | undefined {
1650
- if (Math.abs(head - anchor) > 1) {
1651
+ if (!this.settings.brackets || Math.abs(head - anchor) > 1) {
1651
1652
  return undefined;
1652
1653
  }
1653
1654