prosemirror-view 1.22.0 → 1.23.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/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.23.0 (2021-11-11)
2
+
3
+ ### Bug fixes
4
+
5
+ When parsing clipboard content, ignore trailing BR nodes that look like they might be there as a contenteditable kludge.
6
+
7
+ ### New features
8
+
9
+ `EditorView` now exposes an `isDestroyed` property that can be used to test if the view has been destroyed.
10
+
1
11
  ## 1.22.0 (2021-11-08)
2
12
 
3
13
  ### Bug fixes
package/dist/index.es.js CHANGED
@@ -2975,7 +2975,13 @@ function parseFromClipboard(view, text, html, plainText, $context) {
2975
2975
  var sliceData = contextNode && /^(\d+) (\d+) (.*)/.exec(contextNode.getAttribute("data-pm-slice"));
2976
2976
  if (!slice) {
2977
2977
  var parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
2978
- slice = parser.parseSlice(dom, {preserveWhitespace: !!(asText || sliceData), context: $context});
2978
+ slice = parser.parseSlice(dom, {
2979
+ preserveWhitespace: !!(asText || sliceData),
2980
+ context: $context,
2981
+ ruleFromNode: function ruleFromNode(dom) {
2982
+ if (dom.nodeName == "BR" && !dom.nextSibling) { return {ignore: true} }
2983
+ }
2984
+ });
2979
2985
  }
2980
2986
  if (sliceData) {
2981
2987
  slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]);
@@ -4261,7 +4267,7 @@ Decoration.prototype.map = function map (mapping, offset, oldOffset) {
4261
4267
  // key are interchangeable—if widgets differ in, for example,
4262
4268
  // the behavior of some event handler, they should get
4263
4269
  // different keys.
4264
- //
4270
+ //
4265
4271
  // destroy:: ?(node: dom.Node)
4266
4272
  // Called when the widget decoration is removed as a result of
4267
4273
  // mapping
@@ -4860,7 +4866,7 @@ var EditorView = function EditorView(place, props) {
4860
4866
  this.updatePluginViews();
4861
4867
  };
4862
4868
 
4863
- var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true } };
4869
+ var prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true },isDestroyed: { configurable: true } };
4864
4870
 
4865
4871
  // composing:: boolean
4866
4872
  // Holds `true` when a
@@ -5170,6 +5176,14 @@ EditorView.prototype.destroy = function destroy () {
5170
5176
  this.docView = null;
5171
5177
  };
5172
5178
 
5179
+ // :: boolean
5180
+ // This is true when the view has been
5181
+ // [destroyed](#view.EditorView.destroy) (and thus should not be
5182
+ // used anymore).
5183
+ prototypeAccessors$2.isDestroyed.get = function () {
5184
+ return this.docView == null
5185
+ };
5186
+
5173
5187
  // Used for testing.
5174
5188
  EditorView.prototype.dispatchEvent = function dispatchEvent$1 (event) {
5175
5189
  return dispatchEvent(this, event)