wysimark-lite 0.9.7 → 0.9.8

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.
@@ -1,10 +1,8 @@
1
1
  import * as slate from 'slate';
2
2
  import { Element as Element$1, BaseEditor, NodeEntry, BaseRange, Location, Editor, Descendant, Path, BaseText } from 'slate';
3
- import { Client } from '@portive/client';
4
- import { SetReturnType, SetOptional, UnionToIntersection, Simplify, RequireExactlyOne } from 'type-fest';
5
- import * as zustand from 'zustand';
6
3
  import { HistoryEditor } from 'slate-history';
7
4
  import { ReactEditor, Editable } from 'slate-react';
5
+ import { SetReturnType, SetOptional, UnionToIntersection, Simplify } from 'type-fest';
8
6
  import react from 'react';
9
7
  import { RenderElementProps, RenderLeafProps, RenderPlaceholderProps, EditableProps } from 'slate-react/dist/components/editable';
10
8
 
@@ -423,79 +421,146 @@ type ImageSizePreset = {
423
421
  scale: number;
424
422
  };
425
423
 
426
- declare function createAnchorMethods(editor: Editor): {
427
- insertLink: (args_0: string, args_1?: string | undefined, args_2?: {
428
- select?: boolean | undefined;
429
- } | undefined) => void;
430
- removeLink: (args_0: {
431
- at?: BetterAt | undefined;
432
- }) => boolean;
433
- editLink: (args_0: {
434
- href: string;
435
- title?: string | undefined;
436
- }, args_1: {
437
- at?: BetterAt | undefined;
438
- }) => boolean;
424
+ type ToolbarEditor = {
425
+ toolbar: {
426
+ height?: string | number;
427
+ minHeight?: string | number;
428
+ maxHeight?: string | number;
429
+ showUploadButtons?: boolean;
430
+ };
431
+ };
432
+ type ToolbarOptions = {
433
+ toolbar: {
434
+ height?: string | number;
435
+ minHeight?: string | number;
436
+ maxHeight?: string | number;
437
+ showUploadButtons?: boolean;
438
+ };
439
+ };
440
+ type ToolbarPluginCustomTypes = {
441
+ Name: "toolbar";
442
+ Editor: ToolbarEditor;
443
+ Options: ToolbarOptions;
439
444
  };
440
445
 
441
- type AnchorMethods = ReturnType<typeof createAnchorMethods>;
442
- type AnchorEditor = {
443
- anchor: AnchorMethods;
446
+ type ThemeEditor = {
447
+ theme: true;
444
448
  };
445
- type AnchorElement = {
446
- type: "anchor";
447
- href: string;
448
- target?: string;
449
- title?: string;
449
+ type ThemePluginCustomTypes = {
450
+ Name: "theme";
451
+ Editor: ThemeEditor;
452
+ };
453
+
454
+ type CollapsibleParagraphEditor = {
455
+ collapsibleParagraph: {
456
+ convertParagraph: () => void;
457
+ };
458
+ };
459
+ type ParagraphElement = {
460
+ type: "paragraph";
461
+ __collapsible?: true;
450
462
  children: Descendant[];
451
463
  };
452
- type AnchorPluginCustomTypes = {
453
- Name: "anchor";
454
- Editor: AnchorEditor;
455
- Element: AnchorElement;
464
+ type CollapsibleParagraphPluginCustomTypes = {
465
+ Name: "collapsible-paragraph";
466
+ Editor: CollapsibleParagraphEditor;
467
+ Element: ParagraphElement;
456
468
  };
457
469
 
458
- declare function createHeadingMethods(editor: Editor): {
459
- convertHeading: (level: 1 | 2 | 3 | 4 | 5 | 6, allowToggle: boolean) => void;
460
- isHeadingActive: (level: 1 | 2 | 3 | 4 | 5 | 6) => boolean;
470
+ type NormalizeAfterDeleteEditor = {
471
+ normalizeAfterDelete: true;
472
+ };
473
+ type NormalizeAfterDeletePluginCustomTypes = {
474
+ Name: "normalize-after-delete";
475
+ Editor: NormalizeAfterDeleteEditor;
461
476
  };
462
477
 
463
- type HeadingEditor = {
464
- heading: ReturnType<typeof createHeadingMethods>;
478
+ type AtomicDeleteEditor = {
479
+ atomicDelete: true;
465
480
  };
466
- type HeadingElement = {
467
- type: "heading";
468
- /**
469
- * NOTE:
470
- *
471
- * Don't extract these into a new type. It's easier to just repeat this and
472
- * there's less indirection.
473
- */
474
- level: 1 | 2 | 3 | 4 | 5 | 6;
475
- children: Descendant[];
481
+ type AtomicDeletePluginCustomTypes = {
482
+ Name: "atomic-delete";
483
+ Editor: AtomicDeleteEditor;
476
484
  };
477
- type HeadingPluginCustomTypes = {
478
- Name: "heading";
479
- Editor: HeadingEditor;
480
- Element: HeadingElement;
485
+
486
+ declare function createListMethods(editor: Editor): {
487
+ indent: () => boolean;
488
+ outdent: () => boolean;
489
+ convertUnorderedList: (allowToggle: boolean) => void;
490
+ convertOrderedList: (allowToggle: boolean) => void;
491
+ convertTaskList: (allowToggle: boolean) => void;
492
+ insertBreak: () => boolean;
493
+ toggleTaskListItem: (args_0?: {
494
+ at?: BetterAt | undefined;
495
+ } | undefined) => false | undefined;
496
+ getListDepth: () => number;
497
+ canIncreaseDepth: () => boolean;
498
+ canDecreaseDepth: () => boolean;
499
+ increaseDepth: () => void;
500
+ decreaseDepth: () => void;
481
501
  };
482
502
 
483
- type BlockQuoteEditor = {
484
- supportsBlockQuote: true;
485
- blockQuotePlugin: {
486
- indent: () => void;
487
- outdent: () => void;
488
- isActive: () => boolean;
489
- };
503
+ /**
504
+ * List Editor
505
+ */
506
+ type ListEditor = {
507
+ list: ReturnType<typeof createListMethods>;
490
508
  };
491
- type BlockQuoteElement = {
492
- type: "block-quote";
509
+ /**
510
+ * Ordered List Item Element
511
+ */
512
+ type OrderedListItemElement = {
513
+ type: "ordered-list-item";
514
+ depth: number;
515
+ __firstAtDepth?: boolean;
493
516
  children: Descendant[];
494
517
  };
495
- type BlockQuotePluginCustomTypes = {
496
- Name: "block-quote";
497
- Editor: BlockQuoteEditor;
498
- Element: BlockQuoteElement;
518
+ /**
519
+ * Unordered List Item Element
520
+ */
521
+ type UnorderedListItemElement = {
522
+ type: "unordered-list-item";
523
+ depth: number;
524
+ __firstAtDepth?: boolean;
525
+ children: Descendant[];
526
+ };
527
+ /**
528
+ * Checkable Task List Item Element
529
+ */
530
+ type TaskListItemElement = {
531
+ type: "task-list-item";
532
+ depth: number;
533
+ __firstAtDepth?: boolean;
534
+ checked: boolean;
535
+ children: Descendant[];
536
+ };
537
+ /**
538
+ * List Plugins Custom Types
539
+ */
540
+ type ListPluginCustomTypes = {
541
+ Name: "list";
542
+ Editor: ListEditor;
543
+ Element: OrderedListItemElement | UnorderedListItemElement | TaskListItemElement;
544
+ };
545
+
546
+ declare function createHorizontalRuleMethods(editor: Editor): {
547
+ insertHorizontalRule: () => boolean;
548
+ };
549
+
550
+ type HorizontalRuleMethods = ReturnType<typeof createHorizontalRuleMethods>;
551
+ type HorizontalRuleEditor = {
552
+ horizontalRule: HorizontalRuleMethods;
553
+ };
554
+ type HorizontalRuleElement = {
555
+ type: "horizontal-rule";
556
+ children: [{
557
+ text: "";
558
+ }];
559
+ };
560
+ type HorizontalRulePluginCustomTypes = {
561
+ Name: "horizontal-rule";
562
+ Editor: HorizontalRuleEditor;
563
+ Element: HorizontalRuleElement;
499
564
  };
500
565
 
501
566
  /**
@@ -574,100 +639,79 @@ type TableInfo = {
574
639
  cellCount: number;
575
640
  };
576
641
 
577
- declare function createHorizontalRuleMethods(editor: Editor): {
578
- insertHorizontalRule: () => boolean;
642
+ declare function createAnchorMethods(editor: Editor): {
643
+ insertLink: (args_0: string, args_1?: string | undefined, args_2?: {
644
+ select?: boolean | undefined;
645
+ } | undefined) => void;
646
+ removeLink: (args_0: {
647
+ at?: BetterAt | undefined;
648
+ }) => boolean;
649
+ editLink: (args_0: {
650
+ href: string;
651
+ title?: string | undefined;
652
+ }, args_1: {
653
+ at?: BetterAt | undefined;
654
+ }) => boolean;
579
655
  };
580
656
 
581
- type HorizontalRuleMethods = ReturnType<typeof createHorizontalRuleMethods>;
582
- type HorizontalRuleEditor = {
583
- horizontalRule: HorizontalRuleMethods;
657
+ type AnchorMethods = ReturnType<typeof createAnchorMethods>;
658
+ type AnchorEditor = {
659
+ anchor: AnchorMethods;
584
660
  };
585
- type HorizontalRuleElement = {
586
- type: "horizontal-rule";
587
- children: [{
588
- text: "";
589
- }];
661
+ type AnchorElement = {
662
+ type: "anchor";
663
+ href: string;
664
+ target?: string;
665
+ title?: string;
666
+ children: Descendant[];
590
667
  };
591
- type HorizontalRulePluginCustomTypes = {
592
- Name: "horizontal-rule";
593
- Editor: HorizontalRuleEditor;
594
- Element: HorizontalRuleElement;
668
+ type AnchorPluginCustomTypes = {
669
+ Name: "anchor";
670
+ Editor: AnchorEditor;
671
+ Element: AnchorElement;
595
672
  };
596
673
 
597
- declare function createListMethods(editor: Editor): {
598
- indent: () => boolean;
599
- outdent: () => boolean;
600
- convertUnorderedList: (allowToggle: boolean) => void;
601
- convertOrderedList: (allowToggle: boolean) => void;
602
- convertTaskList: (allowToggle: boolean) => void;
603
- insertBreak: () => boolean;
604
- toggleTaskListItem: (args_0?: {
605
- at?: BetterAt | undefined;
606
- } | undefined) => false | undefined;
607
- getListDepth: () => number;
608
- canIncreaseDepth: () => boolean;
609
- canDecreaseDepth: () => boolean;
610
- increaseDepth: () => void;
611
- decreaseDepth: () => void;
674
+ declare function createHeadingMethods(editor: Editor): {
675
+ convertHeading: (level: 1 | 2 | 3 | 4 | 5 | 6, allowToggle: boolean) => void;
676
+ isHeadingActive: (level: 1 | 2 | 3 | 4 | 5 | 6) => boolean;
612
677
  };
613
678
 
614
- /**
615
- * List Editor
616
- */
617
- type ListEditor = {
618
- list: ReturnType<typeof createListMethods>;
619
- };
620
- /**
621
- * Ordered List Item Element
622
- */
623
- type OrderedListItemElement = {
624
- type: "ordered-list-item";
625
- depth: number;
626
- __firstAtDepth?: boolean;
627
- children: Descendant[];
628
- };
629
- /**
630
- * Unordered List Item Element
631
- */
632
- type UnorderedListItemElement = {
633
- type: "unordered-list-item";
634
- depth: number;
635
- __firstAtDepth?: boolean;
636
- children: Descendant[];
679
+ type HeadingEditor = {
680
+ heading: ReturnType<typeof createHeadingMethods>;
637
681
  };
638
- /**
639
- * Checkable Task List Item Element
640
- */
641
- type TaskListItemElement = {
642
- type: "task-list-item";
643
- depth: number;
644
- __firstAtDepth?: boolean;
645
- checked: boolean;
682
+ type HeadingElement = {
683
+ type: "heading";
684
+ /**
685
+ * NOTE:
686
+ *
687
+ * Don't extract these into a new type. It's easier to just repeat this and
688
+ * there's less indirection.
689
+ */
690
+ level: 1 | 2 | 3 | 4 | 5 | 6;
646
691
  children: Descendant[];
647
692
  };
648
- /**
649
- * List Plugins Custom Types
650
- */
651
- type ListPluginCustomTypes = {
652
- Name: "list";
653
- Editor: ListEditor;
654
- Element: OrderedListItemElement | UnorderedListItemElement | TaskListItemElement;
693
+ type HeadingPluginCustomTypes = {
694
+ Name: "heading";
695
+ Editor: HeadingEditor;
696
+ Element: HeadingElement;
655
697
  };
656
698
 
657
- type CollapsibleParagraphEditor = {
658
- collapsibleParagraph: {
659
- convertParagraph: () => void;
699
+ type BlockQuoteEditor = {
700
+ supportsBlockQuote: true;
701
+ blockQuotePlugin: {
702
+ indent: () => void;
703
+ outdent: () => void;
704
+ isActive: () => boolean;
660
705
  };
661
706
  };
662
- type ParagraphElement = {
663
- type: "paragraph";
664
- __collapsible?: true;
707
+ type BlockQuoteElement = {
708
+ type: "block-quote";
665
709
  children: Descendant[];
666
710
  };
667
- type CollapsibleParagraphPluginCustomTypes = {
668
- Name: "collapsible-paragraph";
669
- Editor: CollapsibleParagraphEditor;
670
- Element: ParagraphElement;
711
+ type BlockQuotePluginCustomTypes = {
712
+ Name: "block-quote";
713
+ Editor: BlockQuoteEditor;
714
+ Element: BlockQuoteElement;
671
715
  };
672
716
 
673
717
  declare function createTableMethods(editor: Editor): {
@@ -714,161 +758,6 @@ type TablePluginCustomTypes = {
714
758
  Element: TableElement | TableRowElement | TableCellElement | TableContentElement;
715
759
  };
716
760
 
717
- declare function createUploadMethods(editor: Editor): {
718
- upload: (file: File) => boolean;
719
- setElementTimeTraveling: <T extends ImageBlockElement | ImageInlineElement | ParagraphElement | OrderedListItemElement | UnorderedListItemElement | TaskListItemElement | HorizontalRuleElement | TableElement | TableRowElement | TableCellElement | TableContentElement | BlockQuoteElement | HeadingElement | AnchorElement, K extends keyof T = keyof T>(prev: RequireExactlyOne<T, K>, next: RequireExactlyOne<T, K>) => void;
720
- };
721
-
722
- /**
723
- * Indicates an `Origin` that is uploading and the state of the Upload
724
- */
725
- type UploadProgress = {
726
- /**
727
- * This is a URL but not the final upload URL. This is a URL that represents
728
- * a secure value in the form of a string that represents a location on the
729
- * user's computer.
730
- */
731
- url: string;
732
- status: "progress";
733
- sentBytes: number;
734
- totalBytes: number;
735
- };
736
- /**
737
- * Indicates an `Origin` that has completed uploading
738
- */
739
- type UploadComplete = {
740
- status: "success";
741
- /**
742
- * This is a URL to the final place of the file
743
- */
744
- url: string;
745
- };
746
- /**
747
- * Indicates an `Origin` that has an error during uploading and the Error
748
- * message
749
- */
750
- type UploadError = {
751
- status: "error";
752
- url: string;
753
- message: string;
754
- };
755
- type Upload = UploadProgress | UploadComplete | UploadError;
756
-
757
- /**
758
- * Creates an origin store using `zustand`.
759
- *
760
- * The purpose of this is to keep track of uploads and their progress but only
761
- * storing the key to the lookup in the Element itself.
762
- *
763
- * This is necessary so that the Element value stays the same even as the image
764
- * progress is updating during the upload.
765
- *
766
- * We want this because we don't want the progress updates to be part of the
767
- * document's edit history. Consider that a user executes an undo and it undoes
768
- * the progress of the upload.
769
- *
770
- * Te return value of `createUploadStore` is a React hook.
771
- *
772
- * The hook should be referenced as `useUploadStore`
773
- */
774
- declare const createUploadStore: ({ uploads }?: {
775
- uploads: Record<string, Upload>;
776
- }) => zustand.UseBoundStore<zustand.StoreApi<UploadStore>>;
777
-
778
- /**
779
- * Types related to the `zustand` state-management library which we use to
780
- * store the state of uploads.
781
- */
782
- type GetUpload = (id: string) => Upload;
783
- type SetUpload = (id: string, upload: Upload) => void;
784
- type UploadStore = {
785
- uploads: Record<string, Upload>;
786
- getUpload: GetUpload;
787
- setUpload: SetUpload;
788
- };
789
-
790
- type UploadMethods = ReturnType<typeof createUploadMethods>;
791
- type UploadFileEvent = {
792
- hashUrl: string;
793
- file: File;
794
- };
795
- type UploadImageFileEvent = UploadFileEvent & {
796
- width: number;
797
- height: number;
798
- };
799
- type UploadFileSuccessEvent = UploadFileEvent & {
800
- url: string;
801
- };
802
- type UploadImageFileSuccessEvent = UploadImageFileEvent & {
803
- url: string;
804
- };
805
- type UploadEditor = {
806
- upload: UploadMethods & {
807
- client?: Client;
808
- onUploadImageFile: (e: UploadImageFileEvent) => boolean;
809
- onUploadFile: (e: UploadFileEvent) => boolean;
810
- onUploadImageFileSuccess: (e: UploadImageFileSuccessEvent) => boolean;
811
- onUploadFileSuccess: (e: UploadFileSuccessEvent) => boolean;
812
- useUploadStore: ReturnType<typeof createUploadStore>;
813
- };
814
- };
815
- type UploadOptions = {
816
- upload?: {
817
- authToken?: string;
818
- };
819
- };
820
- type UploadPluginCustomTypes = {
821
- Name: "upload";
822
- Editor: UploadEditor;
823
- Options: UploadOptions;
824
- };
825
-
826
- type ToolbarEditor = {
827
- toolbar: {
828
- height?: string | number;
829
- minHeight?: string | number;
830
- maxHeight?: string | number;
831
- showUploadButtons?: boolean;
832
- };
833
- };
834
- type ToolbarOptions = {
835
- toolbar: {
836
- height?: string | number;
837
- minHeight?: string | number;
838
- maxHeight?: string | number;
839
- showUploadButtons?: boolean;
840
- };
841
- };
842
- type ToolbarPluginCustomTypes = {
843
- Name: "toolbar";
844
- Editor: ToolbarEditor;
845
- Options: ToolbarOptions;
846
- };
847
-
848
- type ThemeEditor = {
849
- theme: true;
850
- };
851
- type ThemePluginCustomTypes = {
852
- Name: "theme";
853
- Editor: ThemeEditor;
854
- };
855
-
856
- type NormalizeAfterDeleteEditor = {
857
- normalizeAfterDelete: true;
858
- };
859
- type NormalizeAfterDeletePluginCustomTypes = {
860
- Name: "normalize-after-delete";
861
- Editor: NormalizeAfterDeleteEditor;
862
- };
863
-
864
- type AtomicDeleteEditor = {
865
- atomicDelete: true;
866
- };
867
- type AtomicDeletePluginCustomTypes = {
868
- Name: "atomic-delete";
869
- Editor: AtomicDeleteEditor;
870
- };
871
-
872
761
  type InlineCodeEditor = {
873
762
  inlineCode: {
874
763
  toggleInlineCode: () => void;
@@ -982,7 +871,7 @@ declare const plugins: (TypedPlugin<PasteMarkdownPluginCustomTypes> | TypedPlugi
982
871
  Editor: {
983
872
  allowTrailingBlock: true;
984
873
  };
985
- }> | TypedPlugin<ListPluginCustomTypes> | TypedPlugin<AtomicDeletePluginCustomTypes> | TypedPlugin<NormalizeAfterDeletePluginCustomTypes> | TypedPlugin<CollapsibleParagraphPluginCustomTypes> | TypedPlugin<ThemePluginCustomTypes> | TypedPlugin<ToolbarPluginCustomTypes> | TypedPlugin<UploadPluginCustomTypes> | TypedPlugin<ImagePluginCustomTypes> | TypedPlugin<PlaceholderPluginCustomTypes>)[];
874
+ }> | TypedPlugin<ListPluginCustomTypes> | TypedPlugin<AtomicDeletePluginCustomTypes> | TypedPlugin<NormalizeAfterDeletePluginCustomTypes> | TypedPlugin<CollapsibleParagraphPluginCustomTypes> | TypedPlugin<ThemePluginCustomTypes> | TypedPlugin<ToolbarPluginCustomTypes> | TypedPlugin<ImagePluginCustomTypes> | TypedPlugin<PlaceholderPluginCustomTypes>)[];
986
875
  type PluginTypes = ExtractCustomTypes<typeof plugins>;
987
876
  type CustomEditor = PluginTypes["Editor"];
988
877
  type CustomElement = PluginTypes["Element"];