@lvce-editor/main-process 6.19.4 → 6.19.6

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.
@@ -4376,7 +4376,8 @@ const getOrCreateConfig = () => {
4376
4376
 
4377
4377
  const getRelativePath = url => {
4378
4378
  const relative = url.slice(scheme.length + 4);
4379
- return relative;
4379
+ const queryIndex = relative.indexOf('?');
4380
+ return queryIndex === -1 ? relative : relative.slice(0, queryIndex);
4380
4381
  };
4381
4382
 
4382
4383
  const getElectronFileResponseConfig = async (url, request) => {
@@ -6255,6 +6256,39 @@ const getKeyBindingIdentifier = input => {
6255
6256
  return identifier;
6256
6257
  };
6257
6258
 
6259
+ const MaxZoomLevel = 3;
6260
+ const MinZoomLevel = -3;
6261
+ const ZoomDelta = 0.2;
6262
+ const getZoomDelta = input => {
6263
+ if (!input.control || input.alt || input.meta) {
6264
+ return 0;
6265
+ }
6266
+ if (input.key === '+' || input.key === '=') {
6267
+ return ZoomDelta;
6268
+ }
6269
+ if (input.key === '-') {
6270
+ return -ZoomDelta;
6271
+ }
6272
+ return 0;
6273
+ };
6274
+ const handleWebContentsViewZoomKeyBinding = (webContentsId, input) => {
6275
+ const delta = getZoomDelta(input);
6276
+ if (delta === 0) {
6277
+ return false;
6278
+ }
6279
+ const state = get$3(webContentsId);
6280
+ if (!state) {
6281
+ return false;
6282
+ }
6283
+ const {
6284
+ webContents
6285
+ } = state.view;
6286
+ const currentZoomLevel = webContents.getZoomLevel();
6287
+ const newZoomLevel = Math.max(MinZoomLevel, Math.min(MaxZoomLevel, currentZoomLevel + delta));
6288
+ webContents.setZoomLevel(newZoomLevel);
6289
+ return true;
6290
+ };
6291
+
6258
6292
  const key$7 = 'before-input';
6259
6293
  const attach$7 = (webContents, listener) => {
6260
6294
  webContents.on(BeforeInputEvent, listener);
@@ -6262,13 +6296,21 @@ const attach$7 = (webContents, listener) => {
6262
6296
  const detach$7 = (webContents, listener) => {
6263
6297
  webContents.off(BeforeInputEvent, listener);
6264
6298
  };
6265
- const handler$7 = (event, input) => {
6299
+ const handler$7 = (event, input, webContentsId) => {
6266
6300
  if (input.type !== KeyDown) {
6267
6301
  return {
6268
6302
  messages: [],
6269
6303
  result: undefined
6270
6304
  };
6271
6305
  }
6306
+ const didZoom = handleWebContentsViewZoomKeyBinding(webContentsId, input);
6307
+ if (didZoom) {
6308
+ event.preventDefault();
6309
+ return {
6310
+ messages: [],
6311
+ result: undefined
6312
+ };
6313
+ }
6272
6314
  const falltroughKeyBindings = getFallthroughKeyBindings();
6273
6315
  const identifier = getKeyBindingIdentifier(input);
6274
6316
  // @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.6",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"