microboard-temp 0.7.0 → 0.8.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.
@@ -7211,7 +7211,7 @@ var conf = {
7211
7211
  "rgb(231, 232, 238)",
7212
7212
  "rgb(156, 156, 156)"
7213
7213
  ],
7214
- DEFAULT_STICKER_COLOR: "rgb(233, 208, 255)",
7214
+ DEFAULT_STICKER_COLOR: semanticColor("contrastBlue"),
7215
7215
  STICKER_COLOR_NAMES: [
7216
7216
  "purple",
7217
7217
  "pink",
@@ -7421,7 +7421,7 @@ var conf = {
7421
7421
  DEFAULT_TEXT_STYLES: {
7422
7422
  fontFamily: "Manrope",
7423
7423
  fontSize: 14,
7424
- fontColor: "rgb(20, 21, 26)",
7424
+ fontColor: semanticColor("contrastNeutral"),
7425
7425
  fontHighlight: "",
7426
7426
  lineHeight: 1.4,
7427
7427
  bold: false,
@@ -9105,7 +9105,7 @@ function getTextStyle(data) {
9105
9105
  const leafStyle = {
9106
9106
  fontStyle: "normal",
9107
9107
  fontWeight: "normal",
9108
- color: data.fontColor ?? "black",
9108
+ color: data.fontColor ?? semanticColor("contrastNeutral"),
9109
9109
  backgroundColor: data.fontHighlight,
9110
9110
  fontSize: data.fontSize ?? 14,
9111
9111
  fontFamily: data.fontFamily ?? "Arial"
@@ -9565,7 +9565,7 @@ function fillHighlight(ctx, textBlock) {
9565
9565
  return;
9566
9566
  }
9567
9567
  const measure = textBlock.measure;
9568
- ctx.fillStyle = textBlock.style.backgroundColor;
9568
+ ctx.fillStyle = resolveColor(textBlock.style.backgroundColor, conf.theme, "background");
9569
9569
  ctx.fillRect(textBlock.x, textBlock.y - measure.ascent, measure.width, measure.height);
9570
9570
  }
9571
9571
  function underline(ctx, textBlock) {
@@ -9577,14 +9577,13 @@ function underline(ctx, textBlock) {
9577
9577
  const style = textBlock.style;
9578
9578
  const measure = textBlock.measure;
9579
9579
  const width = measure.width - (textBlock.marginLeft || 0);
9580
- const color = style.color;
9581
- ctx.strokeStyle = color;
9580
+ ctx.strokeStyle = resolveColor(style.color, conf.theme, "foreground");
9582
9581
  ctx.lineWidth = textBlock.fontSize / 14;
9583
9582
  ctx.beginPath();
9584
9583
  ctx.moveTo(x, y + 2 * textBlock.fontSize / 14);
9585
9584
  ctx.lineTo(x + width, y + 2 * textBlock.fontSize / 14);
9586
9585
  ctx.stroke();
9587
- ctx.strokeStyle = style.backgroundColor ?? "black";
9586
+ ctx.strokeStyle = style.backgroundColor ? resolveColor(style.backgroundColor, conf.theme, "background") : "black";
9588
9587
  ctx.lineWidth = 2;
9589
9588
  }
9590
9589
  function cross(ctx, textBlock) {
@@ -9597,19 +9596,18 @@ function cross(ctx, textBlock) {
9597
9596
  const measure = textBlock.measure;
9598
9597
  const width = measure.width;
9599
9598
  const height = measure.height;
9600
- const color = style.color;
9601
- ctx.strokeStyle = color;
9599
+ ctx.strokeStyle = resolveColor(style.color, conf.theme, "foreground");
9602
9600
  ctx.lineWidth = textBlock.fontSize / 14;
9603
9601
  ctx.beginPath();
9604
9602
  ctx.moveTo(x, y - height / 4);
9605
9603
  ctx.lineTo(x + width, y - height / 4);
9606
9604
  ctx.stroke();
9607
- ctx.strokeStyle = style.backgroundColor ?? "black";
9605
+ ctx.strokeStyle = style.backgroundColor ? resolveColor(style.backgroundColor, conf.theme, "background") : "black";
9608
9606
  ctx.lineWidth = 2;
9609
9607
  }
9610
9608
  function fillText(ctx, textBlock) {
9611
9609
  const { text, style, x, y } = textBlock;
9612
- ctx.fillStyle = style.color;
9610
+ ctx.fillStyle = resolveColor(style.color, conf.theme, "foreground");
9613
9611
  ctx.fillText(text, x, y);
9614
9612
  if (textBlock.listMark) {
9615
9613
  ctx.fillText(textBlock.listMark, x - measureText(textBlock.listMark, style).width - 4, y);
@@ -16896,7 +16894,7 @@ function setSelectionFontHighlight(editor, format, selectionContext) {
16896
16894
  }
16897
16895
  if (format === "none") {
16898
16896
  import_slate25.Editor.removeMark(editor, "fontHighlight");
16899
- } else if (marks.fontHighlight === format) {
16897
+ } else if (typeof format === "string" && marks.fontHighlight === format) {
16900
16898
  import_slate25.Editor.removeMark(editor, "fontHighlight");
16901
16899
  } else {
16902
16900
  import_slate25.Editor.addMark(editor, "fontHighlight", format);
@@ -22651,8 +22649,8 @@ class RichText extends BaseItem {
22651
22649
  node2.underline ? "underline" : "",
22652
22650
  node2["line-through"] ? "line-through" : ""
22653
22651
  ].filter(Boolean).join(" "),
22654
- color: node2.fontColor || conf.DEFAULT_TEXT_STYLES.fontColor,
22655
- backgroundColor: node2.fontHighlight || conf.DEFAULT_TEXT_STYLES.fontHighlight,
22652
+ color: node2.fontColor ? resolveColor(node2.fontColor, conf.theme, "foreground") : conf.DEFAULT_TEXT_STYLES.fontColor,
22653
+ backgroundColor: node2.fontHighlight ? resolveColor(node2.fontHighlight, conf.theme, "background") : conf.DEFAULT_TEXT_STYLES.fontHighlight,
22656
22654
  fontSize: node2.fontSize ? `${node2.fontSize}px` : `${conf.DEFAULT_TEXT_STYLES.fontSize}px`,
22657
22655
  fontFamily: node2.fontFamily || conf.DEFAULT_TEXT_STYLES.fontFamily
22658
22656
  });
@@ -37817,6 +37815,12 @@ class Connector2 extends BaseItem {
37817
37815
  mbr.strokeWidth = 3;
37818
37816
  mbr.borderStyle = "solid";
37819
37817
  this.clipText(context);
37818
+ const resolvedLineColor = resolveColor(this.lineColor, conf.theme, "foreground");
37819
+ this.lines.setBorderColor(resolvedLineColor);
37820
+ this.startPointer.path.setBorderColor(resolvedLineColor);
37821
+ this.startPointer.path.setBackgroundColor(resolvedLineColor);
37822
+ this.endPointer.path.setBorderColor(resolvedLineColor);
37823
+ this.endPointer.path.setBackgroundColor(resolvedLineColor);
37820
37824
  if (!this.text.isRenderEnabled && this.board.selection.getContext() !== "EditTextUnderPointer") {
37821
37825
  this.lines.render(context);
37822
37826
  }
@@ -38098,17 +38102,11 @@ class Connector2 extends BaseItem {
38098
38102
  const endPoint = this.endPoint;
38099
38103
  this.lines = getLine(this.lineStyle, startPoint, endPoint, this.middlePoint).addConnectedItemType(this.itemType);
38100
38104
  this.startPointer = getStartPointer(startPoint, this.startPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.2);
38101
- const resolvedLineColor = resolveColor(this.lineColor, conf.theme, "foreground");
38102
- this.startPointer.path.setBorderColor(resolvedLineColor);
38103
38105
  this.startPointer.path.setBorderWidth(this.lineWidth);
38104
- this.startPointer.path.setBackgroundColor(resolvedLineColor);
38105
38106
  this.endPointer = getEndPointer(endPoint, this.endPointerStyle, this.lineStyle, this.lines, this.lineWidth * 0.1 + 0.2);
38106
- this.endPointer.path.setBorderColor(resolvedLineColor);
38107
38107
  this.endPointer.path.setBorderWidth(this.lineWidth);
38108
- this.endPointer.path.setBackgroundColor(resolvedLineColor);
38109
38108
  this.offsetLines();
38110
38109
  this.lines.setBorderWidth(this.lineWidth);
38111
- this.lines.setBorderColor(resolvedLineColor);
38112
38110
  this.lines.setBorderStyle(this.borderStyle);
38113
38111
  this.updateTitle();
38114
38112
  }
@@ -39888,7 +39886,6 @@ class Shape extends BaseItem {
39888
39886
  }
39889
39887
  applyBackgroundColor(backgroundColor) {
39890
39888
  this.backgroundColor = backgroundColor;
39891
- this.path.setBackgroundColor(resolveColor(backgroundColor, conf.theme, "background"));
39892
39889
  }
39893
39890
  setBackgroundColor(backgroundColor) {
39894
39891
  this.emit({
@@ -39924,7 +39921,6 @@ class Shape extends BaseItem {
39924
39921
  }
39925
39922
  applyBorderColor(borderColor) {
39926
39923
  this.borderColor = borderColor;
39927
- this.path.setBorderColor(resolveColor(borderColor, conf.theme, "foreground"));
39928
39924
  }
39929
39925
  setBorderColor(borderColor) {
39930
39926
  this.emit({
@@ -40032,6 +40028,8 @@ class Shape extends BaseItem {
40032
40028
  if (this.transformationRenderBlock) {
40033
40029
  return;
40034
40030
  }
40031
+ this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
40032
+ this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
40035
40033
  this.path.render(context);
40036
40034
  this.text.render(context);
40037
40035
  if (this.getLinkTo()) {
@@ -40132,9 +40130,7 @@ class Shape extends BaseItem {
40132
40130
  this.text.setContainer(this.textContainer.copy());
40133
40131
  this.textContainer.transform(this.transformation.toMatrix());
40134
40132
  this.path.transform(this.transformation.toMatrix());
40135
- this.path.setBackgroundColor(this.backgroundColor);
40136
40133
  this.path.setBackgroundOpacity(this.backgroundOpacity);
40137
- this.path.setBorderColor(this.borderColor);
40138
40134
  this.path.setBorderWidth(this.borderWidth);
40139
40135
  this.path.setBorderStyle(this.borderStyle);
40140
40136
  this.path.setBorderOpacity(this.borderOpacity);
@@ -40183,7 +40179,7 @@ class StickerData {
40183
40179
  linkTo;
40184
40180
  text;
40185
40181
  itemType = "Sticker";
40186
- constructor(backgroundColor = fixedColor(stickerColors["Sky Blue"]), transformation = new DefaultTransformationData, linkTo, text5 = new DefaultRichTextData([], "center", undefined)) {
40182
+ constructor(backgroundColor = semanticColor("contrastBlue"), transformation = new DefaultTransformationData, linkTo, text5 = new DefaultRichTextData([], "center", undefined)) {
40187
40183
  this.backgroundColor = backgroundColor;
40188
40184
  this.transformation = transformation;
40189
40185
  this.linkTo = linkTo;
@@ -40321,7 +40317,6 @@ class Sticker extends BaseItem {
40321
40317
  this.stickerPath.transform(this.transformation.toMatrix());
40322
40318
  this.text.setContainer(this.textContainer.copy());
40323
40319
  this.textContainer.transform(this.transformation.toMatrix());
40324
- this.stickerPath.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
40325
40320
  this.saveStickerData();
40326
40321
  }
40327
40322
  setId(id) {
@@ -40365,7 +40360,6 @@ class Sticker extends BaseItem {
40365
40360
  }
40366
40361
  applyBackgroundColor(backgroundColor) {
40367
40362
  this.backgroundColor = backgroundColor;
40368
- this.stickerPath.setBackgroundColor(resolveColor(backgroundColor, conf.theme, "background"));
40369
40363
  }
40370
40364
  setBackgroundColor(backgroundColor) {
40371
40365
  this.emit({
@@ -40412,6 +40406,7 @@ class Sticker extends BaseItem {
40412
40406
  return;
40413
40407
  }
40414
40408
  this.renderShadow(context);
40409
+ this.stickerPath.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
40415
40410
  this.stickerPath.render(context);
40416
40411
  this.text.render(context);
40417
40412
  if (this.getLinkTo()) {
@@ -40954,9 +40949,7 @@ class Frame2 extends BaseItem {
40954
40949
  this.path.transform(this.transformation.toMatrix());
40955
40950
  this.textContainer.transform(this.transformation.toMatrix());
40956
40951
  }
40957
- this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
40958
40952
  this.path.setBackgroundOpacity(this.backgroundOpacity);
40959
- this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
40960
40953
  this.path.setBorderWidth(this.borderWidth);
40961
40954
  this.path.setBorderStyle(this.borderStyle);
40962
40955
  this.path.setBorderOpacity(this.borderOpacity);
@@ -41107,7 +41100,6 @@ class Frame2 extends BaseItem {
41107
41100
  }
41108
41101
  applyBackgroundColor(backgroundColor) {
41109
41102
  this.backgroundColor = backgroundColor;
41110
- this.path.setBackgroundColor(resolveColor(backgroundColor, conf.theme, "background"));
41111
41103
  }
41112
41104
  setBackgroundColor(backgroundColor) {
41113
41105
  this.emit({
@@ -41155,6 +41147,8 @@ class Frame2 extends BaseItem {
41155
41147
  if (this.transformationRenderBlock) {
41156
41148
  return;
41157
41149
  }
41150
+ this.path.setBackgroundColor(resolveColor(this.backgroundColor, conf.theme, "background"));
41151
+ this.path.setBorderColor(resolveColor(this.borderColor, conf.theme, "foreground"));
41158
41152
  this.path.render(context);
41159
41153
  this.renderNewShape(context);
41160
41154
  if (this.getLinkTo()) {
@@ -42817,8 +42811,9 @@ class Drawing extends BaseItem {
42817
42811
  lines = [];
42818
42812
  linkTo;
42819
42813
  strokeWidth = 1;
42820
- borderColor = fixedColor(conf.PEN_DEFAULT_COLOR);
42814
+ borderColor = semanticColor("contrastNeutral");
42821
42815
  borderStyle = "solid";
42816
+ colorRole = "foreground";
42822
42817
  linePattern = scalePatterns(this.strokeWidth)[this.borderStyle];
42823
42818
  borderOpacity = 1;
42824
42819
  transformationRenderBlock = undefined;
@@ -42852,6 +42847,7 @@ class Drawing extends BaseItem {
42852
42847
  transformation: this.transformation.serialize(),
42853
42848
  strokeStyle: this.borderColor,
42854
42849
  strokeWidth: this.strokeWidth,
42850
+ colorRole: this.colorRole,
42855
42851
  linkTo: this.linkTo.serialize()
42856
42852
  };
42857
42853
  }
@@ -42865,6 +42861,9 @@ class Drawing extends BaseItem {
42865
42861
  this.transformation.deserialize(data.transformation);
42866
42862
  this.borderColor = coerceColorValue(data.strokeStyle);
42867
42863
  this.strokeWidth = data.strokeWidth;
42864
+ if (data.colorRole) {
42865
+ this.colorRole = data.colorRole;
42866
+ }
42868
42867
  this.updateGeometry();
42869
42868
  return this;
42870
42869
  }
@@ -42971,7 +42970,8 @@ class Drawing extends BaseItem {
42971
42970
  }
42972
42971
  const ctx = context.ctx;
42973
42972
  ctx.save();
42974
- ctx.strokeStyle = resolveColor(this.borderColor, conf.theme, "foreground");
42973
+ ctx.strokeStyle = resolveColor(this.borderColor, conf.theme, this.colorRole);
42974
+ ctx.globalAlpha = this.borderOpacity;
42975
42975
  ctx.lineWidth = this.strokeWidth;
42976
42976
  ctx.lineCap = "round";
42977
42977
  ctx.setLineDash(this.linePattern);
@@ -42998,7 +42998,8 @@ class Drawing extends BaseItem {
42998
42998
  svg3.setAttribute("style", "position: absolute; overflow: visible;");
42999
42999
  const pathElement = documentFactory.createElementNS("http://www.w3.org/2000/svg", "path");
43000
43000
  pathElement.setAttribute("d", this.getPathData());
43001
- pathElement.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, "foreground"));
43001
+ pathElement.setAttribute("stroke", resolveColor(this.borderColor, conf.theme, this.colorRole));
43002
+ pathElement.setAttribute("stroke-opacity", `${this.borderOpacity}`);
43002
43003
  pathElement.setAttribute("stroke-width", `${this.strokeWidth}`);
43003
43004
  pathElement.setAttribute("fill", "none");
43004
43005
  svg3.appendChild(pathElement);
@@ -43154,6 +43155,13 @@ class Drawing extends BaseItem {
43154
43155
  getStrokeColor() {
43155
43156
  return this.borderColor;
43156
43157
  }
43158
+ setColorRole(role) {
43159
+ this.colorRole = role;
43160
+ return this;
43161
+ }
43162
+ getColorRole() {
43163
+ return this.colorRole;
43164
+ }
43157
43165
  setStrokeWidth(width2) {
43158
43166
  this.emit({
43159
43167
  class: "Drawing",
@@ -44139,7 +44147,7 @@ class AddDrawing extends BoardTool {
44139
44147
  drawing = null;
44140
44148
  isDown = false;
44141
44149
  strokeWidth = conf.PEN_INITIAL_STROKE_WIDTH;
44142
- strokeColor = conf.PEN_DEFAULT_COLOR;
44150
+ strokeColor = semanticColor("contrastNeutral");
44143
44151
  strokeStyle = conf.PEN_STROKE_STYLE;
44144
44152
  constructor(board) {
44145
44153
  super(board);
@@ -44194,6 +44202,9 @@ class AddDrawing extends BoardTool {
44194
44202
  isHighlighter() {
44195
44203
  return false;
44196
44204
  }
44205
+ applyDrawingRole(drawing) {
44206
+ drawing.setColorRole("foreground");
44207
+ }
44197
44208
  leftButtonDown() {
44198
44209
  if (this.strokeColor === "none") {
44199
44210
  return false;
@@ -44233,9 +44244,10 @@ class AddDrawing extends BoardTool {
44233
44244
  }
44234
44245
  const drawing = new Drawing(this.board, points);
44235
44246
  drawing.transformation.translateTo(x, y);
44236
- drawing.setStrokeColor(this.strokeColor);
44247
+ drawing.setStrokeColor(coerceColorValue(this.strokeColor));
44237
44248
  drawing.setStrokeWidth(this.strokeWidth);
44238
44249
  drawing.setBorderStyle(this.strokeStyle);
44250
+ this.applyDrawingRole(drawing);
44239
44251
  this.board.add(drawing).updateMbr();
44240
44252
  this.board.selection.removeAll();
44241
44253
  this.drawing = null;
@@ -44274,16 +44286,17 @@ class AddDrawing extends BoardTool {
44274
44286
  return;
44275
44287
  }
44276
44288
  const drawing = this.drawing;
44277
- drawing.setStrokeColor(this.strokeColor);
44289
+ drawing.setStrokeColor(coerceColorValue(this.strokeColor));
44278
44290
  drawing.setStrokeWidth(this.strokeWidth);
44279
44291
  drawing.setBorderStyle(this.strokeStyle);
44292
+ this.applyDrawingRole(drawing);
44280
44293
  drawing.render(context);
44281
44294
  }
44282
44295
  }
44283
44296
  // src/Tools/AddDrawing/AddHighlighter.ts
44284
44297
  class AddHighlighter extends AddDrawing {
44285
44298
  strokeWidth = conf.HIGHLIGHTER_INITIAL_STROKE_WIDTH;
44286
- strokeColor = conf.HIGHLIGHTER_DEFAULT_COLOR;
44299
+ strokeColor = semanticColor("contrastGreen");
44287
44300
  strokeStyle = conf.PEN_STROKE_STYLE;
44288
44301
  constructor(board) {
44289
44302
  super(board);
@@ -44301,6 +44314,10 @@ class AddHighlighter extends AddDrawing {
44301
44314
  isHighlighter() {
44302
44315
  return true;
44303
44316
  }
44317
+ applyDrawingRole(drawing) {
44318
+ drawing.setColorRole("background");
44319
+ drawing.setStrokeOpacity(0.5);
44320
+ }
44304
44321
  updateSettings() {
44305
44322
  localStorage.setItem(conf.HIGHLIGHTER_SETTINGS_KEY, JSON.stringify({
44306
44323
  strokeWidth: this.strokeWidth,
@@ -44720,7 +44737,8 @@ class AddSticker extends BoardTool {
44720
44737
  }
44721
44738
  setCursor(color2) {
44722
44739
  if (conf.STICKER_COLOR_NAMES) {
44723
- const colorName = color2 ? conf.STICKER_COLOR_NAMES[conf.STICKER_COLORS.indexOf(color2)] : undefined;
44740
+ const cssColor = color2 ? resolveColor(color2, conf.theme, "background") : undefined;
44741
+ const colorName = cssColor ? conf.STICKER_COLOR_NAMES[conf.STICKER_COLORS.indexOf(cssColor)] : undefined;
44724
44742
  this.board.pointer.setCursor(colorName ? `sticker-${colorName}` : "crosshair");
44725
44743
  } else {
44726
44744
  this.board.pointer.setCursor("crosshair");
@@ -44731,7 +44749,7 @@ class AddSticker extends BoardTool {
44731
44749
  class: "Sticker",
44732
44750
  method: "setBackgroundColor",
44733
44751
  item: [this.sticker.getId()],
44734
- backgroundColor: color2
44752
+ backgroundColor: coerceColorValue(color2)
44735
44753
  });
44736
44754
  this.setCursor(color2);
44737
44755
  this.board.tools.publish();