@prose-reader/core 1.65.0 → 1.67.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.
@@ -468,20 +468,25 @@
468
468
  }
469
469
  );
470
470
  fixReflowable(reader);
471
- let observer;
472
- if (options.layoutAutoResize === `container`) {
473
- reader.context.state$.pipe(
474
- operators.map((state) => state.containerElement),
475
- operators.filter(isDefined),
476
- operators.distinctUntilChanged(),
477
- operators.takeUntil(reader.$.destroy$)
478
- ).subscribe((container) => {
479
- observer = new ResizeObserver(() => {
480
- reader == null ? void 0 : reader.layout();
481
- });
482
- observer.observe(container);
471
+ const observeContainerResize = (container) => new rxjs.Observable((observer) => {
472
+ const resizeObserver = new ResizeObserver(() => {
473
+ observer.next();
483
474
  });
484
- }
475
+ resizeObserver.observe(container);
476
+ return () => {
477
+ resizeObserver.disconnect();
478
+ };
479
+ });
480
+ const layoutOnContainerResize$ = settingsManager.settings$.pipe(
481
+ operators.filter(({ layoutAutoResize: layoutAutoResize2 }) => layoutAutoResize2 === "container"),
482
+ operators.switchMap(() => reader.context.containerElement$),
483
+ operators.filter(isDefined),
484
+ operators.switchMap((container) => observeContainerResize(container)),
485
+ operators.debounceTime(100),
486
+ operators.tap(() => {
487
+ reader == null ? void 0 : reader.layout();
488
+ })
489
+ );
485
490
  const movingSafePan$ = createMovingSafePan$(reader);
486
491
  movingSafePan$.subscribe();
487
492
  settingsManager.settings$.pipe(
@@ -493,12 +498,12 @@
493
498
  }),
494
499
  operators.takeUntil(reader.$.destroy$)
495
500
  ).subscribe();
501
+ rxjs.merge(layoutOnContainerResize$).pipe(operators.takeUntil(reader.$.destroy$)).subscribe();
496
502
  return {
497
503
  ...reader,
498
504
  destroy: () => {
499
505
  settingsManager.destroy();
500
506
  reader.destroy();
501
- observer == null ? void 0 : observer.disconnect();
502
507
  },
503
508
  settings: settingsManager
504
509
  };
@@ -2464,6 +2469,174 @@
2464
2469
  }
