@seljs/editor 1.1.0-beta.2 → 1.1.0-beta.4

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.
@@ -54,6 +54,14 @@ const buildExtensions = (config) => {
54
54
  if (config.readOnly) extensions.push(_codemirror_state.EditorState.readOnly.of(true));
55
55
  if (config.placeholder) extensions.push((0, _codemirror_view.placeholder)(config.placeholder));
56
56
  if (resolved.typeDisplay) extensions.push(require_type_display.createTypeDisplay(checker, config.dark ?? false));
57
+ const minLines = config.features?.view?.minLines;
58
+ if (minLines && minLines > 1) {
59
+ const minHeight = `${String(Math.max(1, minLines) * 1.4)}em`;
60
+ extensions.push(_codemirror_view.EditorView.theme({
61
+ "&": { minHeight },
62
+ ".cm-content": { minHeight }
63
+ }));
64
+ }
57
65
  if (config.features?.tooltip) extensions.push((0, _codemirror_view.tooltips)(config.features.tooltip));
58
66
  return extensions;
59
67
  };
@@ -54,6 +54,14 @@ const buildExtensions = (config) => {
54
54
  if (config.readOnly) extensions.push(EditorState.readOnly.of(true));
55
55
  if (config.placeholder) extensions.push(placeholder(config.placeholder));
56
56
  if (resolved.typeDisplay) extensions.push(createTypeDisplay(checker, config.dark ?? false));
57
+ const minLines = config.features?.view?.minLines;
58
+ if (minLines && minLines > 1) {
59
+ const minHeight = `${String(Math.max(1, minLines) * 1.4)}em`;
60
+ extensions.push(EditorView.theme({
61
+ "&": { minHeight },
62
+ ".cm-content": { minHeight }
63
+ }));
64
+ }
57
65
  if (config.features?.tooltip) extensions.push(tooltips(config.features.tooltip));
58
66
  return extensions;
59
67
  };
@@ -9,6 +9,7 @@ const typeField = _codemirror_state.StateField.define({
9
9
  return value;
10
10
  }
11
11
  });
12
+ const UNKNOWN_LABEL = "(unknown)";
12
13
  const createTypePanel = (dark) => (view) => {
13
14
  const dom = document.createElement("div");
14
15
  dom.className = "sel-type-display";
@@ -23,19 +24,16 @@ const createTypePanel = (dark) => (view) => {
23
24
  `background: ${dark ? "#262626" : "#f9fafb"}`,
24
25
  `border-top: 1px solid ${dark ? "#374151" : "#e5e7eb"}`
25
26
  ].join("; ");
27
+ const label = document.createElement("span");
28
+ label.style.color = dark ? "#6b7280" : "#9ca3af";
29
+ label.textContent = "output";
30
+ const typeSpan = document.createElement("span");
31
+ typeSpan.style.fontWeight = "500";
32
+ dom.append(label, " ", typeSpan);
26
33
  const update = () => {
27
34
  const type = view.state.field(typeField);
28
- dom.textContent = "";
29
- if (type) {
30
- const label = document.createElement("span");
31
- label.style.color = dark ? "#6b7280" : "#9ca3af";
32
- label.textContent = "output";
33
- const typeSpan = document.createElement("span");
34
- typeSpan.style.color = dark ? "#93c5fd" : "#2563eb";
35
- typeSpan.style.fontWeight = "500";
36
- typeSpan.textContent = type;
37
- dom.append(label, " ", typeSpan);
38
- }
35
+ typeSpan.textContent = type ?? UNKNOWN_LABEL;
36
+ typeSpan.style.color = type ? dark ? "#93c5fd" : "#2563eb" : dark ? "#6b7280" : "#9ca3af";
39
37
  };
40
38
  update();
41
39
  return {
@@ -9,6 +9,7 @@ const typeField = StateField.define({
9
9
  return value;
10
10
  }
11
11
  });
12
+ const UNKNOWN_LABEL = "(unknown)";
12
13
  const createTypePanel = (dark) => (view) => {
13
14
  const dom = document.createElement("div");
14
15
  dom.className = "sel-type-display";
@@ -23,19 +24,16 @@ const createTypePanel = (dark) => (view) => {
23
24
  `background: ${dark ? "#262626" : "#f9fafb"}`,
24
25
  `border-top: 1px solid ${dark ? "#374151" : "#e5e7eb"}`
25
26
  ].join("; ");
27
+ const label = document.createElement("span");
28
+ label.style.color = dark ? "#6b7280" : "#9ca3af";
29
+ label.textContent = "output";
30
+ const typeSpan = document.createElement("span");
31
+ typeSpan.style.fontWeight = "500";
32
+ dom.append(label, " ", typeSpan);
26
33
  const update = () => {
27
34
  const type = view.state.field(typeField);
28
- dom.textContent = "";
29
- if (type) {
30
- const label = document.createElement("span");
31
- label.style.color = dark ? "#6b7280" : "#9ca3af";
32
- label.textContent = "output";
33
- const typeSpan = document.createElement("span");
34
- typeSpan.style.color = dark ? "#93c5fd" : "#2563eb";
35
- typeSpan.style.fontWeight = "500";
36
- typeSpan.textContent = type;
37
- dom.append(label, " ", typeSpan);
38
- }
35
+ typeSpan.textContent = type ?? UNKNOWN_LABEL;
36
+ typeSpan.style.color = type ? dark ? "#93c5fd" : "#2563eb" : dark ? "#6b7280" : "#9ca3af";
39
37
  };
40
38
  update();
41
39
  return {
@@ -27,6 +27,17 @@ interface SELEditorFeatures {
27
27
  * @default false
28
28
  */
29
29
  typeDisplay?: boolean;
30
+ /**
31
+ * Editor view configuration (always enabled)
32
+ */
33
+ view?: {
34
+ /**
35
+ * Minimum number of visible lines
36
+ *
37
+ * @default 1
38
+ */
39
+ minLines?: number;
40
+ };
30
41
  /**
31
42
  * Tooltip rendering configuration (always enabled)
32
43
  */
@@ -27,6 +27,17 @@ interface SELEditorFeatures {
27
27
  * @default false
28
28
  */
29
29
  typeDisplay?: boolean;
30
+ /**
31
+ * Editor view configuration (always enabled)
32
+ */
33
+ view?: {
34
+ /**
35
+ * Minimum number of visible lines
36
+ *
37
+ * @default 1
38
+ */
39
+ minLines?: number;
40
+ };
30
41
  /**
31
42
  * Tooltip rendering configuration (always enabled)
32
43
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seljs/editor",
3
- "version": "1.1.0-beta.2",
3
+ "version": "1.1.0-beta.4",
4
4
  "repository": {
5
5
  "url": "https://github.com/abinnovision/seljs"
6
6
  },
@@ -56,8 +56,8 @@
56
56
  "@codemirror/view": "^6.40.0",
57
57
  "@lezer/common": "^1.5.1",
58
58
  "@lezer/highlight": "^1.2.3",
59
- "@seljs/cel-lezer": "1.1.0-beta.2",
60
- "@seljs/checker": "1.1.0-beta.2",
59
+ "@seljs/cel-lezer": "1.1.0-beta.4",
60
+ "@seljs/checker": "1.1.0-beta.4",
61
61
  "@seljs/schema": "1.0.1"
62
62
  },
63
63
  "devDependencies": {