@trebco/treb 30.16.0 → 31.1.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.
Files changed (58) hide show
  1. package/api-generator/api-generator.ts +3 -1
  2. package/api-generator/package.json +2 -1
  3. package/dist/languages/treb-i18n-da.mjs +1 -1
  4. package/dist/languages/treb-i18n-de.mjs +1 -1
  5. package/dist/languages/treb-i18n-es.mjs +1 -1
  6. package/dist/languages/treb-i18n-fr.mjs +1 -1
  7. package/dist/languages/treb-i18n-it.mjs +1 -1
  8. package/dist/languages/treb-i18n-nl.mjs +1 -1
  9. package/dist/languages/treb-i18n-no.mjs +1 -1
  10. package/dist/languages/treb-i18n-pl.mjs +1 -1
  11. package/dist/languages/treb-i18n-pt.mjs +1 -1
  12. package/dist/languages/treb-i18n-sv.mjs +1 -1
  13. package/dist/treb-export-worker.mjs +2 -2
  14. package/dist/treb-spreadsheet.mjs +13 -13
  15. package/dist/treb.d.ts +19 -2
  16. package/package.json +8 -7
  17. package/treb-base-types/src/font-stack.ts +144 -0
  18. package/treb-base-types/src/style.ts +121 -11
  19. package/treb-base-types/src/theme.ts +53 -8
  20. package/treb-calculator/src/calculator.ts +13 -13
  21. package/treb-calculator/src/descriptors.ts +12 -4
  22. package/treb-calculator/src/expression-calculator.ts +17 -4
  23. package/treb-calculator/src/functions/base-functions.ts +57 -4
  24. package/treb-calculator/src/functions/statistics-functions.ts +9 -6
  25. package/treb-calculator/tsconfig.json +11 -0
  26. package/treb-charts/style/charts.scss +7 -1
  27. package/treb-data-model/src/annotation.ts +6 -0
  28. package/treb-data-model/src/data_model.ts +14 -3
  29. package/treb-data-model/src/language-model.ts +11 -2
  30. package/treb-data-model/src/sheet.ts +57 -56
  31. package/treb-embed/markup/toolbar.html +15 -1
  32. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +38 -0
  33. package/treb-embed/src/embedded-spreadsheet.ts +139 -32
  34. package/treb-embed/src/options.ts +3 -0
  35. package/treb-embed/src/selection-state.ts +1 -0
  36. package/treb-embed/src/toolbar-message.ts +6 -0
  37. package/treb-embed/src/types.ts +9 -0
  38. package/treb-embed/style/defaults.scss +12 -1
  39. package/treb-embed/style/font-stacks.scss +105 -0
  40. package/treb-embed/style/layout.scss +1 -0
  41. package/treb-embed/style/theme-defaults.scss +12 -2
  42. package/treb-embed/style/toolbar.scss +16 -0
  43. package/treb-grid/src/editors/overlay_editor.ts +36 -3
  44. package/treb-grid/src/layout/base_layout.ts +52 -37
  45. package/treb-grid/src/layout/grid_layout.ts +7 -0
  46. package/treb-grid/src/render/tile_renderer.ts +156 -148
  47. package/treb-grid/src/types/grid.ts +188 -54
  48. package/treb-grid/src/types/grid_events.ts +1 -1
  49. package/treb-grid/src/types/grid_options.ts +3 -0
  50. package/treb-grid/src/util/fontmetrics.ts +134 -0
  51. package/treb-parser/src/parser.ts +12 -3
  52. package/treb-utils/src/measurement.ts +2 -3
  53. package/tsproject.json +1 -1
  54. package/treb-calculator/modern.tsconfig.json +0 -11
  55. package/treb-grid/src/util/fontmetrics2.ts +0 -182
  56. package/treb-parser/src/parser.test.ts +0 -298
  57. /package/treb-embed/{modern.tsconfig.json → tsconfig.json} +0 -0
  58. /package/treb-export/{modern.tsconfig.json → tsconfig.json} +0 -0
