microboard-temp 0.4.108 → 0.5.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.
- package/dist/cjs/browser.js +76 -13
- package/dist/cjs/index.js +76 -13
- package/dist/cjs/node.js +76 -13
- package/dist/esm/browser.js +76 -13
- package/dist/esm/index.js +76 -13
- package/dist/esm/node.js +76 -13
- package/dist/types/Items/BaseItem/BaseItem.d.ts +1 -0
- package/dist/types/Items/Examples/CardGame/Card/Card.d.ts +1 -1
- package/dist/types/Keyboard/HotkeyRegistry.d.ts +13 -0
- package/dist/types/Keyboard/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -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,
|
|
@@ -21666,6 +21669,14 @@ class BaseItem extends Mbr {
|
|
|
21666
21669
|
this.apply(operation);
|
|
21667
21670
|
}
|
|
21668
21671
|
}
|
|
21672
|
+
emitForManyItems(operation) {
|
|
21673
|
+
if (!this.board.events) {
|
|
21674
|
+
return;
|
|
21675
|
+
}
|
|
21676
|
+
const command = createCommand(this.board, operation);
|
|
21677
|
+
command.apply();
|
|
21678
|
+
this.board.events.emit(operation, command);
|
|
21679
|
+
}
|
|
21669
21680
|
apply(op) {
|
|
21670
21681
|
op = op;
|
|
21671
21682
|
switch (op.class) {
|
|
@@ -47824,6 +47835,19 @@ function throttle(func, delay) {
|
|
|
47824
47835
|
};
|
|
47825
47836
|
}
|
|
47826
47837
|
|
|
47838
|
+
// src/Keyboard/HotkeyRegistry.ts
|
|
47839
|
+
var editModeHotkeyRegistry = {};
|
|
47840
|
+
var viewModeHotkeyRegistry = {};
|
|
47841
|
+
var hotkeyNames = {};
|
|
47842
|
+
function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
|
|
47843
|
+
if (boardMode === "edit") {
|
|
47844
|
+
editModeHotkeyRegistry[name] = hotkeyConfig;
|
|
47845
|
+
} else {
|
|
47846
|
+
viewModeHotkeyRegistry[name] = hotkeyConfig;
|
|
47847
|
+
}
|
|
47848
|
+
hotkeyNames[name] = hotkey;
|
|
47849
|
+
}
|
|
47850
|
+
|
|
47827
47851
|
// src/Items/Examples/CardGame/Card/Card.ts
|
|
47828
47852
|
var defaultCardData = {
|
|
47829
47853
|
itemType: "Card",
|
|
@@ -47912,14 +47936,34 @@ class Card extends BaseItem {
|
|
|
47912
47936
|
this.subject.publish(this);
|
|
47913
47937
|
return this;
|
|
47914
47938
|
}
|
|
47915
|
-
toggleIsOpen() {
|
|
47916
|
-
|
|
47917
|
-
|
|
47918
|
-
|
|
47919
|
-
|
|
47920
|
-
|
|
47921
|
-
|
|
47922
|
-
|
|
47939
|
+
toggleIsOpen(cards) {
|
|
47940
|
+
const openedCardIds = [];
|
|
47941
|
+
const closedCardIds = [];
|
|
47942
|
+
for (const card of cards) {
|
|
47943
|
+
if (card.isOpen) {
|
|
47944
|
+
openedCardIds.push(card.getId());
|
|
47945
|
+
} else {
|
|
47946
|
+
closedCardIds.push(card.getId());
|
|
47947
|
+
}
|
|
47948
|
+
}
|
|
47949
|
+
if (openedCardIds.length) {
|
|
47950
|
+
this.emitForManyItems({
|
|
47951
|
+
class: "Card",
|
|
47952
|
+
method: "setIsOpen",
|
|
47953
|
+
item: [this.getId()],
|
|
47954
|
+
newData: { isOpen: false },
|
|
47955
|
+
prevData: { isOpen: true }
|
|
47956
|
+
});
|
|
47957
|
+
}
|
|
47958
|
+
if (closedCardIds.length) {
|
|
47959
|
+
this.emitForManyItems({
|
|
47960
|
+
class: "Card",
|
|
47961
|
+
method: "setIsOpen",
|
|
47962
|
+
item: [this.getId()],
|
|
47963
|
+
newData: { isOpen: true },
|
|
47964
|
+
prevData: { isOpen: false }
|
|
47965
|
+
});
|
|
47966
|
+
}
|
|
47923
47967
|
}
|
|
47924
47968
|
apply(op) {
|
|
47925
47969
|
super.apply(op);
|
|
@@ -47940,6 +47984,23 @@ registerItem({
|
|
|
47940
47984
|
item: Card,
|
|
47941
47985
|
defaultData: defaultCardData
|
|
47942
47986
|
});
|
|
47987
|
+
registerHotkey({
|
|
47988
|
+
name: "flipCard",
|
|
47989
|
+
hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
|
|
47990
|
+
boardMode: "edit",
|
|
47991
|
+
hotkeyConfig: {
|
|
47992
|
+
allItemsType: ["Card"],
|
|
47993
|
+
cb: (event, board) => {
|
|
47994
|
+
const cards = board?.selection.items.list();
|
|
47995
|
+
if (!cards) {
|
|
47996
|
+
return;
|
|
47997
|
+
}
|
|
47998
|
+
cards.forEach((card) => {
|
|
47999
|
+
card.toggleIsOpen();
|
|
48000
|
+
});
|
|
48001
|
+
}
|
|
48002
|
+
}
|
|
48003
|
+
});
|
|
47943
48004
|
// src/Items/Examples/CardGame/Deck/Deck.ts
|
|
47944
48005
|
var defaultDeckData = {
|
|
47945
48006
|
itemType: "Deck"
|
|
@@ -49370,10 +49431,11 @@ var hotkeys_default = {
|
|
|
49370
49431
|
|
|
49371
49432
|
// src/Keyboard/isHotkeyPushed.ts
|
|
49372
49433
|
function isHotkeyPushed(hotkey, event) {
|
|
49373
|
-
|
|
49434
|
+
const hotkeys = { ...hotkeys_default, ...hotkeyNames };
|
|
49435
|
+
if (!hotkeys[hotkey]) {
|
|
49374
49436
|
return false;
|
|
49375
49437
|
}
|
|
49376
|
-
const { key } =
|
|
49438
|
+
const { key } = hotkeys[hotkey];
|
|
49377
49439
|
const isControlPushed = event.ctrlKey || event.metaKey;
|
|
49378
49440
|
const isShiftPushed = event.shiftKey;
|
|
49379
49441
|
const isAltPushed = event.altKey;
|
|
@@ -49753,13 +49815,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
|
|
|
49753
49815
|
|
|
49754
49816
|
// src/Keyboard/checkHotkeys.ts
|
|
49755
49817
|
function checkHotkeys(hotkeyMap, event, board) {
|
|
49756
|
-
const
|
|
49818
|
+
const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
|
|
49819
|
+
const entries = Object.entries(fullHotkeysMap);
|
|
49757
49820
|
for (const [hotkey, configOrCb] of entries) {
|
|
49758
49821
|
if (isHotkeyPushed(hotkey, event)) {
|
|
49759
49822
|
const context = board.selection.getContext();
|
|
49760
49823
|
if (typeof configOrCb === "function") {
|
|
49761
49824
|
event.preventDefault();
|
|
49762
|
-
configOrCb(event);
|
|
49825
|
+
configOrCb(event, board);
|
|
49763
49826
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
49764
49827
|
return true;
|
|
49765
49828
|
}
|
|
@@ -49786,7 +49849,7 @@ function checkHotkeys(hotkeyMap, event, board) {
|
|
|
49786
49849
|
if (preventDefault) {
|
|
49787
49850
|
event.preventDefault();
|
|
49788
49851
|
}
|
|
49789
|
-
cb(event);
|
|
49852
|
+
cb(event, board);
|
|
49790
49853
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
49791
49854
|
return true;
|
|
49792
49855
|
}
|
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,
|
|
@@ -21666,6 +21669,14 @@ class BaseItem extends Mbr {
|
|
|
21666
21669
|
this.apply(operation);
|
|
21667
21670
|
}
|
|
21668
21671
|
}
|
|
21672
|
+
emitForManyItems(operation) {
|
|
21673
|
+
if (!this.board.events) {
|
|
21674
|
+
return;
|
|
21675
|
+
}
|
|
21676
|
+
const command = createCommand(this.board, operation);
|
|
21677
|
+
command.apply();
|
|
21678
|
+
this.board.events.emit(operation, command);
|
|
21679
|
+
}
|
|
21669
21680
|
apply(op) {
|
|
21670
21681
|
op = op;
|
|
21671
21682
|
switch (op.class) {
|
|
@@ -47824,6 +47835,19 @@ function throttle(func, delay) {
|
|
|
47824
47835
|
};
|
|
47825
47836
|
}
|
|
47826
47837
|
|
|
47838
|
+
// src/Keyboard/HotkeyRegistry.ts
|
|
47839
|
+
var editModeHotkeyRegistry = {};
|
|
47840
|
+
var viewModeHotkeyRegistry = {};
|
|
47841
|
+
var hotkeyNames = {};
|
|
47842
|
+
function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
|
|
47843
|
+
if (boardMode === "edit") {
|
|
47844
|
+
editModeHotkeyRegistry[name] = hotkeyConfig;
|
|
47845
|
+
} else {
|
|
47846
|
+
viewModeHotkeyRegistry[name] = hotkeyConfig;
|
|
47847
|
+
}
|
|
47848
|
+
hotkeyNames[name] = hotkey;
|
|
47849
|
+
}
|
|
47850
|
+
|
|
47827
47851
|
// src/Items/Examples/CardGame/Card/Card.ts
|
|
47828
47852
|
var defaultCardData = {
|
|
47829
47853
|
itemType: "Card",
|
|
@@ -47912,14 +47936,34 @@ class Card extends BaseItem {
|
|
|
47912
47936
|
this.subject.publish(this);
|
|
47913
47937
|
return this;
|
|
47914
47938
|
}
|
|
47915
|
-
toggleIsOpen() {
|
|
47916
|
-
|
|
47917
|
-
|
|
47918
|
-
|
|
47919
|
-
|
|
47920
|
-
|
|
47921
|
-
|
|
47922
|
-
|
|
47939
|
+
toggleIsOpen(cards) {
|
|
47940
|
+
const openedCardIds = [];
|
|
47941
|
+
const closedCardIds = [];
|
|
47942
|
+
for (const card of cards) {
|
|
47943
|
+
if (card.isOpen) {
|
|
47944
|
+
openedCardIds.push(card.getId());
|
|
47945
|
+
} else {
|
|
47946
|
+
closedCardIds.push(card.getId());
|
|
47947
|
+
}
|
|
47948
|
+
}
|
|
47949
|
+
if (openedCardIds.length) {
|
|
47950
|
+
this.emitForManyItems({
|
|
47951
|
+
class: "Card",
|
|
47952
|
+
method: "setIsOpen",
|
|
47953
|
+
item: [this.getId()],
|
|
47954
|
+
newData: { isOpen: false },
|
|
47955
|
+
prevData: { isOpen: true }
|
|
47956
|
+
});
|
|
47957
|
+
}
|
|
47958
|
+
if (closedCardIds.length) {
|
|
47959
|
+
this.emitForManyItems({
|
|
47960
|
+
class: "Card",
|
|
47961
|
+
method: "setIsOpen",
|
|
47962
|
+
item: [this.getId()],
|
|
47963
|
+
newData: { isOpen: true },
|
|
47964
|
+
prevData: { isOpen: false }
|
|
47965
|
+
});
|
|
47966
|
+
}
|
|
47923
47967
|
}
|
|
47924
47968
|
apply(op) {
|
|
47925
47969
|
super.apply(op);
|
|
@@ -47940,6 +47984,23 @@ registerItem({
|
|
|
47940
47984
|
item: Card,
|
|
47941
47985
|
defaultData: defaultCardData
|
|
47942
47986
|
});
|
|
47987
|
+
registerHotkey({
|
|
47988
|
+
name: "flipCard",
|
|
47989
|
+
hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
|
|
47990
|
+
boardMode: "edit",
|
|
47991
|
+
hotkeyConfig: {
|
|
47992
|
+
allItemsType: ["Card"],
|
|
47993
|
+
cb: (event, board) => {
|
|
47994
|
+
const cards = board?.selection.items.list();
|
|
47995
|
+
if (!cards) {
|
|
47996
|
+
return;
|
|
47997
|
+
}
|
|
47998
|
+
cards.forEach((card) => {
|
|
47999
|
+
card.toggleIsOpen();
|
|
48000
|
+
});
|
|
48001
|
+
}
|
|
48002
|
+
}
|
|
48003
|
+
});
|
|
47943
48004
|
// src/Items/Examples/CardGame/Deck/Deck.ts
|
|
47944
48005
|
var defaultDeckData = {
|
|
47945
48006
|
itemType: "Deck"
|
|
@@ -49370,10 +49431,11 @@ var hotkeys_default = {
|
|
|
49370
49431
|
|
|
49371
49432
|
// src/Keyboard/isHotkeyPushed.ts
|
|
49372
49433
|
function isHotkeyPushed(hotkey, event) {
|
|
49373
|
-
|
|
49434
|
+
const hotkeys = { ...hotkeys_default, ...hotkeyNames };
|
|
49435
|
+
if (!hotkeys[hotkey]) {
|
|
49374
49436
|
return false;
|
|
49375
49437
|
}
|
|
49376
|
-
const { key } =
|
|
49438
|
+
const { key } = hotkeys[hotkey];
|
|
49377
49439
|
const isControlPushed = event.ctrlKey || event.metaKey;
|
|
49378
49440
|
const isShiftPushed = event.shiftKey;
|
|
49379
49441
|
const isAltPushed = event.altKey;
|
|
@@ -49753,13 +49815,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
|
|
|
49753
49815
|
|
|
49754
49816
|
// src/Keyboard/checkHotkeys.ts
|
|
49755
49817
|
function checkHotkeys(hotkeyMap, event, board) {
|
|
49756
|
-
const
|
|
49818
|
+
const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
|
|
49819
|
+
const entries = Object.entries(fullHotkeysMap);
|
|
49757
49820
|
for (const [hotkey, configOrCb] of entries) {
|
|
49758
49821
|
if (isHotkeyPushed(hotkey, event)) {
|
|
49759
49822
|
const context = board.selection.getContext();
|
|
49760
49823
|
if (typeof configOrCb === "function") {
|
|
49761
49824
|
event.preventDefault();
|
|
49762
|
-
configOrCb(event);
|
|
49825
|
+
configOrCb(event, board);
|
|
49763
49826
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
49764
49827
|
return true;
|
|
49765
49828
|
}
|
|
@@ -49786,7 +49849,7 @@ function checkHotkeys(hotkeyMap, event, board) {
|
|
|
49786
49849
|
if (preventDefault) {
|
|
49787
49850
|
event.preventDefault();
|
|
49788
49851
|
}
|
|
49789
|
-
cb(event);
|
|
49852
|
+
cb(event, board);
|
|
49790
49853
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
49791
49854
|
return true;
|
|
49792
49855
|
}
|
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,
|
|
@@ -24138,6 +24141,14 @@ class BaseItem extends Mbr {
|
|
|
24138
24141
|
this.apply(operation);
|
|
24139
24142
|
}
|
|
24140
24143
|
}
|
|
24144
|
+
emitForManyItems(operation) {
|
|
24145
|
+
if (!this.board.events) {
|
|
24146
|
+
return;
|
|
24147
|
+
}
|
|
24148
|
+
const command = createCommand(this.board, operation);
|
|
24149
|
+
command.apply();
|
|
24150
|
+
this.board.events.emit(operation, command);
|
|
24151
|
+
}
|
|
24141
24152
|
apply(op) {
|
|
24142
24153
|
op = op;
|
|
24143
24154
|
switch (op.class) {
|
|
@@ -50297,6 +50308,19 @@ function throttle(func, delay) {
|
|
|
50297
50308
|
};
|
|
50298
50309
|
}
|
|
50299
50310
|
|
|
50311
|
+
// src/Keyboard/HotkeyRegistry.ts
|
|
50312
|
+
var editModeHotkeyRegistry = {};
|
|
50313
|
+
var viewModeHotkeyRegistry = {};
|
|
50314
|
+
var hotkeyNames = {};
|
|
50315
|
+
function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
|
|
50316
|
+
if (boardMode === "edit") {
|
|
50317
|
+
editModeHotkeyRegistry[name] = hotkeyConfig;
|
|
50318
|
+
} else {
|
|
50319
|
+
viewModeHotkeyRegistry[name] = hotkeyConfig;
|
|
50320
|
+
}
|
|
50321
|
+
hotkeyNames[name] = hotkey;
|
|
50322
|
+
}
|
|
50323
|
+
|
|
50300
50324
|
// src/Items/Examples/CardGame/Card/Card.ts
|
|
50301
50325
|
var defaultCardData = {
|
|
50302
50326
|
itemType: "Card",
|
|
@@ -50385,14 +50409,34 @@ class Card extends BaseItem {
|
|
|
50385
50409
|
this.subject.publish(this);
|
|
50386
50410
|
return this;
|
|
50387
50411
|
}
|
|
50388
|
-
toggleIsOpen() {
|
|
50389
|
-
|
|
50390
|
-
|
|
50391
|
-
|
|
50392
|
-
|
|
50393
|
-
|
|
50394
|
-
|
|
50395
|
-
|
|
50412
|
+
toggleIsOpen(cards) {
|
|
50413
|
+
const openedCardIds = [];
|
|
50414
|
+
const closedCardIds = [];
|
|
50415
|
+
for (const card of cards) {
|
|
50416
|
+
if (card.isOpen) {
|
|
50417
|
+
openedCardIds.push(card.getId());
|
|
50418
|
+
} else {
|
|
50419
|
+
closedCardIds.push(card.getId());
|
|
50420
|
+
}
|
|
50421
|
+
}
|
|
50422
|
+
if (openedCardIds.length) {
|
|
50423
|
+
this.emitForManyItems({
|
|
50424
|
+
class: "Card",
|
|
50425
|
+
method: "setIsOpen",
|
|
50426
|
+
item: [this.getId()],
|
|
50427
|
+
newData: { isOpen: false },
|
|
50428
|
+
prevData: { isOpen: true }
|
|
50429
|
+
});
|
|
50430
|
+
}
|
|
50431
|
+
if (closedCardIds.length) {
|
|
50432
|
+
this.emitForManyItems({
|
|
50433
|
+
class: "Card",
|
|
50434
|
+
method: "setIsOpen",
|
|
50435
|
+
item: [this.getId()],
|
|
50436
|
+
newData: { isOpen: true },
|
|
50437
|
+
prevData: { isOpen: false }
|
|
50438
|
+
});
|
|
50439
|
+
}
|
|
50396
50440
|
}
|
|
50397
50441
|
apply(op) {
|
|
50398
50442
|
super.apply(op);
|
|
@@ -50413,6 +50457,23 @@ registerItem({
|
|
|
50413
50457
|
item: Card,
|
|
50414
50458
|
defaultData: defaultCardData
|
|
50415
50459
|
});
|
|
50460
|
+
registerHotkey({
|
|
50461
|
+
name: "flipCard",
|
|
50462
|
+
hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
|
|
50463
|
+
boardMode: "edit",
|
|
50464
|
+
hotkeyConfig: {
|
|
50465
|
+
allItemsType: ["Card"],
|
|
50466
|
+
cb: (event, board) => {
|
|
50467
|
+
const cards = board?.selection.items.list();
|
|
50468
|
+
if (!cards) {
|
|
50469
|
+
return;
|
|
50470
|
+
}
|
|
50471
|
+
cards.forEach((card) => {
|
|
50472
|
+
card.toggleIsOpen();
|
|
50473
|
+
});
|
|
50474
|
+
}
|
|
50475
|
+
}
|
|
50476
|
+
});
|
|
50416
50477
|
// src/Items/Examples/CardGame/Deck/Deck.ts
|
|
50417
50478
|
var defaultDeckData = {
|
|
50418
50479
|
itemType: "Deck"
|
|
@@ -51843,10 +51904,11 @@ var hotkeys_default = {
|
|
|
51843
51904
|
|
|
51844
51905
|
// src/Keyboard/isHotkeyPushed.ts
|
|
51845
51906
|
function isHotkeyPushed(hotkey, event) {
|
|
51846
|
-
|
|
51907
|
+
const hotkeys = { ...hotkeys_default, ...hotkeyNames };
|
|
51908
|
+
if (!hotkeys[hotkey]) {
|
|
51847
51909
|
return false;
|
|
51848
51910
|
}
|
|
51849
|
-
const { key } =
|
|
51911
|
+
const { key } = hotkeys[hotkey];
|
|
51850
51912
|
const isControlPushed = event.ctrlKey || event.metaKey;
|
|
51851
51913
|
const isShiftPushed = event.shiftKey;
|
|
51852
51914
|
const isAltPushed = event.altKey;
|
|
@@ -52226,13 +52288,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
|
|
|
52226
52288
|
|
|
52227
52289
|
// src/Keyboard/checkHotkeys.ts
|
|
52228
52290
|
function checkHotkeys(hotkeyMap, event, board) {
|
|
52229
|
-
const
|
|
52291
|
+
const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
|
|
52292
|
+
const entries = Object.entries(fullHotkeysMap);
|
|
52230
52293
|
for (const [hotkey, configOrCb] of entries) {
|
|
52231
52294
|
if (isHotkeyPushed(hotkey, event)) {
|
|
52232
52295
|
const context = board.selection.getContext();
|
|
52233
52296
|
if (typeof configOrCb === "function") {
|
|
52234
52297
|
event.preventDefault();
|
|
52235
|
-
configOrCb(event);
|
|
52298
|
+
configOrCb(event, board);
|
|
52236
52299
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
52237
52300
|
return true;
|
|
52238
52301
|
}
|
|
@@ -52259,7 +52322,7 @@ function checkHotkeys(hotkeyMap, event, board) {
|
|
|
52259
52322
|
if (preventDefault) {
|
|
52260
52323
|
event.preventDefault();
|
|
52261
52324
|
}
|
|
52262
|
-
cb(event);
|
|
52325
|
+
cb(event, board);
|
|
52263
52326
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
52264
52327
|
return true;
|
|
52265
52328
|
}
|
package/dist/esm/browser.js
CHANGED
|
@@ -21515,6 +21515,14 @@ class BaseItem extends Mbr {
|
|
|
21515
21515
|
this.apply(operation);
|
|
21516
21516
|
}
|
|
21517
21517
|
}
|
|
21518
|
+
emitForManyItems(operation) {
|
|
21519
|
+
if (!this.board.events) {
|
|
21520
|
+
return;
|
|
21521
|
+
}
|
|
21522
|
+
const command = createCommand(this.board, operation);
|
|
21523
|
+
command.apply();
|
|
21524
|
+
this.board.events.emit(operation, command);
|
|
21525
|
+
}
|
|
21518
21526
|
apply(op) {
|
|
21519
21527
|
op = op;
|
|
21520
21528
|
switch (op.class) {
|
|
@@ -47673,6 +47681,19 @@ function throttle(func, delay) {
|
|
|
47673
47681
|
};
|
|
47674
47682
|
}
|
|
47675
47683
|
|
|
47684
|
+
// src/Keyboard/HotkeyRegistry.ts
|
|
47685
|
+
var editModeHotkeyRegistry = {};
|
|
47686
|
+
var viewModeHotkeyRegistry = {};
|
|
47687
|
+
var hotkeyNames = {};
|
|
47688
|
+
function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
|
|
47689
|
+
if (boardMode === "edit") {
|
|
47690
|
+
editModeHotkeyRegistry[name] = hotkeyConfig;
|
|
47691
|
+
} else {
|
|
47692
|
+
viewModeHotkeyRegistry[name] = hotkeyConfig;
|
|
47693
|
+
}
|
|
47694
|
+
hotkeyNames[name] = hotkey;
|
|
47695
|
+
}
|
|
47696
|
+
|
|
47676
47697
|
// src/Items/Examples/CardGame/Card/Card.ts
|
|
47677
47698
|
var defaultCardData = {
|
|
47678
47699
|
itemType: "Card",
|
|
@@ -47761,14 +47782,34 @@ class Card extends BaseItem {
|
|
|
47761
47782
|
this.subject.publish(this);
|
|
47762
47783
|
return this;
|
|
47763
47784
|
}
|
|
47764
|
-
toggleIsOpen() {
|
|
47765
|
-
|
|
47766
|
-
|
|
47767
|
-
|
|
47768
|
-
|
|
47769
|
-
|
|
47770
|
-
|
|
47771
|
-
|
|
47785
|
+
toggleIsOpen(cards) {
|
|
47786
|
+
const openedCardIds = [];
|
|
47787
|
+
const closedCardIds = [];
|
|
47788
|
+
for (const card of cards) {
|
|
47789
|
+
if (card.isOpen) {
|
|
47790
|
+
openedCardIds.push(card.getId());
|
|
47791
|
+
} else {
|
|
47792
|
+
closedCardIds.push(card.getId());
|
|
47793
|
+
}
|
|
47794
|
+
}
|
|
47795
|
+
if (openedCardIds.length) {
|
|
47796
|
+
this.emitForManyItems({
|
|
47797
|
+
class: "Card",
|
|
47798
|
+
method: "setIsOpen",
|
|
47799
|
+
item: [this.getId()],
|
|
47800
|
+
newData: { isOpen: false },
|
|
47801
|
+
prevData: { isOpen: true }
|
|
47802
|
+
});
|
|
47803
|
+
}
|
|
47804
|
+
if (closedCardIds.length) {
|
|
47805
|
+
this.emitForManyItems({
|
|
47806
|
+
class: "Card",
|
|
47807
|
+
method: "setIsOpen",
|
|
47808
|
+
item: [this.getId()],
|
|
47809
|
+
newData: { isOpen: true },
|
|
47810
|
+
prevData: { isOpen: false }
|
|
47811
|
+
});
|
|
47812
|
+
}
|
|
47772
47813
|
}
|
|
47773
47814
|
apply(op) {
|
|
47774
47815
|
super.apply(op);
|
|
@@ -47789,6 +47830,23 @@ registerItem({
|
|
|
47789
47830
|
item: Card,
|
|
47790
47831
|
defaultData: defaultCardData
|
|
47791
47832
|
});
|
|
47833
|
+
registerHotkey({
|
|
47834
|
+
name: "flipCard",
|
|
47835
|
+
hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
|
|
47836
|
+
boardMode: "edit",
|
|
47837
|
+
hotkeyConfig: {
|
|
47838
|
+
allItemsType: ["Card"],
|
|
47839
|
+
cb: (event, board) => {
|
|
47840
|
+
const cards = board?.selection.items.list();
|
|
47841
|
+
if (!cards) {
|
|
47842
|
+
return;
|
|
47843
|
+
}
|
|
47844
|
+
cards.forEach((card) => {
|
|
47845
|
+
card.toggleIsOpen();
|
|
47846
|
+
});
|
|
47847
|
+
}
|
|
47848
|
+
}
|
|
47849
|
+
});
|
|
47792
47850
|
// src/Items/Examples/CardGame/Deck/Deck.ts
|
|
47793
47851
|
var defaultDeckData = {
|
|
47794
47852
|
itemType: "Deck"
|
|
@@ -49219,10 +49277,11 @@ var hotkeys_default = {
|
|
|
49219
49277
|
|
|
49220
49278
|
// src/Keyboard/isHotkeyPushed.ts
|
|
49221
49279
|
function isHotkeyPushed(hotkey, event) {
|
|
49222
|
-
|
|
49280
|
+
const hotkeys = { ...hotkeys_default, ...hotkeyNames };
|
|
49281
|
+
if (!hotkeys[hotkey]) {
|
|
49223
49282
|
return false;
|
|
49224
49283
|
}
|
|
49225
|
-
const { key } =
|
|
49284
|
+
const { key } = hotkeys[hotkey];
|
|
49226
49285
|
const isControlPushed = event.ctrlKey || event.metaKey;
|
|
49227
49286
|
const isShiftPushed = event.shiftKey;
|
|
49228
49287
|
const isAltPushed = event.altKey;
|
|
@@ -49602,13 +49661,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
|
|
|
49602
49661
|
|
|
49603
49662
|
// src/Keyboard/checkHotkeys.ts
|
|
49604
49663
|
function checkHotkeys(hotkeyMap, event, board) {
|
|
49605
|
-
const
|
|
49664
|
+
const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
|
|
49665
|
+
const entries = Object.entries(fullHotkeysMap);
|
|
49606
49666
|
for (const [hotkey, configOrCb] of entries) {
|
|
49607
49667
|
if (isHotkeyPushed(hotkey, event)) {
|
|
49608
49668
|
const context = board.selection.getContext();
|
|
49609
49669
|
if (typeof configOrCb === "function") {
|
|
49610
49670
|
event.preventDefault();
|
|
49611
|
-
configOrCb(event);
|
|
49671
|
+
configOrCb(event, board);
|
|
49612
49672
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
49613
49673
|
return true;
|
|
49614
49674
|
}
|
|
@@ -49635,7 +49695,7 @@ function checkHotkeys(hotkeyMap, event, board) {
|
|
|
49635
49695
|
if (preventDefault) {
|
|
49636
49696
|
event.preventDefault();
|
|
49637
49697
|
}
|
|
49638
|
-
cb(event);
|
|
49698
|
+
cb(event, board);
|
|
49639
49699
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
49640
49700
|
return true;
|
|
49641
49701
|
}
|
|
@@ -56401,6 +56461,7 @@ function initBrowserSettings() {
|
|
|
56401
56461
|
// src/browser.ts
|
|
56402
56462
|
initBrowserSettings();
|
|
56403
56463
|
export {
|
|
56464
|
+
viewModeHotkeyRegistry,
|
|
56404
56465
|
validateRichTextData,
|
|
56405
56466
|
validateItemsMap,
|
|
56406
56467
|
uploadVideoToStorage,
|
|
@@ -56440,6 +56501,7 @@ export {
|
|
|
56440
56501
|
isFiniteNumber,
|
|
56441
56502
|
isControlCharacter,
|
|
56442
56503
|
initI18N,
|
|
56504
|
+
hotkeyNames,
|
|
56443
56505
|
getYouTubeVideoPreview,
|
|
56444
56506
|
getYouTubeThumbnail,
|
|
56445
56507
|
getVideoMetadata,
|
|
@@ -56454,6 +56516,7 @@ export {
|
|
|
56454
56516
|
forceNumberIntoInterval,
|
|
56455
56517
|
fileTosha256,
|
|
56456
56518
|
exportBoardSnapshot,
|
|
56519
|
+
editModeHotkeyRegistry,
|
|
56457
56520
|
decodeHtml,
|
|
56458
56521
|
defaultCursors as cursors,
|
|
56459
56522
|
createVideoItem,
|
package/dist/esm/index.js
CHANGED
|
@@ -21508,6 +21508,14 @@ class BaseItem extends Mbr {
|
|
|
21508
21508
|
this.apply(operation);
|
|
21509
21509
|
}
|
|
21510
21510
|
}
|
|
21511
|
+
emitForManyItems(operation) {
|
|
21512
|
+
if (!this.board.events) {
|
|
21513
|
+
return;
|
|
21514
|
+
}
|
|
21515
|
+
const command = createCommand(this.board, operation);
|
|
21516
|
+
command.apply();
|
|
21517
|
+
this.board.events.emit(operation, command);
|
|
21518
|
+
}
|
|
21511
21519
|
apply(op) {
|
|
21512
21520
|
op = op;
|
|
21513
21521
|
switch (op.class) {
|
|
@@ -47666,6 +47674,19 @@ function throttle(func, delay) {
|
|
|
47666
47674
|
};
|
|
47667
47675
|
}
|
|
47668
47676
|
|
|
47677
|
+
// src/Keyboard/HotkeyRegistry.ts
|
|
47678
|
+
var editModeHotkeyRegistry = {};
|
|
47679
|
+
var viewModeHotkeyRegistry = {};
|
|
47680
|
+
var hotkeyNames = {};
|
|
47681
|
+
function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
|
|
47682
|
+
if (boardMode === "edit") {
|
|
47683
|
+
editModeHotkeyRegistry[name] = hotkeyConfig;
|
|
47684
|
+
} else {
|
|
47685
|
+
viewModeHotkeyRegistry[name] = hotkeyConfig;
|
|
47686
|
+
}
|
|
47687
|
+
hotkeyNames[name] = hotkey;
|
|
47688
|
+
}
|
|
47689
|
+
|
|
47669
47690
|
// src/Items/Examples/CardGame/Card/Card.ts
|
|
47670
47691
|
var defaultCardData = {
|
|
47671
47692
|
itemType: "Card",
|
|
@@ -47754,14 +47775,34 @@ class Card extends BaseItem {
|
|
|
47754
47775
|
this.subject.publish(this);
|
|
47755
47776
|
return this;
|
|
47756
47777
|
}
|
|
47757
|
-
toggleIsOpen() {
|
|
47758
|
-
|
|
47759
|
-
|
|
47760
|
-
|
|
47761
|
-
|
|
47762
|
-
|
|
47763
|
-
|
|
47764
|
-
|
|
47778
|
+
toggleIsOpen(cards) {
|
|
47779
|
+
const openedCardIds = [];
|
|
47780
|
+
const closedCardIds = [];
|
|
47781
|
+
for (const card of cards) {
|
|
47782
|
+
if (card.isOpen) {
|
|
47783
|
+
openedCardIds.push(card.getId());
|
|
47784
|
+
} else {
|
|
47785
|
+
closedCardIds.push(card.getId());
|
|
47786
|
+
}
|
|
47787
|
+
}
|
|
47788
|
+
if (openedCardIds.length) {
|
|
47789
|
+
this.emitForManyItems({
|
|
47790
|
+
class: "Card",
|
|
47791
|
+
method: "setIsOpen",
|
|
47792
|
+
item: [this.getId()],
|
|
47793
|
+
newData: { isOpen: false },
|
|
47794
|
+
prevData: { isOpen: true }
|
|
47795
|
+
});
|
|
47796
|
+
}
|
|
47797
|
+
if (closedCardIds.length) {
|
|
47798
|
+
this.emitForManyItems({
|
|
47799
|
+
class: "Card",
|
|
47800
|
+
method: "setIsOpen",
|
|
47801
|
+
item: [this.getId()],
|
|
47802
|
+
newData: { isOpen: true },
|
|
47803
|
+
prevData: { isOpen: false }
|
|
47804
|
+
});
|
|
47805
|
+
}
|
|
47765
47806
|
}
|
|
47766
47807
|
apply(op) {
|
|
47767
47808
|
super.apply(op);
|
|
@@ -47782,6 +47823,23 @@ registerItem({
|
|
|
47782
47823
|
item: Card,
|
|
47783
47824
|
defaultData: defaultCardData
|
|
47784
47825
|
});
|
|
47826
|
+
registerHotkey({
|
|
47827
|
+
name: "flipCard",
|
|
47828
|
+
hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
|
|
47829
|
+
boardMode: "edit",
|
|
47830
|
+
hotkeyConfig: {
|
|
47831
|
+
allItemsType: ["Card"],
|
|
47832
|
+
cb: (event, board) => {
|
|
47833
|
+
const cards = board?.selection.items.list();
|
|
47834
|
+
if (!cards) {
|
|
47835
|
+
return;
|
|
47836
|
+
}
|
|
47837
|
+
cards.forEach((card) => {
|
|
47838
|
+
card.toggleIsOpen();
|
|
47839
|
+
});
|
|
47840
|
+
}
|
|
47841
|
+
}
|
|
47842
|
+
});
|
|
47785
47843
|
// src/Items/Examples/CardGame/Deck/Deck.ts
|
|
47786
47844
|
var defaultDeckData = {
|
|
47787
47845
|
itemType: "Deck"
|
|
@@ -49212,10 +49270,11 @@ var hotkeys_default = {
|
|
|
49212
49270
|
|
|
49213
49271
|
// src/Keyboard/isHotkeyPushed.ts
|
|
49214
49272
|
function isHotkeyPushed(hotkey, event) {
|
|
49215
|
-
|
|
49273
|
+
const hotkeys = { ...hotkeys_default, ...hotkeyNames };
|
|
49274
|
+
if (!hotkeys[hotkey]) {
|
|
49216
49275
|
return false;
|
|
49217
49276
|
}
|
|
49218
|
-
const { key } =
|
|
49277
|
+
const { key } = hotkeys[hotkey];
|
|
49219
49278
|
const isControlPushed = event.ctrlKey || event.metaKey;
|
|
49220
49279
|
const isShiftPushed = event.shiftKey;
|
|
49221
49280
|
const isAltPushed = event.altKey;
|
|
@@ -49595,13 +49654,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
|
|
|
49595
49654
|
|
|
49596
49655
|
// src/Keyboard/checkHotkeys.ts
|
|
49597
49656
|
function checkHotkeys(hotkeyMap, event, board) {
|
|
49598
|
-
const
|
|
49657
|
+
const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
|
|
49658
|
+
const entries = Object.entries(fullHotkeysMap);
|
|
49599
49659
|
for (const [hotkey, configOrCb] of entries) {
|
|
49600
49660
|
if (isHotkeyPushed(hotkey, event)) {
|
|
49601
49661
|
const context = board.selection.getContext();
|
|
49602
49662
|
if (typeof configOrCb === "function") {
|
|
49603
49663
|
event.preventDefault();
|
|
49604
|
-
configOrCb(event);
|
|
49664
|
+
configOrCb(event, board);
|
|
49605
49665
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
49606
49666
|
return true;
|
|
49607
49667
|
}
|
|
@@ -49628,7 +49688,7 @@ function checkHotkeys(hotkeyMap, event, board) {
|
|
|
49628
49688
|
if (preventDefault) {
|
|
49629
49689
|
event.preventDefault();
|
|
49630
49690
|
}
|
|
49631
|
-
cb(event);
|
|
49691
|
+
cb(event, board);
|
|
49632
49692
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
49633
49693
|
return true;
|
|
49634
49694
|
}
|
|
@@ -56299,6 +56359,7 @@ function initI18N(i18nInstance) {
|
|
|
56299
56359
|
return i18nInstance;
|
|
56300
56360
|
}
|
|
56301
56361
|
export {
|
|
56362
|
+
viewModeHotkeyRegistry,
|
|
56302
56363
|
validateRichTextData,
|
|
56303
56364
|
validateItemsMap,
|
|
56304
56365
|
uploadVideoToStorage,
|
|
@@ -56338,6 +56399,7 @@ export {
|
|
|
56338
56399
|
isFiniteNumber,
|
|
56339
56400
|
isControlCharacter,
|
|
56340
56401
|
initI18N,
|
|
56402
|
+
hotkeyNames,
|
|
56341
56403
|
getYouTubeVideoPreview,
|
|
56342
56404
|
getYouTubeThumbnail,
|
|
56343
56405
|
getVideoMetadata,
|
|
@@ -56352,6 +56414,7 @@ export {
|
|
|
56352
56414
|
forceNumberIntoInterval,
|
|
56353
56415
|
fileTosha256,
|
|
56354
56416
|
exportBoardSnapshot,
|
|
56417
|
+
editModeHotkeyRegistry,
|
|
56355
56418
|
decodeHtml,
|
|
56356
56419
|
defaultCursors as cursors,
|
|
56357
56420
|
createVideoItem,
|
package/dist/esm/node.js
CHANGED
|
@@ -23975,6 +23975,14 @@ class BaseItem extends Mbr {
|
|
|
23975
23975
|
this.apply(operation);
|
|
23976
23976
|
}
|
|
23977
23977
|
}
|
|
23978
|
+
emitForManyItems(operation) {
|
|
23979
|
+
if (!this.board.events) {
|
|
23980
|
+
return;
|
|
23981
|
+
}
|
|
23982
|
+
const command = createCommand(this.board, operation);
|
|
23983
|
+
command.apply();
|
|
23984
|
+
this.board.events.emit(operation, command);
|
|
23985
|
+
}
|
|
23978
23986
|
apply(op) {
|
|
23979
23987
|
op = op;
|
|
23980
23988
|
switch (op.class) {
|
|
@@ -50134,6 +50142,19 @@ function throttle(func, delay) {
|
|
|
50134
50142
|
};
|
|
50135
50143
|
}
|
|
50136
50144
|
|
|
50145
|
+
// src/Keyboard/HotkeyRegistry.ts
|
|
50146
|
+
var editModeHotkeyRegistry = {};
|
|
50147
|
+
var viewModeHotkeyRegistry = {};
|
|
50148
|
+
var hotkeyNames = {};
|
|
50149
|
+
function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
|
|
50150
|
+
if (boardMode === "edit") {
|
|
50151
|
+
editModeHotkeyRegistry[name] = hotkeyConfig;
|
|
50152
|
+
} else {
|
|
50153
|
+
viewModeHotkeyRegistry[name] = hotkeyConfig;
|
|
50154
|
+
}
|
|
50155
|
+
hotkeyNames[name] = hotkey;
|
|
50156
|
+
}
|
|
50157
|
+
|
|
50137
50158
|
// src/Items/Examples/CardGame/Card/Card.ts
|
|
50138
50159
|
var defaultCardData = {
|
|
50139
50160
|
itemType: "Card",
|
|
@@ -50222,14 +50243,34 @@ class Card extends BaseItem {
|
|
|
50222
50243
|
this.subject.publish(this);
|
|
50223
50244
|
return this;
|
|
50224
50245
|
}
|
|
50225
|
-
toggleIsOpen() {
|
|
50226
|
-
|
|
50227
|
-
|
|
50228
|
-
|
|
50229
|
-
|
|
50230
|
-
|
|
50231
|
-
|
|
50232
|
-
|
|
50246
|
+
toggleIsOpen(cards) {
|
|
50247
|
+
const openedCardIds = [];
|
|
50248
|
+
const closedCardIds = [];
|
|
50249
|
+
for (const card of cards) {
|
|
50250
|
+
if (card.isOpen) {
|
|
50251
|
+
openedCardIds.push(card.getId());
|
|
50252
|
+
} else {
|
|
50253
|
+
closedCardIds.push(card.getId());
|
|
50254
|
+
}
|
|
50255
|
+
}
|
|
50256
|
+
if (openedCardIds.length) {
|
|
50257
|
+
this.emitForManyItems({
|
|
50258
|
+
class: "Card",
|
|
50259
|
+
method: "setIsOpen",
|
|
50260
|
+
item: [this.getId()],
|
|
50261
|
+
newData: { isOpen: false },
|
|
50262
|
+
prevData: { isOpen: true }
|
|
50263
|
+
});
|
|
50264
|
+
}
|
|
50265
|
+
if (closedCardIds.length) {
|
|
50266
|
+
this.emitForManyItems({
|
|
50267
|
+
class: "Card",
|
|
50268
|
+
method: "setIsOpen",
|
|
50269
|
+
item: [this.getId()],
|
|
50270
|
+
newData: { isOpen: true },
|
|
50271
|
+
prevData: { isOpen: false }
|
|
50272
|
+
});
|
|
50273
|
+
}
|
|
50233
50274
|
}
|
|
50234
50275
|
apply(op) {
|
|
50235
50276
|
super.apply(op);
|
|
@@ -50250,6 +50291,23 @@ registerItem({
|
|
|
50250
50291
|
item: Card,
|
|
50251
50292
|
defaultData: defaultCardData
|
|
50252
50293
|
});
|
|
50294
|
+
registerHotkey({
|
|
50295
|
+
name: "flipCard",
|
|
50296
|
+
hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
|
|
50297
|
+
boardMode: "edit",
|
|
50298
|
+
hotkeyConfig: {
|
|
50299
|
+
allItemsType: ["Card"],
|
|
50300
|
+
cb: (event, board) => {
|
|
50301
|
+
const cards = board?.selection.items.list();
|
|
50302
|
+
if (!cards) {
|
|
50303
|
+
return;
|
|
50304
|
+
}
|
|
50305
|
+
cards.forEach((card) => {
|
|
50306
|
+
card.toggleIsOpen();
|
|
50307
|
+
});
|
|
50308
|
+
}
|
|
50309
|
+
}
|
|
50310
|
+
});
|
|
50253
50311
|
// src/Items/Examples/CardGame/Deck/Deck.ts
|
|
50254
50312
|
var defaultDeckData = {
|
|
50255
50313
|
itemType: "Deck"
|
|
@@ -51680,10 +51738,11 @@ var hotkeys_default = {
|
|
|
51680
51738
|
|
|
51681
51739
|
// src/Keyboard/isHotkeyPushed.ts
|
|
51682
51740
|
function isHotkeyPushed(hotkey, event) {
|
|
51683
|
-
|
|
51741
|
+
const hotkeys = { ...hotkeys_default, ...hotkeyNames };
|
|
51742
|
+
if (!hotkeys[hotkey]) {
|
|
51684
51743
|
return false;
|
|
51685
51744
|
}
|
|
51686
|
-
const { key } =
|
|
51745
|
+
const { key } = hotkeys[hotkey];
|
|
51687
51746
|
const isControlPushed = event.ctrlKey || event.metaKey;
|
|
51688
51747
|
const isShiftPushed = event.shiftKey;
|
|
51689
51748
|
const isAltPushed = event.altKey;
|
|
@@ -52063,13 +52122,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
|
|
|
52063
52122
|
|
|
52064
52123
|
// src/Keyboard/checkHotkeys.ts
|
|
52065
52124
|
function checkHotkeys(hotkeyMap, event, board) {
|
|
52066
|
-
const
|
|
52125
|
+
const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
|
|
52126
|
+
const entries = Object.entries(fullHotkeysMap);
|
|
52067
52127
|
for (const [hotkey, configOrCb] of entries) {
|
|
52068
52128
|
if (isHotkeyPushed(hotkey, event)) {
|
|
52069
52129
|
const context = board.selection.getContext();
|
|
52070
52130
|
if (typeof configOrCb === "function") {
|
|
52071
52131
|
event.preventDefault();
|
|
52072
|
-
configOrCb(event);
|
|
52132
|
+
configOrCb(event, board);
|
|
52073
52133
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
52074
52134
|
return true;
|
|
52075
52135
|
}
|
|
@@ -52096,7 +52156,7 @@ function checkHotkeys(hotkeyMap, event, board) {
|
|
|
52096
52156
|
if (preventDefault) {
|
|
52097
52157
|
event.preventDefault();
|
|
52098
52158
|
}
|
|
52099
|
-
cb(event);
|
|
52159
|
+
cb(event, board);
|
|
52100
52160
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
52101
52161
|
return true;
|
|
52102
52162
|
}
|
|
@@ -58934,6 +58994,7 @@ function initNodeSettings() {
|
|
|
58934
58994
|
// src/node.ts
|
|
58935
58995
|
initNodeSettings();
|
|
58936
58996
|
export {
|
|
58997
|
+
viewModeHotkeyRegistry,
|
|
58937
58998
|
validateRichTextData,
|
|
58938
58999
|
validateItemsMap,
|
|
58939
59000
|
uploadVideoToStorage,
|
|
@@ -58973,6 +59034,7 @@ export {
|
|
|
58973
59034
|
isFiniteNumber,
|
|
58974
59035
|
isControlCharacter,
|
|
58975
59036
|
initI18N,
|
|
59037
|
+
hotkeyNames,
|
|
58976
59038
|
getYouTubeVideoPreview,
|
|
58977
59039
|
getYouTubeThumbnail,
|
|
58978
59040
|
getVideoMetadata,
|
|
@@ -58987,6 +59049,7 @@ export {
|
|
|
58987
59049
|
forceNumberIntoInterval,
|
|
58988
59050
|
fileTosha256,
|
|
58989
59051
|
exportBoardSnapshot,
|
|
59052
|
+
editModeHotkeyRegistry,
|
|
58990
59053
|
decodeHtml,
|
|
58991
59054
|
defaultCursors as cursors,
|
|
58992
59055
|
createVideoItem,
|
|
@@ -61,6 +61,7 @@ export declare class BaseItem extends Mbr implements Geometry {
|
|
|
61
61
|
serialize(): SerializedItemData;
|
|
62
62
|
isClosed(): boolean;
|
|
63
63
|
emit(operation: Operation | BaseOperation): void;
|
|
64
|
+
emitForManyItems(operation: Operation | BaseOperation): void;
|
|
64
65
|
apply(op: Operation | BaseItemOperation | BaseOperation): void;
|
|
65
66
|
addOnRemoveCallback(cb: () => void): void;
|
|
66
67
|
onRemove(): void;
|
|
@@ -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";
|