2465
2470
  `;
2466
2471
  };
2472
+ const buildStyleForViewportFrame = () => {
2473
+ return `
2474
+ ${getStyleForViewportDocument()}
2475
+ html {
2476
+ width: 100%;
2477
+ height: 100%;
2478
+ }
2479
+ body {
2480
+ width: 100%;
2481
+ height: 100%;
2482
+ margin: 0;
2483
+ }
2484
+ ${/*
2485
+ * @see https://hammerjs.github.io/touch-action/
2486
+ */
2487
+ ``}
2488
+ html, body {
2489
+ touch-action: none;
2490
+ }
2491
+ `;
2492
+ };
2493
+ const buildStyleForReflowableImageOnly = ({
2494
+ isScrollable,
2495
+ enableTouch
2496
+ }) => {
2497
+ return `
2498
+ ${/*
2499
+ * @see https://hammerjs.github.io/touch-action/
2500
+ */
2501
+ ``}
2502
+ html, body {
2503
+ width: 100%;
2504
+ margin: 0;
2505
+ padding: 0;
2506
+ ${enableTouch ? `
2507
+ touch-action: none
2508
+ ` : ``}
2509
+ }
2510
+ ${isScrollable ? `
2511
+ img {
2512
+ height: auto !important;
2513
+ margin: 0;
2514
+ padding: 0;
2515
+ box-sizing: border-box;
2516
+ ${// we make sure img spread on entire screen
2517
+ ``}
2518
+ width: 100%;
2519
+ ${/**
2520
+ * line break issue
2521
+ * @see https://stackoverflow.com/questions/37869020/image-not-taking-up-the-full-height-of-container
2522
+ */
2523
+ ``}
2524
+ display: block;
2525
+ }
2526
+ ` : ``}
2527
+ `;
2528
+ };
2529
+ const buildStyleWithMultiColumn = ({
2530
+ width,
2531
+ columnHeight,
2532
+ columnWidth
2533
+ }) => {
2534
+ return `
2535
+ parsererror {
2536
+ display: none !important;
2537
+ }
2538
+ ${/*
2539
+ might be html * but it does mess up things like figure if so.
2540
+ check accessible_epub_3
2541
+ */
2542
+ ``}
2543
+ html, body {
2544
+ margin: 0;
2545
+ padding: 0 !important;
2546
+ -max-width: ${columnWidth}px !important;
2547
+ }
2548
+ ${/*
2549
+ body {
2550
+ height: ${columnHeight}px !important;
2551
+ width: ${columnWidth}px !important;
2552
+ -margin-left: ${horizontalMargin}px !important;
2553
+ -margin-right: ${horizontalMargin}px !important;
2554
+ -margin: ${verticalMargin}px ${horizontalMargin}px !important;
2555
+ -padding-top: ${horizontalMargin}px !important;
2556
+ -padding-bottom: ${horizontalMargin}px !important;
2557
+ }
2558
+ */
2559
+ ``}
2560
+ body {
2561
+ padding: 0 !important;
2562
+ width: ${width}px !important;
2563
+ height: ${columnHeight}px !important;
2564
+ overflow-y: hidden;
2565
+ column-gap: 0px !important;
2566
+ column-width: ${columnWidth}px !important;
2567
+ column-fill: auto !important;
2568
+ word-wrap: break-word;
2569
+ box-sizing: border-box;
2570
+ }
2571
+ body {
2572
+ margin: 0;
2573
+ }
2574
+ body:focus-visible {
2575
+ ${/*
2576
+ we make sure that there are no outline when we focus something inside the iframe
2577
+ */
2578
+ ``}
2579
+ outline: none;
2580
+ }
2581
+ ${/*
2582
+ * @see https://hammerjs.github.io/touch-action/
2583
+ */
2584
+ ``}
2585
+ html, body {
2586
+ touch-action: none;
2587
+ }
2588
+ ${/*
2589
+ this messes up hard, be careful with this
2590
+ */
2591
+ ``}
2592
+ * {
2593
+ -max-width: ${columnWidth}px !important;
2594
+ }
2595
+ ${/*
2596
+ this is necessary to have a proper calculation when determining size
2597
+ of iframe content. If an img is using something like width:100% it would expand to
2598
+ the size of the original image and potentially gives back a wrong size (much larger)
2599
+ @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Columns/Handling_Overflow_in_Multicol
2600
+ */
2601
+ ``}
2602
+ img, video, audio, object, svg {
2603
+ max-width: 100%;
2604
+ max-width: ${columnWidth}px !important;
2605
+ max-height: ${columnHeight}px !important;
2606
+ -pointer-events: none;
2607
+ -webkit-column-break-inside: avoid;
2608
+ page-break-inside: avoid;
2609
+ break-inside: avoid;
2610
+ }
2611
+ figure {
2612
+ d-max-width: ${columnWidth}px !important;
2613
+ }
2614
+ img {
2615
+ object-fit: contain;
2616
+ break-inside: avoid;
2617
+ box-sizing: border-box;
2618
+ d-max-width: ${columnWidth}px !important;
2619
+ }
2620
+ ${/*
2621
+ img, video, audio, object, svg {
2622
+ max-height: ${columnHeight}px !important;
2623
+ box-sizing: border-box;
2624
+ object-fit: contain;
2625
+ -webkit-column-break-inside: avoid;
2626
+ page-break-inside: avoid;
2627
+ break-inside: avoid;
2628
+ }
2629
+ */
2630
+ ``}
2631
+ table {
2632
+ max-width: ${columnWidth}px !important;
2633
+ table-layout: fixed;
2634
+ }
2635
+ td {
2636
+ max-width: ${columnWidth}px;
2637
+ }
2638
+ `;
2639
+ };
2467
2640
  const createReflowableSpineItem = ({
2468
2641
  item,
2469
2642
  context,
@@ -2593,174 +2766,6 @@
2593
2766
  layout
2594
2767
  };
2595
2768
  };
2596
- const buildStyleForViewportFrame = () => {
2597
- return `
2598
- ${getStyleForViewportDocument()}
2599
- html {
2600
- width: 100%;
2601
- height: 100%;
2602
- }
2603
- body {
2604
- width: 100%;
2605
- height: 100%;
2606
- margin: 0;
2607
- }
2608
- ${/*
2609
- * @see https://hammerjs.github.io/touch-action/
2610
- */
2611
- ``}
2612
- html, body {
2613
- touch-action: none;
2614
- }
2615
- `;
2616
- };
2617
- const buildStyleForReflowableImageOnly = ({
2618
- isScrollable,
2619
- enableTouch
2620
- }) => {
2621
- return `
2622
- ${/*
2623
- * @see https://hammerjs.github.io/touch-action/
2624
- */
2625
- ``}
2626
- html, body {
2627
- width: 100%;
2628
- margin: 0;
2629
- padding: 0;
2630
- ${enableTouch ? `
2631
- touch-action: none
2632
- ` : ``}
2633
- }
2634
- ${isScrollable ? `
2635
- img {
2636
- height: auto !important;
2637
- margin: 0;
2638
- padding: 0;
2639
- box-sizing: border-box;
2640
- ${// we make sure img spread on entire screen
2641
- ``}
2642
- width: 100%;
2643
- ${/**
2644
- * line break issue
2645
- * @see https://stackoverflow.com/questions/37869020/image-not-taking-up-the-full-height-of-container
2646
- */
2647
- ``}
2648
- display: block;
2649
- }
2650
- ` : ``}
2651
- `;
2652
- };
2653
- const buildStyleWithMultiColumn = ({
2654
- width,
2655
- columnHeight,
2656
- columnWidth
2657
- }) => {
2658
- return `
2659
- parsererror {
2660
- display: none !important;
2661
- }
2662
- ${/*
2663
- might be html * but it does mess up things like figure if so.
2664
- check accessible_epub_3
2665
- */
2666
- ``}
2667
- html, body {
2668
- margin: 0;
2669
- padding: 0 !important;
2670
- -max-width: ${columnWidth}px !important;
2671
- }
2672
- ${/*
2673
- body {
2674
- height: ${columnHeight}px !important;
2675
- width: ${columnWidth}px !important;
2676
- -margin-left: ${horizontalMargin}px !important;
2677
- -margin-right: ${horizontalMargin}px !important;
2678
- -margin: ${verticalMargin}px ${horizontalMargin}px !important;
2679
- -padding-top: ${horizontalMargin}px !important;
2680
- -padding-bottom: ${horizontalMargin}px !important;
2681
- }
2682
- */
2683
- ``}
2684
- body {
2685
- padding: 0 !important;
2686
- width: ${width}px !important;
2687
- height: ${columnHeight}px !important;
2688
- overflow-y: hidden;
2689
- column-gap: 0px !important;
2690
- column-width: ${columnWidth}px !important;
2691
- column-fill: auto !important;
2692
- word-wrap: break-word;
2693
- box-sizing: border-box;
2694
- }
2695
- body {
2696
- margin: 0;
2697
- }
2698
- body:focus-visible {
2699
- ${/*
2700
- we make sure that there are no outline when we focus something inside the iframe
2701
- */
2702
- ``}
2703
- outline: none;
2704
- }
2705
- ${/*
2706
- * @see https://hammerjs.github.io/touch-action/
2707
- */
2708
- ``}
2709
- html, body {
2710
- touch-action: none;
2711
- }
2712
- ${/*
2713
- this messes up hard, be careful with this
2714
- */
2715
- ``}
2716
- * {
2717
- -max-width: ${columnWidth}px !important;
2718
- }
2719
- ${/*
2720
- this is necessary to have a proper calculation when determining size
2721
- of iframe content. If an img is using something like width:100% it would expand to
2722
- the size of the original image and potentially gives back a wrong size (much larger)
2723
- @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Columns/Handling_Overflow_in_Multicol
2724
- */
2725
- ``}
2726
- img, video, audio, object, svg {
2727
- max-width: 100%;
2728
- max-width: ${columnWidth}px !important;
2729
- max-height: ${columnHeight}px !important;
2730
- -pointer-events: none;
2731
- -webkit-column-break-inside: avoid;
2732
- page-break-inside: avoid;
2733
- break-inside: avoid;
2734
- }
2735
- figure {
2736
- d-max-width: ${columnWidth}px !important;
2737
- }
2738
- img {
2739
- object-fit: contain;
2740
- break-inside: avoid;
2741
- box-sizing: border-box;
2742
- d-max-width: ${columnWidth}px !important;
2743
- }
2744
- ${/*
2745
- img, video, audio, object, svg {
2746
- max-height: ${columnHeight}px !important;
2747
- box-sizing: border-box;
2748
- object-fit: contain;
2749
- -webkit-column-break-inside: avoid;
2750
- page-break-inside: avoid;
2751
- break-inside: avoid;
2752
- }
2753
- */
2754
- ``}
2755
- table {
2756
- max-width: ${columnWidth}px !important;
2757
- table-layout: fixed;
2758
- }
2759
- td {
2760
- max-width: ${columnWidth}px;
2761
- }
2762
- `;
2763
- };
2764
2769
  const createSpineItem = ({
2765
2770
  item,
2766
2771
  context,