@@ -759,6 +759,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
759
759
  // delete_tab: this.options.delete_tab,
760
760
  expand: this.options.expand,
761
761
 
762
+ support_font_stacks: !!this.options.font_stack,
763
+
762
764
  };
763
765
 
764
766
  if (this.options.scale) {
@@ -838,7 +840,12 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
838
840
  // if we don't have a container. that's distinct (at the moment)
839
841
  // from headless, which is a state that can change.
840
842
 
841
- this.grid = new Grid(grid_options, this.model, undefined, !!container, this.DOM);
843
+ this.grid = new Grid(
844
+ grid_options,
845
+ this.model,
846
+ undefined,
847
+ !!container,
848
+ this.DOM);
842
849
 
843
850
  if (this.options.headless) {
844
851
  this.grid.headless = true; // FIXME: move into grid options
@@ -1003,7 +1010,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1003
1010
 
1004
1011
  case 'scale':
1005
1012
  this.RebuildAllAnnotations();
1006
- this.events.Publish({ type: 'view-change' });
1013
+ this.Publish({ type: 'view-change' });
1007
1014
  break;
1008
1015
 
1009
1016
  case 'annotation':
@@ -1013,32 +1020,48 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1013
1020
  if (event.annotation) {
1014
1021
  const view: AnnotationViewData = event.annotation.view[this.grid.view_index] || {};
1015
1022
 
1016
- this.DocumentChange();
1017
- switch (event.event) {
1018
- case 'create':
1019
- this.InflateAnnotation(event.annotation);
1020
- this.calculator.UpdateAnnotations(event.annotation, this.grid.active_sheet);
1021
- this.grid.AnnotationUpdated(event.annotation);
1022
- break;
1023
- case 'delete':
1024
- this.calculator.RemoveAnnotation(event.annotation); // clean up vertex
1025
- break;
1026
- case 'update':
1027
- if (view.update_callback) {
1028
- view.update_callback();
1029
- this.grid.AnnotationUpdated(event.annotation);
1030
- }
1031
- else {
1032
- console.info('annotation update event without update callback');
1033
- }
1034
- this.calculator.UpdateAnnotations(event.annotation, this.grid.active_sheet);
1035
- break;
1036
- case 'resize':
1037
- if (view.resize_callback) {
1038
- view.resize_callback();
1023
+ let update_toolbar = false;
1024
+
1025
+ if (event.event === 'select') {
1026
+ update_toolbar = true;
1027
+ }
1028
+ else {
1029
+ this.DocumentChange();
1030
+ switch (event.event) {
1031
+ case 'create':
1032
+ this.InflateAnnotation(event.annotation);
1033
+ this.calculator.UpdateAnnotations(event.annotation, this.grid.active_sheet);
1039
1034
  this.grid.AnnotationUpdated(event.annotation);
1040
- }
1041
- break;
1035
+ update_toolbar = (event.annotation === this.grid.selected_annotation);
1036
+ break;
1037
+ case 'delete':
1038
+ this.calculator.RemoveAnnotation(event.annotation); // clean up vertex
1039
+ break;
1040
+ case 'update':
1041
+ if (view.update_callback) {
1042
+ view.update_callback();
1043
+ this.grid.AnnotationUpdated(event.annotation);
1044
+ }
1045
+ else {
1046
+ console.info('annotation update event without update callback');
1047
+ }
1048
+ this.calculator.UpdateAnnotations(event.annotation, this.grid.active_sheet);
1049
+ update_toolbar = (event.annotation === this.grid.selected_annotation);
1050
+ break;
1051
+ case 'resize':
1052
+ if (view.resize_callback) {
1053
+ view.resize_callback();
1054
+ this.grid.AnnotationUpdated(event.annotation);
1055
+ }
1056
+ break;
1057
+ }
1058
+
1059
+ }
1060
+
1061
+ if (update_toolbar) {
1062
+ this.UpdateSelectionStyleAnnotation(event.annotation);
1063
+ this.Publish({ type: 'annotation-selection' });
1064
+ break;
1042
1065
  }
1043
1066
 
1044
1067
  }
@@ -1207,6 +1230,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1207
1230
  map[entry.base.toUpperCase()] = entry;
1208
1231
  }
1209
1232
 
1233
+ // console.info({map});
1234
+
1210
1235
  list = list.map(descriptor => {
1211
1236
  const partial = map[descriptor.name.toUpperCase()];
1212
1237
 
@@ -1216,10 +1241,25 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1216
1241
  // setting function names / descriptions.
1217
1242
 
1218
1243
  if (partial) {
1219
- return {
1244
+
1245
+ const clone: FunctionDescriptor = JSON.parse(JSON.stringify({
1220
1246
  ...descriptor,
1221
- ...partial,
1222
- };
1247
+ name: partial.name,
1248
+ }));
1249
+
1250
+ if (partial.description) {
1251
+ clone.description = partial.description;
1252
+ }
1253
+ if (partial.arguments && clone.arguments) {
1254
+ for (const [index, argument] of partial.arguments.entries()) {
1255
+ if (clone.arguments[index]) {
1256
+ clone.arguments[index].name = argument;
1257
+ }
1258
+ }
1259
+ }
1260
+
1261
+ return clone;
1262
+
1223
1263
  }
1224
1264
  return descriptor;
1225
1265
  });
@@ -1557,6 +1597,34 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1557
1597
 
1558
1598
  let updated_style: CellStyle = {};
1559
1599
 
1600
+ if (this.grid.AnnotationSelected()) {
1601
+
1602
+ // only handle a limited set of commands, then
1603
+
1604
+ switch (event.command) {
1605
+ case 'font-scale':
1606
+ {
1607
+ const scale = Number(event.scale || 1);
1608
+ if (scale && !isNaN(scale)) {
1609
+ updated_style.font_size = { unit: 'em', value: scale };
1610
+ this.grid.ApplyAnnotationStyle(updated_style);
1611
+ }
1612
+ }
1613
+ break;
1614
+
1615
+ case 'font-stack':
1616
+ if (event.font_stack) {
1617
+ updated_style.font_face = 'stack:' + event.font_stack;
1618
+ }
1619
+ this.grid.ApplyAnnotationStyle(updated_style);
1620
+ break;
1621
+ }
1622
+
1623
+ this.Focus();
1624
+ return;
1625
+
1626
+ }
1627
+
1560
1628
  const insert_annotation = (func: string) => {
1561
1629
  const selection = this.grid.GetSelection();
1562
1630
  if (selection && !selection.empty) {
@@ -1608,6 +1676,12 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1608
1676
  updated_style.number_format = event.format || 'General';
1609
1677
  break;
1610
1678
 
1679
+ case 'font-stack':
1680
+ if (event.font_stack) {
1681
+ updated_style.font_face = 'stack:' + event.font_stack;
1682
+ }
1683
+ break;
1684
+
1611
1685
  case 'font-scale':
1612
1686
 
1613
1687
  // above we handle 'font-size' events; this comes from a dropdown,
@@ -1615,6 +1689,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1615
1689
  // FIXME: break out
1616
1690
 
1617
1691
  {
1692
+
1618
1693
  const selection = this.grid.GetSelection();
1619
1694
  const area = this.grid.active_sheet.RealArea(selection.area);
1620
1695
  const scale = Number(event.scale || 1);
@@ -1899,7 +1974,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1899
1974
  if (Object.keys(updated_style).length) {
1900
1975
  this.grid.ApplyStyle(undefined, updated_style, true);
1901
1976
  }
1902
-
1977
+
1903
1978
  this.Focus();
1904
1979
 
1905
1980
  }
@@ -5813,6 +5888,26 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5813
5888
  this.Publish({ type: 'selection' });
5814
5889
  }
5815
5890
 
5891
+ /** update selection style for the toolbar, when an annotation is selected. */
5892
+ protected UpdateSelectionStyleAnnotation(annotation: Annotation) {
5893
+
5894
+ const state: SelectionState = {
5895
+ style: JSON.parse(JSON.stringify(annotation.data.style || {})),
5896
+ };
5897
+
5898
+ if (state.style) {
5899
+ if (!state.style.font_face) {
5900
+ state.style.font_face = 'stack:ui';
5901
+ }
5902
+ if (!state.style.font_size) {
5903
+ state.style.font_size = { unit: 'em', value: 1 };
5904
+ }
5905
+ }
5906
+
5907
+ state.relative_font_size = Style.RelativeFontSize(state.style || {}, this.grid.theme.grid_cell || {});
5908
+ this.selection_state = state;
5909
+
5910
+ }
5816
5911
 
5817
5912
  /** update selection style for the toolbar */
5818
5913
  protected UpdateSelectionStyle(selection?: GridSelection): void {
@@ -5845,10 +5940,22 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5845
5940
  state.style = data.style ? { ...data.style } : undefined;
5846
5941
  state.relative_font_size = Style.RelativeFontSize(state.style || {}, this.grid.theme.grid_cell || {});
5847
5942
 
5943
+ state.empty = typeof data.value === 'undefined' && !data.style?.font_face;
5944
+
5945
+ // let's not do this
5946
+ /*
5947
+ if (state.empty && state.style) {
5948
+ state.style.font_face = this.selection_state.style?.font_face || undefined;
5949
+ }
5950
+ */
5951
+
5952
+ }
5953
+
5954
+ if (this.grid?.edit_state) {
5955
+ this.grid.edit_state.font_face = state.style?.font_face || undefined;
5848
5956
  }
5849
5957
 
5850
5958
  this.selection_state = state;
5851
- // this.toolbar?.UpdateState(state);
5852
5959
 
5853
5960
  }
5854
5961
 
@@ -187,6 +187,9 @@ export interface EmbeddedSpreadsheetOptions {
187
187
  /** include the font scale control in the toolbar */
188
188
  font_scale?: boolean;
189
189
 
190
+ /** include the font stack control in the toolbar */
191
+ font_stack?: boolean;
192
+
190
193
  /** include the insert/remove table button in the toolbar */
191
194
  table_button?: boolean;
192
195
 
@@ -10,6 +10,7 @@ export interface SelectionState {
10
10
  merge?: boolean;
11
11
  table?: boolean;
12
12
  frozen?: boolean;
13
+ empty?: boolean;
13
14
  comment?: string;
14
15
  selection?: GridSelection;
15
16
  relative_font_size?: number;
@@ -55,6 +55,11 @@ export interface FontScaleToolbarMessage {
55
55
  scale?: number;
56
56
  }
57
57
 
58
+ export interface FontStackToolbarMessage {
59
+ command: 'font-stack';
60
+ font_stack?: string;
61
+ }
62
+
58
63
  export interface NumberFormatToolbarMessage {
59
64
  command: 'number-format';
60
65
  format?: string;
@@ -103,4 +108,5 @@ export type ToolbarMessage
103
108
  | IndentMessage
104
109
  | NumberFormatToolbarMessage
105
110
  | FontScaleToolbarMessage
111
+ | FontStackToolbarMessage
106
112
  ;
@@ -198,6 +198,14 @@ export interface SelectionEvent {
198
198
  type: 'selection';
199
199
  }
200
200
 
201
+ /**
202
+ * this event is used when an annotation is selected. we're not changing
203
+ * the original selection event, because I don't want to break anything.
204
+ */
205
+ export interface AnnotationSelectionEvent {
206
+ type: 'annotation-selection';
207
+ }
208
+
201
209
  /**
202
210
  * This event is sent when the focused view changes, if you have more
203
211
  * than one view.
@@ -220,6 +228,7 @@ export type EmbeddedSheetEvent
220
228
  | FocusViewEvent
221
229
  | SelectionEvent
222
230
  | ResizeEvent
231
+ | AnnotationSelectionEvent
223
232
  ;
224
233
 
225
234
  /**
@@ -25,8 +25,19 @@ $default-box-shadow: 0px 1px 4px 2px rgba(109,109,109,0.2);
25
25
 
26
26
  $tooltip-arrow-size: 4px;
27
27
 
28
+ //
29
+ // -apple-system came out because it would break safari when rendering
30
+ // certain characters. if you render an acute angle character ("⦟", U+299F)
31
+ // in a canvas in safari with -apple-system, javascript will stop. no
32
+ // exception, no error, it just stops.
33
+ //
34
+ // that was ca 2023? haven't tested this lately so it may be resolved by now.
35
+ //
36
+
37
+ // "BlinkMacSystemFont" magically turns into "system-ui"? that's incredibly annoying.
38
+
28
39
  $font-stack: // "-apple-system",
29
- "BlinkMacSystemFont",
40
+ "BlinkMacSystemFont", // this turns into "system-ui"? wuwt? is that a sass thing?
30
41
  "Segoe UI",
31
42
  "Roboto",
32
43
  "Oxygen-Sans",
@@ -0,0 +1,105 @@
1
+ /*
2
+ * This file is part of TREB.
3
+ *
4
+ * TREB is free software: you can redistribute it and/or modify it under the
5
+ * terms of the GNU General Public License as published by the Free Software
6
+ * Foundation, either version 3 of the License, or (at your option) any
7
+ * later version.
8
+ *
9
+ * TREB is distributed in the hope that it will be useful, but WITHOUT ANY
10
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
+ * details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License along
15
+ * with TREB. If not, see <https://www.gnu.org/licenses/>.
16
+ *
17
+ * Copyright 2022-2024 trebco, llc.
18
+ * info@treb.app
19
+ *
20
+ */
21
+
22
+ //
23
+ // thanks to
24
+ // https://modernfontstacks.com/
25
+ //
26
+ // for the stacks. we make some minor changes, mostly because of browser issues.
27
+ //
28
+
29
+ .treb-main.treb-main {
30
+
31
+ /* default size for fonts in grid cells */
32
+ --treb-font-stack-default-size: 14px;
33
+
34
+ /* size adjustment for some fonts */
35
+ --treb-font-stack-calibri-size: 16px;
36
+ --treb-font-stack-tscu-comic-size: 16px;
37
+ --treb-font-stack-helvetica-neue-size: 13px;
38
+ --treb-font-stack-cambria-size: 16px;
39
+
40
+ /* flag that we need to use font variants (chrome only) */
41
+ --treb-font-stack-sitka-text-variant: lining-nums tabular-nums;
42
+
43
+ /*
44
+ * os-specific size adjustment. it's not that important but for consistency
45
+ * with the old layout this should be 10pt, ~13.33px. I notice that the
46
+ * editor is slightly off from the canvas rendering, I assume that's related
47
+ * to the subpixel size? maybe we should break from the old version. (or
48
+ * maybe we can fix the editor?)
49
+ */
50
+ &.treb-ua-osx {
51
+ --treb-font-stack-system-ui-size: 10pt;
52
+ }
53
+
54
+ /**
55
+ * this is the default font. it's also used for other font stacks
56
+ * if stacks are turned off (the default, for now).
57
+ */
58
+ .treb-font-stack-default {
59
+
60
+ // I love avenir but the bold is too bold. can we adjust it?
61
+
62
+ // font-family: calibri, avenir, $font-stack;
63
+ font-family: calibri, $font-stack;
64
+
65
+ }
66
+
67
+ .treb-font-stack-transitional {
68
+
69
+ // we drop sitka text because the bounding box isn't calculating properly
70
+ // for some reason -- variants? also, firefox does not support numeric
71
+ // variants in canvas and the sitka default is old-style non-tabular nums.
72
+
73
+ // font-family: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif;
74
+ font-family: Charter, 'Bitstream Charter', Cambria, serif;
75
+
76
+ }
77
+
78
+ /* not using this atm, we just have one serif (the transitional) */
79
+ .treb-font-stack-old-style {
80
+ font-family: 'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif;
81
+ }
82
+
83
+ .treb-font-stack-handwritten {
84
+
85
+ // not sure I believe that that tscu comic font is widely installed...
86
+ // there might be a better alternative.
87
+
88
+ font-family: 'Segoe Print', 'Bradley Hand', Chilanka, TSCu_Comic, casual, cursive;
89
+ }
90
+
91
+ /* not using this atm */
92
+ .treb-font-stack-industrial {
93
+ font-family: Bahnschrift, 'DIN Alternate', 'Franklin Gothic Medium', 'Nimbus Sans Narrow', sans-serif-condensed, sans-serif;
94
+ }
95
+
96
+ /* not a slab */
97
+ .treb-font-stack-monospace {
98
+ font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
99
+ }
100
+
101
+ .treb-font-stack-ui {
102
+ font-family: system-ui, sans-serif;
103
+ }
104
+
105
+ }
@@ -7,6 +7,7 @@
7
7
  @import './spinner.scss';
8
8
  @import './treb-icons.scss';
9
9
  @import './toolbar.scss';
10
+ @import './font-stacks.scss';
10
11
 
11
12
  /*
12
13
  * switching to a double-selector to increase specificity. the particular
@@ -192,7 +192,16 @@ $text-reference-color-5: rgb(254, 47, 1);
192
192
  */
193
193
  .grid-cells {
194
194
  font-family: var(--treb-grid-font-family, inherit);
195
+
196
+ // it seems like the old default was 14px / 16px for calibri on windows?
197
+ // we should get back to that, then we can adjust calibri (in the stacks)
198
+ // to scale.
199
+
200
+ // font-size: var(--treb-grid-font-size, 10px);
201
+ // font-size: var(--treb-grid-font-size, 10pt);
202
+
195
203
  font-size: var(--treb-grid-font-size, 14px);
204
+
196
205
  color: var(--treb-grid-default-color, inherit);
197
206
  stroke: var(--treb-grid-grid-color, rgb(204, 204, 212));
198
207
  background: var(--treb-grid-background, #fff);
@@ -520,11 +529,11 @@ $text-reference-color-5: rgb(254, 47, 1);
520
529
 
521
530
 
522
531
 
523
- /**
532
+ /* *
524
533
  * special override for windows, using calibri (which is too small).
525
534
  * you should still be able to override with a regular theme style,
526
535
  * or (potentially) also override for windows specifically. fancy!
527
- */
536
+ * /
528
537
  &.treb-ua-windows .grid-cells {
529
538
  font-size: var(--treb-grid-font-size-windows, var(--treb-grid-font-size, 12pt));
530
539
  font-family: var(--treb-grid-font-family-windows, var(--treb-grid-font-family, "Calibri", $font-stack)); // does this actually work? is this included? (...)
@@ -534,6 +543,7 @@ $text-reference-color-5: rgb(254, 47, 1);
534
543
  font-size: var(--treb-grid-font-size-osx, var(--treb-grid-font-size, 10pt)); // slightly smaller default
535
544
  font-family: var(--treb-grid-font-family-osx, var(--treb-grid-font-family, inherit));
536
545
  }
546
+ */
537
547
 
538
548
  /**
539
549
  *
@@ -157,6 +157,13 @@ $swatch-size: 18px;
157
157
  mask-size: var(--icon-size, 16px 16px);
158
158
  -webkit-mask-size: var(--icon-size, 16px 16px);
159
159
  }
160
+
161
+ &.treb-font-stack {
162
+ &::before {
163
+ display: none;
164
+ }
165
+ }
166
+
160
167
  }
161
168
 
162
169
  }
@@ -193,6 +200,15 @@ $swatch-size: 18px;
193
200
 
194
201
  }
195
202
 
203
+ .treb-font-stack {
204
+ width: 8em;
205
+ align-items: flex-start;
206
+ overflow: hidden;
207
+ &::before {
208
+ display: none;
209
+ }
210
+ }
211
+
196
212
  .treb-menu {
197
213
 
198
214
  // on Safari, we need to make these menus focus targets, so we can
@@ -67,6 +67,9 @@ export class OverlayEditor extends Editor<ResetSelectionEvent> {
67
67
 
68
68
  // ---------------------------------------------------------------------------
69
69
 
70
+ /** possibly carrying over a font face (+size?) */
71
+ public edit_style?: CellStyle;
72
+
70
73
  /**
71
74
  * this is a flag used to indicate when we need to reset the selection.
72
75
  * the issue has to do with selecting cells via arrow keys; if you do
@@ -273,7 +276,7 @@ export class OverlayEditor extends Editor<ResetSelectionEvent> {
273
276
  *
274
277
  * something to do with keyboard selection? (which needs to be fixed)?
275
278
  */
276
- public Edit(gridselection: GridSelection, rect: Rectangle, cell: Cell, value?: CellValue, event?: Event): void {
279
+ public Edit(gridselection: GridSelection, rect: Rectangle, cell: Cell, value?: CellValue, event?: Event, edit_style?: CellStyle): void {
277
280
 
278
281
  this.Publish({
279
282
  type: 'start-editing',
@@ -284,9 +287,33 @@ export class OverlayEditor extends Editor<ResetSelectionEvent> {
284
287
  this.target_address = {...gridselection.target};
285
288
  this.reset_selection = false;
286
289
 
287
- const style: CellStyle = cell.style || {};
290
+ const style: CellStyle = JSON.parse(JSON.stringify(cell.style || {})); // clone
291
+
292
+ //
293
+ // CURRENT ISSUE: this works, but the style is not actually applied to
294
+ // the cell. we need to modify the commit routine to apply the style.
295
+ // I think?
296
+ //
297
+ // WAIT, that might not be right... might have something to do with
298
+ // default?
299
+ //
300
+
301
+ this.edit_style = edit_style; // set (or unset)
302
+
303
+ if (edit_style?.font_face) {
304
+ style.font_face = edit_style.font_face;
305
+ }
306
+
307
+ const font_info = Style.CompositeFont(this.theme.grid_cell_font_size, style, this.scale, this.theme);
308
+
309
+ this.edit_node.style.font = font_info.font;
310
+ if (font_info.variants) {
311
+ this.edit_node.style.fontVariant = font_info.variants;
312
+ }
313
+ else {
314
+ this.edit_node.style.fontVariant = '';
315
+ }
288
316
 
289
- this.edit_node.style.font = Style.Font(style, this.scale);
290
317
  this.edit_node.style.color = ResolveThemeColor(this.theme, style.text, 1);
291
318
  this.edit_inset.style.backgroundColor = ResolveThemeColor(this.theme, style.fill, 0);
292
319
 
@@ -332,6 +359,12 @@ export class OverlayEditor extends Editor<ResetSelectionEvent> {
332
359
 
333
360
  rect.ApplyStyle(this.container_node);
334
361
 
362
+ // trial and error. still a little wonky at scales, but reasonable.
363
+
364
+ const offset = UA.is_mac ? 0 : 0.5;
365
+
366
+ this.edit_node.style.bottom = offset.toFixed(2) + 'px'; // does this need to scale for dpr? not sure
367
+
335
368
  this.autocomplete?.ResetBlock();
336
369
  this.selection = gridselection;
337
370