@progress/kendo-editor-common 1.9.6-dev.202305301645 → 1.9.6-dev.202305311245

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.
@@ -64,7 +64,7 @@ var marks = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__ass
64
64
  inclusive: false,
65
65
  parseDOM: [{ tag: 'a', getAttrs: domAttributes }],
66
66
  toDOM: function (node) { return ['a', pmAttributes(node.attrs), hole]; }
67
- } }, tagMark('strong')), tagMark('b')), tagMark('em')), tagMark('i')), tagMark('u')), tagMark('del')), tagMark('sub')), tagMark('sup')), tagMark('code')), { style: {
67
+ } }, tagMark('strong')), tagMark('b')), tagMark('em')), tagMark('i')), tagMark('del')), tagMark('sub')), tagMark('sup')), tagMark('code')), { style: {
68
68
  attrs: __assign({}, commonAttributes()),
69
69
  parseDOM: [{
70
70
  tag: 'span',
@@ -72,7 +72,7 @@ var marks = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__ass
72
72
  }],
73
73
  toDOM: function (node) { return hasAttrs(node.attrs) ?
74
74
  ['span', pmAttributes(node.attrs), hole] : ['span', hole]; }
75
- } });
75
+ } }), tagMark('u'));
76
76
  var cellAttribute = function (name) {
77
77
  var _a;
78
78
  return _a = {},
package/dist/es/source.js CHANGED
@@ -99,7 +99,7 @@ export var htmlToFragment = function (html) {
99
99
  * @hidden
100
100
  */
101
101
  export var fragmentToHtml = function (fragment) {
102
- return Array.from(fragment.children).reduce(function (acc, cur) { return acc + (cur.outerHTML || cur.textContent || ''); }, '');
102
+ return Array.from(fragment.childNodes).reduce(function (acc, cur) { return acc + (cur.outerHTML || cur.textContent || ''); }, '');
103
103
  };
104
104
  /**
105
105
  * Creates a DocumentFragment from the given ProseMirrorNode.
package/dist/es/utils.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { __assign } from "tslib";
1
2
  import { Node, Fragment } from 'prosemirror-model';
2
3
  import { TextSelection, AllSelection, NodeSelection } from 'prosemirror-state';
3
4
  import { parseContent } from './source';
@@ -58,11 +59,29 @@ export var findNthParentNodeOfType = function (nodeType, depth) {
58
59
  return findNthParentNode(function (node) { return getTypeName(node) === getTypeName(nodeType); }, depth)(selection);
59
60
  };
60
61
  };
62
+ var filterEmptyAttrs = function (attrs) {
63
+ var result = {};
64
+ for (var attr in attrs) {
65
+ if (attr && (attrs[attr] || attrs[attr] === 0)) {
66
+ result[attr] = attrs[attr];
67
+ }
68
+ }
69
+ return result;
70
+ };
61
71
  /**
62
72
  * Inserts the given node at the place of current selection.
63
73
  */
64
74
  export var insertNode = function (node, scrollIntoView) { return function (state, dispatch) {
65
- var tr = state.tr.replaceSelectionWith(node);
75
+ var selection = state.selection, tr = state.tr;
76
+ if (selection instanceof NodeSelection
77
+ && selection.node.type.name === node.type.name
78
+ && node.isLeaf && !node.isText && node.nodeSize === 1) {
79
+ tr.setNodeMarkup(selection.from, null, __assign(__assign({}, filterEmptyAttrs(selection.node.attrs)), filterEmptyAttrs(node.attrs)));
80
+ tr.setSelection(NodeSelection.create(tr.doc, selection.from));
81
+ }
82
+ else {
83
+ tr.replaceSelectionWith(node);
84
+ }
66
85
  if (scrollIntoView) {
67
86
  tr.scrollIntoView();
68
87
  }
@@ -58,7 +58,7 @@ const marks = Object.assign(Object.assign(Object.assign(Object.assign(Object.ass
58
58
  inclusive: false,
59
59
  parseDOM: [{ tag: 'a', getAttrs: domAttributes }],
60
60
  toDOM: (node) => ['a', pmAttributes(node.attrs), hole]
61
- } }, tagMark('strong')), tagMark('b')), tagMark('em')), tagMark('i')), tagMark('u')), tagMark('del')), tagMark('sub')), tagMark('sup')), tagMark('code')), { style: {
61
+ } }, tagMark('strong')), tagMark('b')), tagMark('em')), tagMark('i')), tagMark('del')), tagMark('sub')), tagMark('sup')), tagMark('code')), { style: {
62
62
  attrs: Object.assign({}, commonAttributes()),
63
63
  parseDOM: [{
64
64
  tag: 'span',
@@ -66,7 +66,7 @@ const marks = Object.assign(Object.assign(Object.assign(Object.assign(Object.ass
66
66
  }],
67
67
  toDOM: node => hasAttrs(node.attrs) ?
68
68
  ['span', pmAttributes(node.attrs), hole] : ['span', hole]
69
- } });
69
+ } }), tagMark('u'));
70
70
  const cellAttribute = (name) => {
71
71
  return {
72
72
  [name]: {
@@ -98,7 +98,7 @@ export const htmlToFragment = (html) => {
98
98
  * @hidden
99
99
  */
100
100
  export const fragmentToHtml = (fragment) => {
101
- return Array.from(fragment.children).reduce((acc, cur) => acc + (cur.outerHTML || cur.textContent || ''), '');
101
+ return Array.from(fragment.childNodes).reduce((acc, cur) => acc + (cur.outerHTML || cur.textContent || ''), '');
102
102
  };
103
103
  /**
104
104
  * Creates a DocumentFragment from the given ProseMirrorNode.
@@ -56,11 +56,29 @@ export const findNthParentNodeOfType = (nodeType, depth = 1) => {
56
56
  return findNthParentNode((node) => getTypeName(node) === getTypeName(nodeType), depth)(selection);
57
57
  };
58
58
  };
59
+ const filterEmptyAttrs = (attrs) => {
60
+ const result = {};
61
+ for (let attr in attrs) {
62
+ if (attr && (attrs[attr] || attrs[attr] === 0)) {
63
+ result[attr] = attrs[attr];
64
+ }
65
+ }
66
+ return result;
67
+ };
59
68
  /**
60
69
  * Inserts the given node at the place of current selection.
61
70
  */
62
71
  export const insertNode = (node, scrollIntoView) => (state, dispatch) => {
63
- const tr = state.tr.replaceSelectionWith(node);
72
+ const { selection, tr } = state;
73
+ if (selection instanceof NodeSelection
74
+ && selection.node.type.name === node.type.name
75
+ && node.isLeaf && !node.isText && node.nodeSize === 1) {
76
+ tr.setNodeMarkup(selection.from, null, Object.assign(Object.assign({}, filterEmptyAttrs(selection.node.attrs)), filterEmptyAttrs(node.attrs)));
77
+ tr.setSelection(NodeSelection.create(tr.doc, selection.from));
78
+ }
79
+ else {
80
+ tr.replaceSelectionWith(node);
81
+ }
64
82
  if (scrollIntoView) {
65
83
  tr.scrollIntoView();
66
84
  }
@@ -67,7 +67,7 @@ var marks = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(
67
67
  inclusive: false,
68
68
  parseDOM: [{ tag: 'a', getAttrs: domAttributes }],
69
69
  toDOM: function (node) { return ['a', pmAttributes(node.attrs), hole]; }
70
- } }, tagMark('strong')), tagMark('b')), tagMark('em')), tagMark('i')), tagMark('u')), tagMark('del')), tagMark('sub')), tagMark('sup')), tagMark('code')), { style: {
70
+ } }, tagMark('strong')), tagMark('b')), tagMark('em')), tagMark('i')), tagMark('del')), tagMark('sub')), tagMark('sup')), tagMark('code')), { style: {
71
71
  attrs: tslib_1.__assign({}, commonAttributes()),
72
72
  parseDOM: [{
73
73
  tag: 'span',
@@ -75,7 +75,7 @@ var marks = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(
75
75
  }],
76
76
  toDOM: function (node) { return hasAttrs(node.attrs) ?
77
77
  ['span', pmAttributes(node.attrs), hole] : ['span', hole]; }
78
- } });
78
+ } }), tagMark('u'));
79
79
  exports.marks = marks;
