@tiptap/core 2.0.0-beta.139 → 2.0.0-beta.142

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/core",
3
3
  "description": "headless rich text editor",
4
- "version": "2.0.0-beta.139",
4
+ "version": "2.0.0-beta.142",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -44,5 +44,5 @@
44
44
  "url": "https://github.com/ueberdosis/tiptap",
45
45
  "directory": "packages/core"
46
46
  },
47
- "gitHead": "abe932384ce5fe14d3c0acb984978bbf2cf1f594"
47
+ "gitHead": "7c5223fc926e27a231190e0c8ad1b8351768375c"
48
48
  }
@@ -13,6 +13,7 @@ import getNodeType from './helpers/getNodeType'
13
13
  import splitExtensions from './helpers/splitExtensions'
14
14
  import getAttributesFromExtensions from './helpers/getAttributesFromExtensions'
15
15
  import getRenderedAttributes from './helpers/getRenderedAttributes'
16
+ import isExtensionRulesEnabled from './helpers/isExtensionRulesEnabled'
16
17
  import callOrReturn from './utilities/callOrReturn'
17
18
  import findDuplicates from './utilities/findDuplicates'
18
19
  import { NodeConfig } from '.'
@@ -270,7 +271,7 @@ export default class ExtensionManager {
270
271
  context,
271
272
  )
272
273
 
273
- if (editor.options.enableInputRules && addInputRules) {
274
+ if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
274
275
  inputRules.push(...addInputRules())
275
276
  }
276
277
 
@@ -280,7 +281,7 @@ export default class ExtensionManager {
280
281
  context,
281
282
  )
282
283
 
283
- if (editor.options.enablePasteRules && addPasteRules) {
284
+ if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
284
285
  pasteRules.push(...addPasteRules())
285
286
  }
286
287
 
package/src/NodeView.ts CHANGED
@@ -202,7 +202,12 @@ export class NodeView<
202
202
  // this is because ProseMirror can’t preventDispatch on enter
203
203
  // this will lead to a re-render of the node view on enter
204
204
  // see: https://github.com/ueberdosis/tiptap/issues/1214
205
- if (this.dom.contains(mutation.target) && mutation.type === 'childList' && isiOS()) {
205
+ if (
206
+ this.dom.contains(mutation.target)
207
+ && mutation.type === 'childList'
208
+ && isiOS()
209
+ && this.editor.isFocused
210
+ ) {
206
211
  const changedNodes = [
207
212
  ...Array.from(mutation.addedNodes),
208
213
  ...Array.from(mutation.removedNodes),
@@ -16,15 +16,22 @@ function resolveSelection(state: EditorState, position: FocusPosition = null) {
16
16
  }
17
17
  }
18
18
 
19
- if (position === 'end') {
20
- const { size } = state.doc.content
19
+ const { size } = state.doc.content
21
20
 
21
+ if (position === 'end') {
22
22
  return {
23
23
  from: size,
24
24
  to: size,
25
25
  }
26
26
  }
27
27
 
28
+ if (position === 'all') {
29
+ return {
30
+ from: 0,
31
+ to: size,
32
+ }
33
+ }
34
+
28
35
  return {
29
36
  from: position,
30
37
  to: position,
@@ -0,0 +1,13 @@
1
+ import { ContentMatch, NodeType } from 'prosemirror-model'
2
+
3
+ export default function defaultBlockAt(match: ContentMatch): NodeType | null {
4
+ for (let i = 0; i < match.edgeCount; i += 1) {
5
+ const { type } = match.edge(i)
6
+
7
+ if (type.isTextblock && !type.hasRequiredAttrs()) {
8
+ return type
9
+ }
10
+ }
11
+
12
+ return null
13
+ }
@@ -0,0 +1,15 @@
1
+ import { AnyExtension, EnableRules } from '../types'
2
+
3
+ export default function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean {
4
+ if (Array.isArray(enabled)) {
5
+ return enabled.some(enabledExtension => {
6
+ const name = typeof enabledExtension === 'string'
7
+ ? enabledExtension
8
+ : enabledExtension.name
9
+
10
+ return name === extension.name
11
+ })
12
+ }
13
+
14
+ return enabled
15
+ }
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export { default as textPasteRule } from './pasteRules/textPasteRule'
23
23
  export { default as callOrReturn } from './utilities/callOrReturn'
24
24
  export { default as mergeAttributes } from './utilities/mergeAttributes'
25
25
 
26
+ export { default as defaultBlockAt } from './helpers/defaultBlockAt'
26
27
  export { default as getExtensionField } from './helpers/getExtensionField'
27
28
  export { default as findChildren } from './helpers/findChildren'
28
29
  export { default as findChildrenInRange } from './helpers/findChildrenInRange'
package/src/style.ts CHANGED
@@ -35,6 +35,7 @@ img.ProseMirror-separator {
35
35
  display: none;
36
36
  pointer-events: none;
37
37
  position: absolute;
38
+ margin: 0;
38
39
  }
39
40
 
40
41
  .ProseMirror-gapcursor:after {
package/src/types.ts CHANGED
@@ -63,6 +63,8 @@ export interface EditorEvents {
63
63
  destroy: void,
64
64
  }
65
65
 
66
+ export type EnableRules = (AnyExtension | string)[] | boolean
67
+
66
68
  export interface EditorOptions {
67
69
  element: Element,
68
70
  content: Content,
@@ -72,8 +74,8 @@ export interface EditorOptions {
72
74
  editable: boolean,
73
75
  editorProps: EditorProps,
74
76
  parseOptions: ParseOptions,
75
- enableInputRules: boolean,
76
- enablePasteRules: boolean,
77
+ enableInputRules: EnableRules,
78
+ enablePasteRules: EnableRules,
77
79
  enableCoreExtensions: boolean,
78
80
  onBeforeCreate: (props: EditorEvents['beforeCreate']) => void,
79
81
  onCreate: (props: EditorEvents['create']) => void,
@@ -210,7 +212,7 @@ export type ChainedCommands = {
210
212
 
211
213
  export type CanCommands = SingleCommands & { chain: () => ChainedCommands }
212
214
 
213
- export type FocusPosition = 'start' | 'end' | number | boolean | null
215
+ export type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null
214
216
 
215
217
  export type Range = {
216
218
  from: number,