microboard-temp 0.4.108 → 0.5.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.
@@ -626,6 +626,7 @@ var require_escape_html = __commonJS((exports2, module2) => {
626
626
  // src/browser.ts
627
627
  var exports_browser = {};
628
628
  __export(exports_browser, {
629
+ viewModeHotkeyRegistry: () => viewModeHotkeyRegistry,
629
630
  validateRichTextData: () => validateRichTextData,
630
631
  validateItemsMap: () => validateItemsMap,
631
632
  uploadVideoToStorage: () => uploadVideoToStorage,
@@ -665,6 +666,7 @@ __export(exports_browser, {
665
666
  isFiniteNumber: () => isFiniteNumber,
666
667
  isControlCharacter: () => isControlCharacter,
667
668
  initI18N: () => initI18N,
669
+ hotkeyNames: () => hotkeyNames,
668
670
  getYouTubeVideoPreview: () => getYouTubeVideoPreview,
669
671
  getYouTubeThumbnail: () => getYouTubeThumbnail,
670
672
  getVideoMetadata: () => getVideoMetadata,
@@ -679,6 +681,7 @@ __export(exports_browser, {
679
681
  forceNumberIntoInterval: () => forceNumberIntoInterval,
680
682
  fileTosha256: () => fileTosha256,
681
683
  exportBoardSnapshot: () => exportBoardSnapshot,
684
+ editModeHotkeyRegistry: () => editModeHotkeyRegistry,
682
685
  decodeHtml: () => decodeHtml,
683
686
  cursors: () => defaultCursors,
684
687
  createVideoItem: () => createVideoItem,
@@ -47824,6 +47827,19 @@ function throttle(func, delay) {
47824
47827
  };
47825
47828
  }
47826
47829
 
47830
+ // src/Keyboard/HotkeyRegistry.ts
47831
+ var editModeHotkeyRegistry = {};
47832
+ var viewModeHotkeyRegistry = {};
47833
+ var hotkeyNames = {};
47834
+ function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
47835
+ if (boardMode === "edit") {
47836
+ editModeHotkeyRegistry[name] = hotkeyConfig;
47837
+ } else {
47838
+ viewModeHotkeyRegistry[name] = hotkeyConfig;
47839
+ }
47840
+ hotkeyNames[name] = hotkey;
47841
+ }
47842
+
47827
47843
  // src/Items/Examples/CardGame/Card/Card.ts
47828
47844
  var defaultCardData = {
47829
47845
  itemType: "Card",
@@ -47940,6 +47956,23 @@ registerItem({
47940
47956
  item: Card,
47941
47957
  defaultData: defaultCardData
47942
47958
  });
47959
+ registerHotkey({
47960
+ name: "flipCard",
47961
+ hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
47962
+ boardMode: "edit",
47963
+ hotkeyConfig: {
47964
+ allItemsType: ["Card"],
47965
+ cb: (event, board) => {
47966
+ const cards = board?.selection.items.list();
47967
+ if (!cards) {
47968
+ return;
47969
+ }
47970
+ cards.forEach((card) => {
47971
+ card.toggleIsOpen();
47972
+ });
47973
+ }
47974
+ }
47975
+ });
47943
47976
  // src/Items/Examples/CardGame/Deck/Deck.ts
47944
47977
  var defaultDeckData = {
47945
47978
  itemType: "Deck"
@@ -49370,10 +49403,11 @@ var hotkeys_default = {
49370
49403
 
49371
49404
  // src/Keyboard/isHotkeyPushed.ts
49372
49405
  function isHotkeyPushed(hotkey, event) {
49373
- if (!hotkeys_default[hotkey]) {
49406
+ const hotkeys = { ...hotkeys_default, ...hotkeyNames };
49407
+ if (!hotkeys[hotkey]) {
49374
49408
  return false;
49375
49409
  }
49376
- const { key } = hotkeys_default[hotkey];
49410
+ const { key } = hotkeys[hotkey];
49377
49411
  const isControlPushed = event.ctrlKey || event.metaKey;
49378
49412
  const isShiftPushed = event.shiftKey;
49379
49413
  const isAltPushed = event.altKey;
@@ -49753,13 +49787,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
49753
49787
 
49754
49788
  // src/Keyboard/checkHotkeys.ts
49755
49789
  function checkHotkeys(hotkeyMap, event, board) {
49756
- const entries = Object.entries(hotkeyMap);
49790
+ const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
49791
+ const entries = Object.entries(fullHotkeysMap);
49757
49792
  for (const [hotkey, configOrCb] of entries) {
49758
49793
  if (isHotkeyPushed(hotkey, event)) {
49759
49794
  const context = board.selection.getContext();
49760
49795
  if (typeof configOrCb === "function") {
49761
49796
  event.preventDefault();
49762
- configOrCb(event);
49797
+ configOrCb(event, board);
49763
49798
  logHotkey(configOrCb, hotkey, "triggered", context);
49764
49799
  return true;
49765
49800
  }
@@ -49786,7 +49821,7 @@ function checkHotkeys(hotkeyMap, event, board) {
49786
49821
  if (preventDefault) {
49787
49822
  event.preventDefault();
49788
49823
  }
49789
- cb(event);
49824
+ cb(event, board);
49790
49825
  logHotkey(configOrCb, hotkey, "triggered", context);
49791
49826
  return true;
49792
49827
  }
package/dist/cjs/index.js CHANGED
@@ -626,6 +626,7 @@ var require_escape_html = __commonJS((exports2, module2) => {
626
626
  // src/index.ts
627
627
  var exports_src = {};
628
628
  __export(exports_src, {
629
+ viewModeHotkeyRegistry: () => viewModeHotkeyRegistry,
629
630
  validateRichTextData: () => validateRichTextData,
630
631
  validateItemsMap: () => validateItemsMap,
631
632
  uploadVideoToStorage: () => uploadVideoToStorage,
@@ -665,6 +666,7 @@ __export(exports_src, {
665
666
  isFiniteNumber: () => isFiniteNumber,
666
667
  isControlCharacter: () => isControlCharacter,
667
668
  initI18N: () => initI18N,
669
+ hotkeyNames: () => hotkeyNames,
668
670
  getYouTubeVideoPreview: () => getYouTubeVideoPreview,
669
671
  getYouTubeThumbnail: () => getYouTubeThumbnail,
670
672
  getVideoMetadata: () => getVideoMetadata,
@@ -679,6 +681,7 @@ __export(exports_src, {
679
681
  forceNumberIntoInterval: () => forceNumberIntoInterval,
680
682
  fileTosha256: () => fileTosha256,
681
683
  exportBoardSnapshot: () => exportBoardSnapshot,
684
+ editModeHotkeyRegistry: () => editModeHotkeyRegistry,
682
685
  decodeHtml: () => decodeHtml,
683
686
  cursors: () => defaultCursors,
684
687
  createVideoItem: () => createVideoItem,
@@ -47824,6 +47827,19 @@ function throttle(func, delay) {
47824
47827
  };
47825
47828
  }
47826
47829
 
47830
+ // src/Keyboard/HotkeyRegistry.ts
47831
+ var editModeHotkeyRegistry = {};
47832
+ var viewModeHotkeyRegistry = {};
47833
+ var hotkeyNames = {};
47834
+ function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
47835
+ if (boardMode === "edit") {
47836
+ editModeHotkeyRegistry[name] = hotkeyConfig;
47837
+ } else {
47838
+ viewModeHotkeyRegistry[name] = hotkeyConfig;
47839
+ }
47840
+ hotkeyNames[name] = hotkey;
47841
+ }
47842
+
47827
47843
  // src/Items/Examples/CardGame/Card/Card.ts
47828
47844
  var defaultCardData = {
47829
47845
  itemType: "Card",
@@ -47940,6 +47956,23 @@ registerItem({
47940
47956
  item: Card,
47941
47957
  defaultData: defaultCardData
47942
47958
  });
47959
+ registerHotkey({
47960
+ name: "flipCard",
47961
+ hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
47962
+ boardMode: "edit",
47963
+ hotkeyConfig: {
47964
+ allItemsType: ["Card"],
47965
+ cb: (event, board) => {
47966
+ const cards = board?.selection.items.list();
47967
+ if (!cards) {
47968
+ return;
47969
+ }
47970
+ cards.forEach((card) => {
47971
+ card.toggleIsOpen();
47972
+ });
47973
+ }
47974
+ }
47975
+ });
47943
47976
  // src/Items/Examples/CardGame/Deck/Deck.ts
47944
47977
  var defaultDeckData = {
47945
47978
  itemType: "Deck"
@@ -49370,10 +49403,11 @@ var hotkeys_default = {
49370
49403
 
49371
49404
  // src/Keyboard/isHotkeyPushed.ts
49372
49405
  function isHotkeyPushed(hotkey, event) {
49373
- if (!hotkeys_default[hotkey]) {
49406
+ const hotkeys = { ...hotkeys_default, ...hotkeyNames };
49407
+ if (!hotkeys[hotkey]) {
49374
49408
  return false;
49375
49409
  }
49376
- const { key } = hotkeys_default[hotkey];
49410
+ const { key } = hotkeys[hotkey];
49377
49411
  const isControlPushed = event.ctrlKey || event.metaKey;
49378
49412
  const isShiftPushed = event.shiftKey;
49379
49413
  const isAltPushed = event.altKey;
@@ -49753,13 +49787,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
49753
49787
 
49754
49788
  // src/Keyboard/checkHotkeys.ts
49755
49789
  function checkHotkeys(hotkeyMap, event, board) {
49756
- const entries = Object.entries(hotkeyMap);
49790
+ const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
49791
+ const entries = Object.entries(fullHotkeysMap);
49757
49792
  for (const [hotkey, configOrCb] of entries) {
49758
49793
  if (isHotkeyPushed(hotkey, event)) {
49759
49794
  const context = board.selection.getContext();
49760
49795
  if (typeof configOrCb === "function") {
49761
49796
  event.preventDefault();
49762
- configOrCb(event);
49797
+ configOrCb(event, board);
49763
49798
  logHotkey(configOrCb, hotkey, "triggered", context);
49764
49799
  return true;
49765
49800
  }
@@ -49786,7 +49821,7 @@ function checkHotkeys(hotkeyMap, event, board) {
49786
49821
  if (preventDefault) {
49787
49822
  event.preventDefault();
49788
49823
  }
49789
- cb(event);
49824
+ cb(event, board);
49790
49825
  logHotkey(configOrCb, hotkey, "triggered", context);
49791
49826
  return true;
49792
49827
  }
package/dist/cjs/node.js CHANGED
@@ -1663,6 +1663,7 @@ var require_css_escape = __commonJS((exports2, module2) => {
1663
1663
  // src/node.ts
1664
1664
  var exports_node = {};
1665
1665
  __export(exports_node, {
1666
+ viewModeHotkeyRegistry: () => viewModeHotkeyRegistry,
1666
1667
  validateRichTextData: () => validateRichTextData,
1667
1668
  validateItemsMap: () => validateItemsMap,
1668
1669
  uploadVideoToStorage: () => uploadVideoToStorage,
@@ -1702,6 +1703,7 @@ __export(exports_node, {
1702
1703
  isFiniteNumber: () => isFiniteNumber,
1703
1704
  isControlCharacter: () => isControlCharacter,
1704
1705
  initI18N: () => initI18N,
1706
+ hotkeyNames: () => hotkeyNames,
1705
1707
  getYouTubeVideoPreview: () => getYouTubeVideoPreview,
1706
1708
  getYouTubeThumbnail: () => getYouTubeThumbnail,
1707
1709
  getVideoMetadata: () => getVideoMetadata,
@@ -1716,6 +1718,7 @@ __export(exports_node, {
1716
1718
  forceNumberIntoInterval: () => forceNumberIntoInterval,
1717
1719
  fileTosha256: () => fileTosha256,
1718
1720
  exportBoardSnapshot: () => exportBoardSnapshot,
1721
+ editModeHotkeyRegistry: () => editModeHotkeyRegistry,
1719
1722
  decodeHtml: () => decodeHtml,
1720
1723
  cursors: () => defaultCursors,
1721
1724
  createVideoItem: () => createVideoItem,
@@ -50297,6 +50300,19 @@ function throttle(func, delay) {
50297
50300
  };
50298
50301
  }
50299
50302
 
50303
+ // src/Keyboard/HotkeyRegistry.ts
50304
+ var editModeHotkeyRegistry = {};
50305
+ var viewModeHotkeyRegistry = {};
50306
+ var hotkeyNames = {};
50307
+ function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
50308
+ if (boardMode === "edit") {
50309
+ editModeHotkeyRegistry[name] = hotkeyConfig;
50310
+ } else {
50311
+ viewModeHotkeyRegistry[name] = hotkeyConfig;
50312
+ }
50313
+ hotkeyNames[name] = hotkey;
50314
+ }
50315
+
50300
50316
  // src/Items/Examples/CardGame/Card/Card.ts
50301
50317
  var defaultCardData = {
50302
50318
  itemType: "Card",
@@ -50413,6 +50429,23 @@ registerItem({
50413
50429
  item: Card,
50414
50430
  defaultData: defaultCardData
50415
50431
  });
50432
+ registerHotkey({
50433
+ name: "flipCard",
50434
+ hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
50435
+ boardMode: "edit",
50436
+ hotkeyConfig: {
50437
+ allItemsType: ["Card"],
50438
+ cb: (event, board) => {
50439
+ const cards = board?.selection.items.list();
50440
+ if (!cards) {
50441
+ return;
50442
+ }
50443
+ cards.forEach((card) => {
50444
+ card.toggleIsOpen();
50445
+ });
50446
+ }
50447
+ }
50448
+ });
50416
50449
  // src/Items/Examples/CardGame/Deck/Deck.ts
50417
50450
  var defaultDeckData = {
50418
50451
  itemType: "Deck"
@@ -51843,10 +51876,11 @@ var hotkeys_default = {
51843
51876
 
51844
51877
  // src/Keyboard/isHotkeyPushed.ts
51845
51878
  function isHotkeyPushed(hotkey, event) {
51846
- if (!hotkeys_default[hotkey]) {
51879
+ const hotkeys = { ...hotkeys_default, ...hotkeyNames };
51880
+ if (!hotkeys[hotkey]) {
51847
51881
  return false;
51848
51882
  }
51849
- const { key } = hotkeys_default[hotkey];
51883
+ const { key } = hotkeys[hotkey];
51850
51884
  const isControlPushed = event.ctrlKey || event.metaKey;
51851
51885
  const isShiftPushed = event.shiftKey;
51852
51886
  const isAltPushed = event.altKey;
@@ -52226,13 +52260,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
52226
52260
 
52227
52261
  // src/Keyboard/checkHotkeys.ts
52228
52262
  function checkHotkeys(hotkeyMap, event, board) {
52229
- const entries = Object.entries(hotkeyMap);
52263
+ const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
52264
+ const entries = Object.entries(fullHotkeysMap);
52230
52265
  for (const [hotkey, configOrCb] of entries) {
52231
52266
  if (isHotkeyPushed(hotkey, event)) {
52232
52267
  const context = board.selection.getContext();
52233
52268
  if (typeof configOrCb === "function") {
52234
52269
  event.preventDefault();
52235
- configOrCb(event);
52270
+ configOrCb(event, board);
52236
52271
  logHotkey(configOrCb, hotkey, "triggered", context);
52237
52272
  return true;
52238
52273
  }
@@ -52259,7 +52294,7 @@ function checkHotkeys(hotkeyMap, event, board) {
52259
52294
  if (preventDefault) {
52260
52295
  event.preventDefault();
52261
52296
  }
52262
- cb(event);
52297
+ cb(event, board);
52263
52298
  logHotkey(configOrCb, hotkey, "triggered", context);
52264
52299
  return true;
52265
52300
  }
@@ -47673,6 +47673,19 @@ function throttle(func, delay) {
47673
47673
  };
47674
47674
  }
47675
47675
 
47676
+ // src/Keyboard/HotkeyRegistry.ts
47677
+ var editModeHotkeyRegistry = {};
47678
+ var viewModeHotkeyRegistry = {};
47679
+ var hotkeyNames = {};
47680
+ function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
47681
+ if (boardMode === "edit") {
47682
+ editModeHotkeyRegistry[name] = hotkeyConfig;
47683
+ } else {
47684
+ viewModeHotkeyRegistry[name] = hotkeyConfig;
47685
+ }
47686
+ hotkeyNames[name] = hotkey;
47687
+ }
47688
+
47676
47689
  // src/Items/Examples/CardGame/Card/Card.ts
47677
47690
  var defaultCardData = {
47678
47691
  itemType: "Card",
@@ -47789,6 +47802,23 @@ registerItem({
47789
47802
  item: Card,
47790
47803
  defaultData: defaultCardData
47791
47804
  });
47805
+ registerHotkey({
47806
+ name: "flipCard",
47807
+ hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
47808
+ boardMode: "edit",
47809
+ hotkeyConfig: {
47810
+ allItemsType: ["Card"],
47811
+ cb: (event, board) => {
47812
+ const cards = board?.selection.items.list();
47813
+ if (!cards) {
47814
+ return;
47815
+ }
47816
+ cards.forEach((card) => {
47817
+ card.toggleIsOpen();
47818
+ });
47819
+ }
47820
+ }
47821
+ });
47792
47822
  // src/Items/Examples/CardGame/Deck/Deck.ts
47793
47823
  var defaultDeckData = {
47794
47824
  itemType: "Deck"
@@ -49219,10 +49249,11 @@ var hotkeys_default = {
49219
49249
 
49220
49250
  // src/Keyboard/isHotkeyPushed.ts
49221
49251
  function isHotkeyPushed(hotkey, event) {
49222
- if (!hotkeys_default[hotkey]) {
49252
+ const hotkeys = { ...hotkeys_default, ...hotkeyNames };
49253
+ if (!hotkeys[hotkey]) {
49223
49254
  return false;
49224
49255
  }
49225
- const { key } = hotkeys_default[hotkey];
49256
+ const { key } = hotkeys[hotkey];
49226
49257
  const isControlPushed = event.ctrlKey || event.metaKey;
49227
49258
  const isShiftPushed = event.shiftKey;
49228
49259
  const isAltPushed = event.altKey;
@@ -49602,13 +49633,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
49602
49633
 
49603
49634
  // src/Keyboard/checkHotkeys.ts
49604
49635
  function checkHotkeys(hotkeyMap, event, board) {
49605
- const entries = Object.entries(hotkeyMap);
49636
+ const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
49637
+ const entries = Object.entries(fullHotkeysMap);
49606
49638
  for (const [hotkey, configOrCb] of entries) {
49607
49639
  if (isHotkeyPushed(hotkey, event)) {
49608
49640
  const context = board.selection.getContext();
49609
49641
  if (typeof configOrCb === "function") {
49610
49642
  event.preventDefault();
49611
- configOrCb(event);
49643
+ configOrCb(event, board);
49612
49644
  logHotkey(configOrCb, hotkey, "triggered", context);
49613
49645
  return true;
49614
49646
  }
@@ -49635,7 +49667,7 @@ function checkHotkeys(hotkeyMap, event, board) {
49635
49667
  if (preventDefault) {
49636
49668
  event.preventDefault();
49637
49669
  }
49638
- cb(event);
49670
+ cb(event, board);
49639
49671
  logHotkey(configOrCb, hotkey, "triggered", context);
49640
49672
  return true;
49641
49673
  }
@@ -56401,6 +56433,7 @@ function initBrowserSettings() {
56401
56433
  // src/browser.ts
56402
56434
  initBrowserSettings();
56403
56435
  export {
56436
+ viewModeHotkeyRegistry,
56404
56437
  validateRichTextData,
56405
56438
  validateItemsMap,
56406
56439
  uploadVideoToStorage,
@@ -56440,6 +56473,7 @@ export {
56440
56473
  isFiniteNumber,
56441
56474
  isControlCharacter,
56442
56475
  initI18N,
56476
+ hotkeyNames,
56443
56477
  getYouTubeVideoPreview,
56444
56478
  getYouTubeThumbnail,
56445
56479
  getVideoMetadata,
@@ -56454,6 +56488,7 @@ export {
56454
56488
  forceNumberIntoInterval,
56455
56489
  fileTosha256,
56456
56490
  exportBoardSnapshot,
56491
+ editModeHotkeyRegistry,
56457
56492
  decodeHtml,
56458
56493
  defaultCursors as cursors,
56459
56494
  createVideoItem,
package/dist/esm/index.js CHANGED
@@ -47666,6 +47666,19 @@ function throttle(func, delay) {
47666
47666
  };
47667
47667
  }
47668
47668
 
47669
+ // src/Keyboard/HotkeyRegistry.ts
47670
+ var editModeHotkeyRegistry = {};
47671
+ var viewModeHotkeyRegistry = {};
47672
+ var hotkeyNames = {};
47673
+ function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
47674
+ if (boardMode === "edit") {
47675
+ editModeHotkeyRegistry[name] = hotkeyConfig;
47676
+ } else {
47677
+ viewModeHotkeyRegistry[name] = hotkeyConfig;
47678
+ }
47679
+ hotkeyNames[name] = hotkey;
47680
+ }
47681
+
47669
47682
  // src/Items/Examples/CardGame/Card/Card.ts
47670
47683
  var defaultCardData = {
47671
47684
  itemType: "Card",
@@ -47782,6 +47795,23 @@ registerItem({
47782
47795
  item: Card,
47783
47796
  defaultData: defaultCardData
47784
47797
  });
47798
+ registerHotkey({
47799
+ name: "flipCard",
47800
+ hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
47801
+ boardMode: "edit",
47802
+ hotkeyConfig: {
47803
+ allItemsType: ["Card"],
47804
+ cb: (event, board) => {
47805
+ const cards = board?.selection.items.list();
47806
+ if (!cards) {
47807
+ return;
47808
+ }
47809
+ cards.forEach((card) => {
47810
+ card.toggleIsOpen();
47811
+ });
47812
+ }
47813
+ }
47814
+ });
47785
47815
  // src/Items/Examples/CardGame/Deck/Deck.ts
47786
47816
  var defaultDeckData = {
47787
47817
  itemType: "Deck"
@@ -49212,10 +49242,11 @@ var hotkeys_default = {
49212
49242
 
49213
49243
  // src/Keyboard/isHotkeyPushed.ts
49214
49244
  function isHotkeyPushed(hotkey, event) {
49215
- if (!hotkeys_default[hotkey]) {
49245
+ const hotkeys = { ...hotkeys_default, ...hotkeyNames };
49246
+ if (!hotkeys[hotkey]) {
49216
49247
  return false;
49217
49248
  }
49218
- const { key } = hotkeys_default[hotkey];
49249
+ const { key } = hotkeys[hotkey];
49219
49250
  const isControlPushed = event.ctrlKey || event.metaKey;
49220
49251
  const isShiftPushed = event.shiftKey;
49221
49252
  const isAltPushed = event.altKey;
@@ -49595,13 +49626,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
49595
49626
 
49596
49627
  // src/Keyboard/checkHotkeys.ts
49597
49628
  function checkHotkeys(hotkeyMap, event, board) {
49598
- const entries = Object.entries(hotkeyMap);
49629
+ const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
49630
+ const entries = Object.entries(fullHotkeysMap);
49599
49631
  for (const [hotkey, configOrCb] of entries) {
49600
49632
  if (isHotkeyPushed(hotkey, event)) {
49601
49633
  const context = board.selection.getContext();
49602
49634
  if (typeof configOrCb === "function") {
49603
49635
  event.preventDefault();
49604
- configOrCb(event);
49636
+ configOrCb(event, board);
49605
49637
  logHotkey(configOrCb, hotkey, "triggered", context);
49606
49638
  return true;
49607
49639
  }
@@ -49628,7 +49660,7 @@ function checkHotkeys(hotkeyMap, event, board) {
49628
49660
  if (preventDefault) {
49629
49661
  event.preventDefault();
49630
49662
  }
49631
- cb(event);
49663
+ cb(event, board);
49632
49664
  logHotkey(configOrCb, hotkey, "triggered", context);
49633
49665
  return true;
49634
49666
  }
@@ -56299,6 +56331,7 @@ function initI18N(i18nInstance) {
56299
56331
  return i18nInstance;
56300
56332
  }
56301
56333
  export {
56334
+ viewModeHotkeyRegistry,
56302
56335
  validateRichTextData,
56303
56336
  validateItemsMap,
56304
56337
  uploadVideoToStorage,
@@ -56338,6 +56371,7 @@ export {
56338
56371
  isFiniteNumber,
56339
56372
  isControlCharacter,
56340
56373
  initI18N,
56374
+ hotkeyNames,
56341
56375
  getYouTubeVideoPreview,
56342
56376
  getYouTubeThumbnail,
56343
56377
  getVideoMetadata,
@@ -56352,6 +56386,7 @@ export {
56352
56386
  forceNumberIntoInterval,
56353
56387
  fileTosha256,
56354
56388
  exportBoardSnapshot,
56389
+ editModeHotkeyRegistry,
56355
56390
  decodeHtml,
56356
56391
  defaultCursors as cursors,
56357
56392
  createVideoItem,
package/dist/esm/node.js CHANGED
@@ -50134,6 +50134,19 @@ function throttle(func, delay) {
50134
50134
  };
50135
50135
  }
50136
50136
 
50137
+ // src/Keyboard/HotkeyRegistry.ts
50138
+ var editModeHotkeyRegistry = {};
50139
+ var viewModeHotkeyRegistry = {};
50140
+ var hotkeyNames = {};
50141
+ function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
50142
+ if (boardMode === "edit") {
50143
+ editModeHotkeyRegistry[name] = hotkeyConfig;
50144
+ } else {
50145
+ viewModeHotkeyRegistry[name] = hotkeyConfig;
50146
+ }
50147
+ hotkeyNames[name] = hotkey;
50148
+ }
50149
+
50137
50150
  // src/Items/Examples/CardGame/Card/Card.ts
50138
50151
  var defaultCardData = {
50139
50152
  itemType: "Card",
@@ -50250,6 +50263,23 @@ registerItem({
50250
50263
  item: Card,
50251
50264
  defaultData: defaultCardData
50252
50265
  });
50266
+ registerHotkey({
50267
+ name: "flipCard",
50268
+ hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
50269
+ boardMode: "edit",
50270
+ hotkeyConfig: {
50271
+ allItemsType: ["Card"],
50272
+ cb: (event, board) => {
50273
+ const cards = board?.selection.items.list();
50274
+ if (!cards) {
50275
+ return;
50276
+ }
50277
+ cards.forEach((card) => {
50278
+ card.toggleIsOpen();
50279
+ });
50280
+ }
50281
+ }
50282
+ });
50253
50283
  // src/Items/Examples/CardGame/Deck/Deck.ts
50254
50284
  var defaultDeckData = {
50255
50285
  itemType: "Deck"
@@ -51680,10 +51710,11 @@ var hotkeys_default = {
51680
51710
 
51681
51711
  // src/Keyboard/isHotkeyPushed.ts
51682
51712
  function isHotkeyPushed(hotkey, event) {
51683
- if (!hotkeys_default[hotkey]) {
51713
+ const hotkeys = { ...hotkeys_default, ...hotkeyNames };
51714
+ if (!hotkeys[hotkey]) {
51684
51715
  return false;
51685
51716
  }
51686
- const { key } = hotkeys_default[hotkey];
51717
+ const { key } = hotkeys[hotkey];
51687
51718
  const isControlPushed = event.ctrlKey || event.metaKey;
51688
51719
  const isShiftPushed = event.shiftKey;
51689
51720
  const isAltPushed = event.altKey;
@@ -52063,13 +52094,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
52063
52094
 
52064
52095
  // src/Keyboard/checkHotkeys.ts
52065
52096
  function checkHotkeys(hotkeyMap, event, board) {
52066
- const entries = Object.entries(hotkeyMap);
52097
+ const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
52098
+ const entries = Object.entries(fullHotkeysMap);
52067
52099
  for (const [hotkey, configOrCb] of entries) {
52068
52100
  if (isHotkeyPushed(hotkey, event)) {
52069
52101
  const context = board.selection.getContext();
52070
52102
  if (typeof configOrCb === "function") {
52071
52103
  event.preventDefault();
52072
- configOrCb(event);
52104
+ configOrCb(event, board);
52073
52105
  logHotkey(configOrCb, hotkey, "triggered", context);
52074
52106
  return true;
52075
52107
  }
@@ -52096,7 +52128,7 @@ function checkHotkeys(hotkeyMap, event, board) {
52096
52128
  if (preventDefault) {
52097
52129
  event.preventDefault();
52098
52130
  }
52099
- cb(event);
52131
+ cb(event, board);
52100
52132
  logHotkey(configOrCb, hotkey, "triggered", context);
52101
52133
  return true;
52102
52134
  }
@@ -58934,6 +58966,7 @@ function initNodeSettings() {
58934
58966
  // src/node.ts
58935
58967
  initNodeSettings();
58936
58968
  export {
58969
+ viewModeHotkeyRegistry,
58937
58970
  validateRichTextData,
58938
58971
  validateItemsMap,
58939
58972
  uploadVideoToStorage,
@@ -58973,6 +59006,7 @@ export {
58973
59006
  isFiniteNumber,
58974
59007
  isControlCharacter,
58975
59008
  initI18N,
59009
+ hotkeyNames,
58976
59010
  getYouTubeVideoPreview,
58977
59011
  getYouTubeThumbnail,
58978
59012
  getVideoMetadata,
@@ -58987,6 +59021,7 @@ export {
58987
59021
  forceNumberIntoInterval,
58988
59022
  fileTosha256,
58989
59023
  exportBoardSnapshot,
59024
+ editModeHotkeyRegistry,
58990
59025
  decodeHtml,
58991
59026
  defaultCursors as cursors,
58992
59027
  createVideoItem,
@@ -0,0 +1,13 @@
1
+ import { type Hotkey, HotkeyConfig, HotkeysMap } from "./types";
2
+ import { Board } from "../Board";
3
+ export declare const editModeHotkeyRegistry: HotkeysMap;
4
+ export declare const viewModeHotkeyRegistry: HotkeysMap;
5
+ export declare const hotkeyNames: Record<string, Hotkey>;
6
+ type RegisterHotkeyArgs = {
7
+ name: string;
8
+ hotkey: Hotkey;
9
+ hotkeyConfig: HotkeyConfig | ((event?: KeyboardEvent, board?: Board) => void);
10
+ boardMode: "view" | "edit";
11
+ };
12
+ export declare function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }: RegisterHotkeyArgs): void;
13
+ export {};
@@ -14,4 +14,5 @@ export { isHotkeyPushed } from "./isHotkeyPushed";
14
14
  export * from "./checkHotkeys";
15
15
  export { getHotkeyLabel } from "./getHotkeyLabel";
16
16
  export { isControlCharacter } from "./isControlCharacter";
17
+ export { editModeHotkeyRegistry, viewModeHotkeyRegistry, hotkeyNames } from "./HotkeyRegistry";
17
18
  export type { HotkeysMap } from "./types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.4.108",
3
+ "version": "0.5.0",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",