80
80
  var cellAttribute = function (name) {
81
81
  var _a;
@@ -104,7 +104,7 @@ exports.htmlToFragment = htmlToFragment;
104
104
  * @hidden
105
105
  */
106
106
  var fragmentToHtml = function (fragment) {
107
- return Array.from(fragment.children).reduce(function (acc, cur) { return acc + (cur.outerHTML || cur.textContent || ''); }, '');
107
+ return Array.from(fragment.childNodes).reduce(function (acc, cur) { return acc + (cur.outerHTML || cur.textContent || ''); }, '');
108
108
  };
109
109
  exports.fragmentToHtml = fragmentToHtml;
110
110
  /**
package/dist/npm/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expandToWordWrap = exports.expandSelection = exports.shallowEqual = exports.indentHtml = exports.selectedLineTextOnly = exports.getNodeFromSelection = exports.getSelectionText = exports.hasSameMarkup = exports.insertNode = exports.findNthParentNodeOfType = exports.canInsert = exports.changeStylesString = void 0;
4
+ var tslib_1 = require("tslib");
4
5
  var prosemirror_model_1 = require("prosemirror-model");
5
6
  var prosemirror_state_1 = require("prosemirror-state");
6
7
  var source_1 = require("./source");
@@ -64,11 +65,29 @@ var findNthParentNodeOfType = function (nodeType, depth) {
64
65
  };
65
66
  };
66
67
  exports.findNthParentNodeOfType = findNthParentNodeOfType;
68
+ var filterEmptyAttrs = function (attrs) {
69
+ var result = {};
70
+ for (var attr in attrs) {
71
+ if (attr && (attrs[attr] || attrs[attr] === 0)) {
72
+ result[attr] = attrs[attr];
73
+ }
74
+ }
75
+ return result;
76
+ };
67
77
  /**
68
78
  * Inserts the given node at the place of current selection.
69
79
  */
70
80
  var insertNode = function (node, scrollIntoView) { return function (state, dispatch) {
71
- var tr = state.tr.replaceSelectionWith(node);
81
+ var selection = state.selection, tr = state.tr;
82
+ if (selection instanceof prosemirror_state_1.NodeSelection
83
+ && selection.node.type.name === node.type.name
84
+ && node.isLeaf && !node.isText && node.nodeSize === 1) {
85
+ tr.setNodeMarkup(selection.from, null, tslib_1.__assign(tslib_1.__assign({}, filterEmptyAttrs(selection.node.attrs)), filterEmptyAttrs(node.attrs)));
86
+ tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, selection.from));
87
+ }
88
+ else {
89
+ tr.replaceSelectionWith(node);
90
+ }
72
91
  if (scrollIntoView) {
73
92
  tr.scrollIntoView();
74
93
  }