@tiptap/core 2.0.0-beta.138 → 2.0.0-beta.141

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.
@@ -0,0 +1,2 @@
1
+ import { AnyExtension, EnableRules } from '../types';
2
+ export default function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean;
@@ -1,2 +1,2 @@
1
- declare const style = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}";
1
+ declare const style = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}";
2
2
  export default style;
@@ -47,6 +47,7 @@ export interface EditorEvents {
47
47
  };
48
48
  destroy: void;
49
49
  }
50
+ export declare type EnableRules = (AnyExtension | string)[] | boolean;
50
51
  export interface EditorOptions {
51
52
  element: Element;
52
53
  content: Content;
@@ -56,8 +57,8 @@ export interface EditorOptions {
56
57
  editable: boolean;
57
58
  editorProps: EditorProps;
58
59
  parseOptions: ParseOptions;
59
- enableInputRules: boolean;
60
- enablePasteRules: boolean;
60
+ enableInputRules: EnableRules;
61
+ enablePasteRules: EnableRules;
61
62
  enableCoreExtensions: boolean;
62
63
  onBeforeCreate: (props: EditorEvents['beforeCreate']) => void;
63
64
  onCreate: (props: EditorEvents['create']) => void;
@@ -178,7 +179,7 @@ export declare type ChainedCommands = {
178
179
  export declare type CanCommands = SingleCommands & {
179
180
  chain: () => ChainedCommands;
180
181
  };
181
- export declare type FocusPosition = 'start' | 'end' | number | boolean | null;
182
+ export declare type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null;
182
183
  export declare type Range = {
183
184
  from: number;
184
185
  to: number;
@@ -513,13 +513,19 @@ function resolveSelection(state, position = null) {
513
513
  to: 0,
514
514
  };
515
515
  }
516
+ const { size } = state.doc.content;
516
517
  if (position === 'end') {
517
- const { size } = state.doc.content;
518
518
  return {
519
519
  from: size,
520
520
  to: size,
521
521
  };
522
522
  }
523
+ if (position === 'all') {
524
+ return {
525
+ from: 0,
526
+ to: size,
527
+ };
528
+ }
523
529
  return {
524
530
  from: position,
525
531
  to: position,
@@ -2676,6 +2682,18 @@ function getSchemaTypeByName(name, schema) {
2676
2682
  return schema.nodes[name] || schema.marks[name] || null;
2677
2683
  }
2678
2684
 
2685
+ function isExtensionRulesEnabled(extension, enabled) {
2686
+ if (Array.isArray(enabled)) {
2687
+ return enabled.some(enabledExtension => {
2688
+ const name = typeof enabledExtension === 'string'
2689
+ ? enabledExtension
2690
+ : enabledExtension.name;
2691
+ return name === extension.name;
2692
+ });
2693
+ }
2694
+ return enabled;
2695
+ }
2696
+
2679
2697
  function findDuplicates(items) {
2680
2698
  const filtered = items.filter((el, index) => items.indexOf(el) !== index);
2681
2699
  return [...new Set(filtered)];
@@ -2830,11 +2848,11 @@ class ExtensionManager {
2830
2848
  plugins.push(keyMapPlugin);
2831
2849
  }
2832
2850
  const addInputRules = getExtensionField(extension, 'addInputRules', context);
2833
- if (editor.options.enableInputRules && addInputRules) {
2851
+ if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
2834
2852
  inputRules.push(...addInputRules());
2835
2853
  }
2836
2854
  const addPasteRules = getExtensionField(extension, 'addPasteRules', context);
2837
- if (editor.options.enablePasteRules && addPasteRules) {
2855
+ if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
2838
2856
  pasteRules.push(...addPasteRules());
2839
2857
  }
2840
2858
  const addProseMirrorPlugins = getExtensionField(extension, 'addProseMirrorPlugins', context);
@@ -2966,6 +2984,7 @@ img.ProseMirror-separator {
2966
2984
  display: none;
2967
2985
  pointer-events: none;
2968
2986
  position: absolute;
2987
+ margin: 0;
2969
2988
  }
2970
2989
 
2971
2990
  .ProseMirror-gapcursor:after {
@@ -3632,7 +3651,10 @@ class NodeView {
3632
3651
  // this is because ProseMirror can’t preventDispatch on enter
3633
3652
  // this will lead to a re-render of the node view on enter
3634
3653
  // see: https://github.com/ueberdosis/tiptap/issues/1214
3635
- if (this.dom.contains(mutation.target) && mutation.type === 'childList' && isiOS()) {
3654
+ if (this.dom.contains(mutation.target)
3655
+ && mutation.type === 'childList'
3656
+ && isiOS()
3657
+ && this.editor.isFocused) {
3636
3658
  const changedNodes = [
3637
3659
  ...Array.from(mutation.addedNodes),
3638
3660
  ...Array.from(mutation.removedNodes),