@tiptap/core 3.12.1 → 3.13.0
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.cjs +57 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -4
- package/dist/index.d.ts +100 -4
- package/dist/index.js +57 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/lib/ResizableNodeView.ts +122 -4
- package/src/utilities/markdown/createInlineMarkdownSpec.ts +51 -5
package/dist/index.cjs
CHANGED
|
@@ -5366,6 +5366,10 @@ var ResizableNodeView = class {
|
|
|
5366
5366
|
this.startHeight = 0;
|
|
5367
5367
|
/** Whether Shift key is currently pressed (for temporary aspect ratio lock) */
|
|
5368
5368
|
this.isShiftKeyPressed = false;
|
|
5369
|
+
/** Last known editable state of the editor */
|
|
5370
|
+
this.lastEditableState = void 0;
|
|
5371
|
+
/** Map of handle elements by direction */
|
|
5372
|
+
this.handleMap = /* @__PURE__ */ new Map();
|
|
5369
5373
|
/**
|
|
5370
5374
|
* Handles mouse movement during an active resize.
|
|
5371
5375
|
*
|
|
@@ -5442,8 +5446,9 @@ var ResizableNodeView = class {
|
|
|
5442
5446
|
this.isShiftKeyPressed = false;
|
|
5443
5447
|
}
|
|
5444
5448
|
};
|
|
5445
|
-
var _a, _b, _c, _d, _e;
|
|
5449
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5446
5450
|
this.node = options.node;
|
|
5451
|
+
this.editor = options.editor;
|
|
5447
5452
|
this.element = options.element;
|
|
5448
5453
|
this.contentElement = options.contentElement;
|
|
5449
5454
|
this.getPos = options.getPos;
|
|
@@ -5473,10 +5478,14 @@ var ResizableNodeView = class {
|
|
|
5473
5478
|
resizing: options.options.className.resizing || ""
|
|
5474
5479
|
};
|
|
5475
5480
|
}
|
|
5481
|
+
if ((_f = options.options) == null ? void 0 : _f.createCustomHandle) {
|
|
5482
|
+
this.createCustomHandle = options.options.createCustomHandle;
|
|
5483
|
+
}
|
|
5476
5484
|
this.wrapper = this.createWrapper();
|
|
5477
5485
|
this.container = this.createContainer();
|
|
5478
5486
|
this.applyInitialSize();
|
|
5479
5487
|
this.attachHandles();
|
|
5488
|
+
this.editor.on("update", this.handleEditorUpdate.bind(this));
|
|
5480
5489
|
}
|
|
5481
5490
|
/**
|
|
5482
5491
|
* Returns the top-level DOM node that should be placed in the editor.
|
|
@@ -5492,6 +5501,18 @@ var ResizableNodeView = class {
|
|
|
5492
5501
|
get contentDOM() {
|
|
5493
5502
|
return this.contentElement;
|
|
5494
5503
|
}
|
|
5504
|
+
handleEditorUpdate() {
|
|
5505
|
+
const isEditable = this.editor.isEditable;
|
|
5506
|
+
if (isEditable === this.lastEditableState) {
|
|
5507
|
+
return;
|
|
5508
|
+
}
|
|
5509
|
+
this.lastEditableState = isEditable;
|
|
5510
|
+
if (!isEditable) {
|
|
5511
|
+
this.removeHandles();
|
|
5512
|
+
} else if (isEditable && this.handleMap.size === 0) {
|
|
5513
|
+
this.attachHandles();
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5495
5516
|
/**
|
|
5496
5517
|
* Called when the node's content or attributes change.
|
|
5497
5518
|
*
|
|
@@ -5533,6 +5554,7 @@ var ResizableNodeView = class {
|
|
|
5533
5554
|
this.isResizing = false;
|
|
5534
5555
|
this.activeHandle = null;
|
|
5535
5556
|
}
|
|
5557
|
+
this.editor.off("update", this.handleEditorUpdate.bind(this));
|
|
5536
5558
|
this.container.remove();
|
|
5537
5559
|
}
|
|
5538
5560
|
/**
|
|
@@ -5549,8 +5571,6 @@ var ResizableNodeView = class {
|
|
|
5549
5571
|
element.dataset.resizeContainer = "";
|
|
5550
5572
|
element.dataset.node = this.node.type.name;
|
|
5551
5573
|
element.style.display = "flex";
|
|
5552
|
-
element.style.justifyContent = "flex-start";
|
|
5553
|
-
element.style.alignItems = "flex-start";
|
|
5554
5574
|
if (this.classNames.container) {
|
|
5555
5575
|
element.className = this.classNames.container;
|
|
5556
5576
|
}
|
|
@@ -5638,13 +5658,36 @@ var ResizableNodeView = class {
|
|
|
5638
5658
|
*/
|
|
5639
5659
|
attachHandles() {
|
|
5640
5660
|
this.directions.forEach((direction) => {
|
|
5641
|
-
|
|
5642
|
-
this.
|
|
5661
|
+
let handle;
|
|
5662
|
+
if (this.createCustomHandle) {
|
|
5663
|
+
handle = this.createCustomHandle(direction);
|
|
5664
|
+
} else {
|
|
5665
|
+
handle = this.createHandle(direction);
|
|
5666
|
+
}
|
|
5667
|
+
if (!(handle instanceof HTMLElement)) {
|
|
5668
|
+
console.warn(
|
|
5669
|
+
`[ResizableNodeView] createCustomHandle("${direction}") did not return an HTMLElement. Falling back to default handle.`
|
|
5670
|
+
);
|
|
5671
|
+
handle = this.createHandle(direction);
|
|
5672
|
+
}
|
|
5673
|
+
if (!this.createCustomHandle) {
|
|
5674
|
+
this.positionHandle(handle, direction);
|
|
5675
|
+
}
|
|
5643
5676
|
handle.addEventListener("mousedown", (event) => this.handleResizeStart(event, direction));
|
|
5644
5677
|
handle.addEventListener("touchstart", (event) => this.handleResizeStart(event, direction));
|
|
5678
|
+
this.handleMap.set(direction, handle);
|
|
5645
5679
|
this.wrapper.appendChild(handle);
|
|
5646
5680
|
});
|
|
5647
5681
|
}
|
|
5682
|
+
/**
|
|
5683
|
+
* Removes all resize handles from the wrapper.
|
|
5684
|
+
*
|
|
5685
|
+
* Cleans up the handle map and removes each handle element from the DOM.
|
|
5686
|
+
*/
|
|
5687
|
+
removeHandles() {
|
|
5688
|
+
this.handleMap.forEach((el) => el.remove());
|
|
5689
|
+
this.handleMap.clear();
|
|
5690
|
+
}
|
|
5648
5691
|
/**
|
|
5649
5692
|
* Applies initial sizing from node attributes to the element.
|
|
5650
5693
|
*
|
|
@@ -6191,9 +6234,15 @@ function createInlineMarkdownSpec(options) {
|
|
|
6191
6234
|
return attrs;
|
|
6192
6235
|
}
|
|
6193
6236
|
const filtered = {};
|
|
6194
|
-
allowedAttributes.forEach((
|
|
6195
|
-
|
|
6196
|
-
|
|
6237
|
+
allowedAttributes.forEach((attr) => {
|
|
6238
|
+
const attrName = typeof attr === "string" ? attr : attr.name;
|
|
6239
|
+
const skipIfDefault = typeof attr === "string" ? void 0 : attr.skipIfDefault;
|
|
6240
|
+
if (attrName in attrs) {
|
|
6241
|
+
const value = attrs[attrName];
|
|
6242
|
+
if (skipIfDefault !== void 0 && value === skipIfDefault) {
|
|
6243
|
+
return;
|
|
6244
|
+
}
|
|
6245
|
+
filtered[attrName] = value;
|
|
6197
6246
|
}
|
|
6198
6247
|
});
|
|
6199
6248
|
return filtered;
|