@tiptap/core 3.4.4 → 3.4.5

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": "3.4.4",
4
+ "version": "3.4.5",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -52,10 +52,10 @@
52
52
  "jsx-dev-runtime"
53
53
  ],
54
54
  "devDependencies": {
55
- "@tiptap/pm": "^3.4.4"
55
+ "@tiptap/pm": "^3.4.5"
56
56
  },
57
57
  "peerDependencies": {
58
- "@tiptap/pm": "^3.4.4"
58
+ "@tiptap/pm": "^3.4.5"
59
59
  },
60
60
  "repository": {
61
61
  "type": "git",
package/src/Editor.ts CHANGED
@@ -160,6 +160,10 @@ export class Editor extends EventEmitter<EditorEvents> {
160
160
  this.createView(el)
161
161
  this.emit('mount', { editor: this })
162
162
 
163
+ if (this.css && !document.head.contains(this.css)) {
164
+ document.head.appendChild(this.css)
165
+ }
166
+
163
167
  window.setTimeout(() => {
164
168
  if (this.isDestroyed) {
165
169
  return
@@ -87,89 +87,87 @@ export class ExtensionManager {
87
87
  // based on the `priority` option.
88
88
  const extensions = sortExtensions([...this.extensions].reverse())
89
89
 
90
- const allPlugins = extensions
91
- .map(extension => {
92
- const context = {
93
- name: extension.name,
94
- options: extension.options,
95
- storage: this.editor.extensionStorage[extension.name as keyof Storage],
96
- editor,
97
- type: getSchemaTypeByName(extension.name, this.schema),
98
- }
90
+ const allPlugins = extensions.flatMap(extension => {
91
+ const context = {
92
+ name: extension.name,
93
+ options: extension.options,
94
+ storage: this.editor.extensionStorage[extension.name as keyof Storage],
95
+ editor,
96
+ type: getSchemaTypeByName(extension.name, this.schema),
97
+ }
99
98
 
100
- const plugins: Plugin[] = []
99
+ const plugins: Plugin[] = []
101
100
 
102
- const addKeyboardShortcuts = getExtensionField<AnyConfig['addKeyboardShortcuts']>(
103
- extension,
104
- 'addKeyboardShortcuts',
105
- context,
106
- )
101
+ const addKeyboardShortcuts = getExtensionField<AnyConfig['addKeyboardShortcuts']>(
102
+ extension,
103
+ 'addKeyboardShortcuts',
104
+ context,
105
+ )
107
106
 
108
- let defaultBindings: Record<string, () => boolean> = {}
107
+ let defaultBindings: Record<string, () => boolean> = {}
109
108
 
110
- // bind exit handling
111
- if (extension.type === 'mark' && getExtensionField<MarkConfig['exitable']>(extension, 'exitable', context)) {
112
- defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: extension as Mark })
113
- }
109
+ // bind exit handling
110
+ if (extension.type === 'mark' && getExtensionField<MarkConfig['exitable']>(extension, 'exitable', context)) {
111
+ defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: extension as Mark })
112
+ }
114
113
 
115
- if (addKeyboardShortcuts) {
116
- const bindings = Object.fromEntries(
117
- Object.entries(addKeyboardShortcuts()).map(([shortcut, method]) => {
118
- return [shortcut, () => method({ editor })]
119
- }),
120
- )
114
+ if (addKeyboardShortcuts) {
115
+ const bindings = Object.fromEntries(
116
+ Object.entries(addKeyboardShortcuts()).map(([shortcut, method]) => {
117
+ return [shortcut, () => method({ editor })]
118
+ }),
119
+ )
121
120
 
122
- defaultBindings = { ...defaultBindings, ...bindings }
123
- }
121
+ defaultBindings = { ...defaultBindings, ...bindings }
122
+ }
124
123
 
125
- const keyMapPlugin = keymap(defaultBindings)
124
+ const keyMapPlugin = keymap(defaultBindings)
126
125
 
127
- plugins.push(keyMapPlugin)
126
+ plugins.push(keyMapPlugin)
128
127
 
129
- const addInputRules = getExtensionField<AnyConfig['addInputRules']>(extension, 'addInputRules', context)
128
+ const addInputRules = getExtensionField<AnyConfig['addInputRules']>(extension, 'addInputRules', context)
130
129
 
131
- if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
132
- const rules = addInputRules()
130
+ if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
131
+ const rules = addInputRules()
133
132
 
134
- if (rules && rules.length) {
135
- const inputResult = inputRulesPlugin({
136
- editor,
137
- rules,
138
- })
133
+ if (rules && rules.length) {
134
+ const inputResult = inputRulesPlugin({
135
+ editor,
136
+ rules,
137
+ })
139
138
 
140
- const inputPlugins = Array.isArray(inputResult) ? inputResult : [inputResult]
139
+ const inputPlugins = Array.isArray(inputResult) ? inputResult : [inputResult]
141
140
 
142
- plugins.push(...inputPlugins)
143
- }
141
+ plugins.push(...inputPlugins)
144
142
  }
143
+ }
145
144
 
146
- const addPasteRules = getExtensionField<AnyConfig['addPasteRules']>(extension, 'addPasteRules', context)
145
+ const addPasteRules = getExtensionField<AnyConfig['addPasteRules']>(extension, 'addPasteRules', context)
147
146
 
148
- if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
149
- const rules = addPasteRules()
147
+ if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
148
+ const rules = addPasteRules()
150
149
 
151
- if (rules && rules.length) {
152
- const pasteRules = pasteRulesPlugin({ editor, rules })
150
+ if (rules && rules.length) {
151
+ const pasteRules = pasteRulesPlugin({ editor, rules })
153
152
 
154
- plugins.push(...pasteRules)
155
- }
153
+ plugins.push(...pasteRules)
156
154
  }
155
+ }
157
156
 
158
- const addProseMirrorPlugins = getExtensionField<AnyConfig['addProseMirrorPlugins']>(
159
- extension,
160
- 'addProseMirrorPlugins',
161
- context,
162
- )
157
+ const addProseMirrorPlugins = getExtensionField<AnyConfig['addProseMirrorPlugins']>(
158
+ extension,
159
+ 'addProseMirrorPlugins',
160
+ context,
161
+ )
163
162
 
164
- if (addProseMirrorPlugins) {
165
- const proseMirrorPlugins = addProseMirrorPlugins()
163
+ if (addProseMirrorPlugins) {
164
+ const proseMirrorPlugins = addProseMirrorPlugins()
166
165
 
167
- plugins.push(...proseMirrorPlugins)
168
- }
166
+ plugins.push(...proseMirrorPlugins)
167
+ }
169
168
 
170
- return plugins
171
- })
172
- .flat()
169
+ return plugins
170
+ })
173
171
 
174
172
  return allPlugins
175
173
  }