@tiptap/core 3.3.1 → 3.4.1

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/dist/index.d.cts CHANGED
@@ -880,6 +880,18 @@ type RemoveThis<T> = T extends (...args: any) => any ? (...args: Parameters<T>)
880
880
  type MaybeReturnType<T> = T extends (...args: any) => any ? ReturnType<T> : T;
881
881
  type MaybeThisParameterType<T> = Exclude<T, Primitive> extends (...args: any) => any ? ThisParameterType<Exclude<T, Primitive>> : any;
882
882
  interface EditorEvents {
883
+ mount: {
884
+ /**
885
+ * The editor instance
886
+ */
887
+ editor: Editor;
888
+ };
889
+ unmount: {
890
+ /**
891
+ * The editor instance
892
+ */
893
+ editor: Editor;
894
+ };
883
895
  beforeCreate: {
884
896
  /**
885
897
  * The editor instance
@@ -1192,6 +1204,14 @@ interface EditorOptions {
1192
1204
  * Called after the editor is constructed.
1193
1205
  */
1194
1206
  onCreate: (props: EditorEvents['create']) => void;
1207
+ /**
1208
+ * Called when the editor is mounted.
1209
+ */
1210
+ onMount: (props: EditorEvents['mount']) => void;
1211
+ /**
1212
+ * Called when the editor is unmounted.
1213
+ */
1214
+ onUnmount: (props: EditorEvents['unmount']) => void;
1195
1215
  /**
1196
1216
  * Called when the editor encounters an error while parsing the content.
1197
1217
  * Only enabled if `enableContentCheck` is `true`.
package/dist/index.d.ts CHANGED
@@ -880,6 +880,18 @@ type RemoveThis<T> = T extends (...args: any) => any ? (...args: Parameters<T>)
880
880
  type MaybeReturnType<T> = T extends (...args: any) => any ? ReturnType<T> : T;
881
881
  type MaybeThisParameterType<T> = Exclude<T, Primitive> extends (...args: any) => any ? ThisParameterType<Exclude<T, Primitive>> : any;
882
882
  interface EditorEvents {
883
+ mount: {
884
+ /**
885
+ * The editor instance
886
+ */
887
+ editor: Editor;
888
+ };
889
+ unmount: {
890
+ /**
891
+ * The editor instance
892
+ */
893
+ editor: Editor;
894
+ };
883
895
  beforeCreate: {
884
896
  /**
885
897
  * The editor instance
@@ -1192,6 +1204,14 @@ interface EditorOptions {
1192
1204
  * Called after the editor is constructed.
1193
1205
  */
1194
1206
  onCreate: (props: EditorEvents['create']) => void;
1207
+ /**
1208
+ * Called when the editor is mounted.
1209
+ */
1210
+ onMount: (props: EditorEvents['mount']) => void;
1211
+ /**
1212
+ * Called when the editor is unmounted.
1213
+ */
1214
+ onUnmount: (props: EditorEvents['unmount']) => void;
1195
1215
  /**
1196
1216
  * Called when the editor encounters an error while parsing the content.
1197
1217
  * Only enabled if `enableContentCheck` is `true`.
package/dist/index.js CHANGED
@@ -3127,7 +3127,8 @@ function canSetMark(state, tr, newMarkType) {
3127
3127
  }
3128
3128
  if (cursor) {
3129
3129
  const currentMarks = (_a = state.storedMarks) != null ? _a : cursor.marks();
3130
- return !!newMarkType.isInSet(currentMarks) || !currentMarks.some((mark) => mark.type.excludes(newMarkType));
3130
+ const parentAllowsMarkType = cursor.parent.type.allowsMarkType(newMarkType);
3131
+ return parentAllowsMarkType && (!!newMarkType.isInSet(currentMarks) || !currentMarks.some((mark) => mark.type.excludes(newMarkType)));
3131
3132
  }
3132
3133
  const { ranges } = selection;
3133
3134
  return ranges.some(({ $from, $to }) => {
@@ -4310,6 +4311,8 @@ var Editor = class extends EventEmitter {
4310
4311
  emitContentError: false,
4311
4312
  onBeforeCreate: () => null,
4312
4313
  onCreate: () => null,
4314
+ onMount: () => null,
4315
+ onUnmount: () => null,
4313
4316
  onUpdate: () => null,
4314
4317
  onSelectionUpdate: () => null,
4315
4318
  onTransaction: () => null,
@@ -4331,6 +4334,8 @@ var Editor = class extends EventEmitter {
4331
4334
  this.createSchema();
4332
4335
  this.on("beforeCreate", this.options.onBeforeCreate);
4333
4336
  this.emit("beforeCreate", { editor: this });
4337
+ this.on("mount", this.options.onMount);
4338
+ this.on("unmount", this.options.onUnmount);
4334
4339
  this.on("contentError", this.options.onContentError);
4335
4340
  this.on("create", this.options.onCreate);
4336
4341
  this.on("update", this.options.onUpdate);
@@ -4363,6 +4368,7 @@ var Editor = class extends EventEmitter {
4363
4368
  );
4364
4369
  }
4365
4370
  this.createView(el);
4371
+ this.emit("mount", { editor: this });
4366
4372
  window.setTimeout(() => {
4367
4373
  if (this.isDestroyed) {
4368
4374
  return;
@@ -4397,6 +4403,7 @@ var Editor = class extends EventEmitter {
4397
4403
  }
4398
4404
  }
4399
4405
  this.css = null;
4406
+ this.emit("unmount", { editor: this });
4400
4407
  }
4401
4408
  /**
4402
4409
  * Returns the editor storage.