@tiptap/core 2.0.0-beta.93 → 2.0.0-beta.94
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/CHANGELOG.md +13 -0
- package/dist/packages/core/src/commands/insertContent.d.ts +2 -1
- package/dist/packages/core/src/commands/insertContentAt.d.ts +2 -1
- package/dist/tiptap-core.cjs.js +21 -8
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +21 -8
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +21 -8
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/Editor.ts +20 -6
- package/src/commands/insertContent.ts +4 -3
- package/src/commands/insertContentAt.ts +4 -3
package/dist/tiptap-core.esm.js
CHANGED
|
@@ -1395,8 +1395,8 @@ var forEach$1 = /*#__PURE__*/Object.freeze({
|
|
|
1395
1395
|
forEach: forEach
|
|
1396
1396
|
});
|
|
1397
1397
|
|
|
1398
|
-
const insertContent = value => ({ tr, commands }) => {
|
|
1399
|
-
return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value);
|
|
1398
|
+
const insertContent = (value, options) => ({ tr, commands }) => {
|
|
1399
|
+
return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options);
|
|
1400
1400
|
};
|
|
1401
1401
|
|
|
1402
1402
|
var insertContent$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -1424,12 +1424,13 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
1424
1424
|
tr.setSelection(Selection.near(tr.doc.resolve(end), bias));
|
|
1425
1425
|
}
|
|
1426
1426
|
|
|
1427
|
-
const insertContentAt = (position, value) => ({ tr, dispatch, editor }) => {
|
|
1427
|
+
const insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) => {
|
|
1428
1428
|
if (dispatch) {
|
|
1429
1429
|
const content = createNodeFromContent(value, editor.schema, {
|
|
1430
1430
|
parseOptions: {
|
|
1431
1431
|
preserveWhitespace: 'full',
|
|
1432
1432
|
},
|
|
1433
|
+
...(options || {}),
|
|
1433
1434
|
});
|
|
1434
1435
|
// don’t dispatch an empty fragment because this can lead to strange errors
|
|
1435
1436
|
if (content.toString() === '<>') {
|
|
@@ -2596,22 +2597,34 @@ class Editor extends EventEmitter {
|
|
|
2596
2597
|
* @param options A list of options
|
|
2597
2598
|
*/
|
|
2598
2599
|
setOptions(options = {}) {
|
|
2599
|
-
this.options = {
|
|
2600
|
+
this.options = {
|
|
2601
|
+
...this.options,
|
|
2602
|
+
...options,
|
|
2603
|
+
};
|
|
2604
|
+
if (!this.view || !this.state || this.isDestroyed) {
|
|
2605
|
+
return;
|
|
2606
|
+
}
|
|
2607
|
+
if (this.options.editorProps) {
|
|
2608
|
+
this.view.setProps(this.options.editorProps);
|
|
2609
|
+
}
|
|
2610
|
+
this.view.updateState(this.state);
|
|
2600
2611
|
}
|
|
2601
2612
|
/**
|
|
2602
2613
|
* Update editable state of the editor.
|
|
2603
2614
|
*/
|
|
2604
2615
|
setEditable(editable) {
|
|
2605
2616
|
this.setOptions({ editable });
|
|
2606
|
-
if (this.view && this.state && !this.isDestroyed) {
|
|
2607
|
-
this.view.updateState(this.state);
|
|
2608
|
-
}
|
|
2609
2617
|
}
|
|
2610
2618
|
/**
|
|
2611
2619
|
* Returns whether the editor is editable.
|
|
2612
2620
|
*/
|
|
2613
2621
|
get isEditable() {
|
|
2614
|
-
|
|
2622
|
+
// since plugins are applied after creating the view
|
|
2623
|
+
// `editable` is always `true` for one tick.
|
|
2624
|
+
// that’s why we also have to check for `options.editable`
|
|
2625
|
+
return this.options.editable
|
|
2626
|
+
&& this.view
|
|
2627
|
+
&& this.view.editable;
|
|
2615
2628
|
}
|
|
2616
2629
|
/**
|
|
2617
2630
|
* Returns the editor state.
|