@lvce-editor/main-process 6.19.4 → 6.19.5

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.
@@ -6255,6 +6255,39 @@ const getKeyBindingIdentifier = input => {
6255
6255
  return identifier;
6256
6256
  };
6257
6257
 
6258
+ const MaxZoomLevel = 3;
6259
+ const MinZoomLevel = -3;
6260
+ const ZoomDelta = 0.2;
6261
+ const getZoomDelta = input => {
6262
+ if (!input.control || input.alt || input.meta) {
6263
+ return 0;
6264
+ }
6265
+ if (input.key === '+' || input.key === '=') {
6266
+ return ZoomDelta;
6267
+ }
6268
+ if (input.key === '-') {
6269
+ return -ZoomDelta;
6270
+ }
6271
+ return 0;
6272
+ };
6273
+ const handleWebContentsViewZoomKeyBinding = (webContentsId, input) => {
6274
+ const delta = getZoomDelta(input);
6275
+ if (delta === 0) {
6276
+ return false;
6277
+ }
6278
+ const state = get$3(webContentsId);
6279
+ if (!state) {
6280
+ return false;
6281
+ }
6282
+ const {
6283
+ webContents
6284
+ } = state.view;
6285
+ const currentZoomLevel = webContents.getZoomLevel();
6286
+ const newZoomLevel = Math.max(MinZoomLevel, Math.min(MaxZoomLevel, currentZoomLevel + delta));
6287
+ webContents.setZoomLevel(newZoomLevel);
6288
+ return true;
6289
+ };
6290
+
6258
6291
  const key$7 = 'before-input';
6259
6292
  const attach$7 = (webContents, listener) => {
6260
6293
  webContents.on(BeforeInputEvent, listener);
@@ -6262,13 +6295,21 @@ const attach$7 = (webContents, listener) => {
6262
6295
  const detach$7 = (webContents, listener) => {
6263
6296
  webContents.off(BeforeInputEvent, listener);
6264
6297
  };
6265
- const handler$7 = (event, input) => {
6298
+ const handler$7 = (event, input, webContentsId) => {
6266
6299
  if (input.type !== KeyDown) {
6267
6300
  return {
6268
6301
  messages: [],
6269
6302
  result: undefined
6270
6303
  };
6271
6304
  }
6305
+ const didZoom = handleWebContentsViewZoomKeyBinding(webContentsId, input);
6306
+ if (didZoom) {
6307
+ event.preventDefault();
6308
+ return {
6309
+ messages: [],
6310
+ result: undefined
6311
+ };
6312
+ }
6272
6313
  const falltroughKeyBindings = getFallthroughKeyBindings();
6273
6314
  const identifier = getKeyBindingIdentifier(input);
6274
6315
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "6.19.4",
3
+ "version": "6.19.5",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"