@tiptap/core 3.4.4 → 3.4.6
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 +25 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +25 -13
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Editor.ts +4 -0
- package/src/ExtensionManager.ts +58 -60
- package/src/InputRule.ts +12 -6
- package/src/inputRules/markInputRule.ts +2 -0
- package/src/inputRules/nodeInputRule.ts +7 -0
- package/src/inputRules/textInputRule.ts +2 -1
- package/src/inputRules/textblockTypeInputRule.ts +2 -0
- package/src/inputRules/wrappingInputRule.ts +2 -0
package/dist/index.cjs
CHANGED
|
@@ -1689,8 +1689,10 @@ var import_model7 = require("@tiptap/pm/model");
|
|
|
1689
1689
|
var import_state5 = require("@tiptap/pm/state");
|
|
1690
1690
|
var InputRule = class {
|
|
1691
1691
|
constructor(config) {
|
|
1692
|
+
var _a;
|
|
1692
1693
|
this.find = config.find;
|
|
1693
1694
|
this.handler = config.handler;
|
|
1695
|
+
this.undoable = (_a = config.undoable) != null ? _a : true;
|
|
1694
1696
|
}
|
|
1695
1697
|
};
|
|
1696
1698
|
var inputRuleMatcherHandler = (text, find) => {
|
|
@@ -1762,12 +1764,14 @@ function run(config) {
|
|
|
1762
1764
|
if (handler === null || !tr.steps.length) {
|
|
1763
1765
|
return;
|
|
1764
1766
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1767
|
+
if (rule.undoable) {
|
|
1768
|
+
tr.setMeta(plugin, {
|
|
1769
|
+
transform: tr,
|
|
1770
|
+
from,
|
|
1771
|
+
to,
|
|
1772
|
+
text
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1771
1775
|
view.dispatch(tr);
|
|
1772
1776
|
matched = true;
|
|
1773
1777
|
});
|
|
@@ -2262,7 +2266,7 @@ var ExtensionManager = class {
|
|
|
2262
2266
|
get plugins() {
|
|
2263
2267
|
const { editor } = this;
|
|
2264
2268
|
const extensions = sortExtensions([...this.extensions].reverse());
|
|
2265
|
-
const allPlugins = extensions.
|
|
2269
|
+
const allPlugins = extensions.flatMap((extension) => {
|
|
2266
2270
|
const context = {
|
|
2267
2271
|
name: extension.name,
|
|
2268
2272
|
options: extension.options,
|
|
@@ -2320,7 +2324,7 @@ var ExtensionManager = class {
|
|
|
2320
2324
|
plugins.push(...proseMirrorPlugins);
|
|
2321
2325
|
}
|
|
2322
2326
|
return plugins;
|
|
2323
|
-
})
|
|
2327
|
+
});
|
|
2324
2328
|
return allPlugins;
|
|
2325
2329
|
}
|
|
2326
2330
|
/**
|
|
@@ -4486,6 +4490,9 @@ var Editor = class extends EventEmitter {
|
|
|
4486
4490
|
}
|
|
4487
4491
|
this.createView(el);
|
|
4488
4492
|
this.emit("mount", { editor: this });
|
|
4493
|
+
if (this.css && !document.head.contains(this.css)) {
|
|
4494
|
+
document.head.appendChild(this.css);
|
|
4495
|
+
}
|
|
4489
4496
|
window.setTimeout(() => {
|
|
4490
4497
|
if (this.isDestroyed) {
|
|
4491
4498
|
return;
|
|
@@ -4975,7 +4982,8 @@ function markInputRule(config) {
|
|
|
4975
4982
|
tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
|
|
4976
4983
|
tr.removeStoredMark(config.type);
|
|
4977
4984
|
}
|
|
4978
|
-
}
|
|
4985
|
+
},
|
|
4986
|
+
undoable: config.undoable
|
|
4979
4987
|
});
|
|
4980
4988
|
}
|
|
4981
4989
|
|
|
@@ -5005,7 +5013,8 @@ function nodeInputRule(config) {
|
|
|
5005
5013
|
tr.insert(insertionStart, config.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end));
|
|
5006
5014
|
}
|
|
5007
5015
|
tr.scrollIntoView();
|
|
5008
|
-
}
|
|
5016
|
+
},
|
|
5017
|
+
undoable: config.undoable
|
|
5009
5018
|
});
|
|
5010
5019
|
}
|
|
5011
5020
|
|
|
@@ -5020,7 +5029,8 @@ function textblockTypeInputRule(config) {
|
|
|
5020
5029
|
return null;
|
|
5021
5030
|
}
|
|
5022
5031
|
state.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
|
|
5023
|
-
}
|
|
5032
|
+
},
|
|
5033
|
+
undoable: config.undoable
|
|
5024
5034
|
});
|
|
5025
5035
|
}
|
|
5026
5036
|
|
|
@@ -5043,7 +5053,8 @@ function textInputRule(config) {
|
|
|
5043
5053
|
}
|
|
5044
5054
|
}
|
|
5045
5055
|
state.tr.insertText(insert, start, end);
|
|
5046
|
-
}
|
|
5056
|
+
},
|
|
5057
|
+
undoable: config.undoable
|
|
5047
5058
|
});
|
|
5048
5059
|
}
|
|
5049
5060
|
|
|
@@ -5079,7 +5090,8 @@ function wrappingInputRule(config) {
|
|
|
5079
5090
|
if (before && before.type === config.type && (0, import_transform10.canJoin)(tr.doc, range.from - 1) && (!config.joinPredicate || config.joinPredicate(match, before))) {
|
|
5080
5091
|
tr.join(range.from - 1);
|
|
5081
5092
|
}
|
|
5082
|
-
}
|
|
5093
|
+
},
|
|
5094
|
+
undoable: config.undoable
|
|
5083
5095
|
});
|
|
5084
5096
|
}
|
|
5085
5097
|
|