@progress/kendo-editor-common 1.11.7 → 1.11.8-dev.202411010906

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/es/source.js CHANGED
@@ -2,6 +2,7 @@ import { DOMParser as ProseMirrorDOMParser } from 'prosemirror-model';
2
2
  import { AllSelection } from 'prosemirror-state';
3
3
  import { rowTypeAttr, colgroupAttr } from './config/constants';
4
4
  import { DOMSerializer } from './DOMSerializer';
5
+ import { setStyleAttr } from './utils';
5
6
  var blockWrappers = [
6
7
  'div', 'ol', 'ul', 'li', 'table', 'tbody', 'thead', 'tfoot', 'caption', 'td', 'th', 'p',
7
8
  'tr', 'col', 'colgroup', 'article', 'main', 'nav', 'header', 'footer', 'aside', 'section'
@@ -139,17 +140,11 @@ var replacer = function (match) {
139
140
  var replaceStyleAttr = function (html) {
140
141
  return html.replace(reTag, replacer);
141
142
  };
142
- var applyStyle = function (styleString, element) {
143
- return styleString.split(';').filter(function (s) { return s.trim() !== ''; }).forEach(function (s) {
144
- var parts = s.split(':');
145
- element.style[parts[0].trim()] = parts[1].trim();
146
- });
147
- };
148
143
  var restoreStyleAttr = function (container) {
149
144
  Array.from(container.querySelectorAll('[' + styleAttr + ']')).forEach(function (element) {
150
145
  var styleString = element.getAttribute(styleAttr);
151
146
  element.removeAttribute(styleAttr);
152
- applyStyle(styleString, element);
147
+ setStyleAttr(element, styleString);
153
148
  });
154
149
  };
155
150
  /**
package/dist/es/utils.js CHANGED
@@ -273,7 +273,7 @@ export var applyStyle = function (styleText, styleType, styleValue) {
273
273
  .join('; ');
274
274
  return result ? result + ';' : null;
275
275
  };
276
- var setStyleAttr = function (element, styleString) {
276
+ export var setStyleAttr = function (element, styleString) {
277
277
  var styles = parseStyle(styleString);
278
278
  for (var style in styles) {
279
279
  if (style && typeof element.style[style] !== 'undefined') {
@@ -2,6 +2,7 @@ import { DOMParser as ProseMirrorDOMParser } from 'prosemirror-model';
2
2
  import { AllSelection } from 'prosemirror-state';
3
3
  import { rowTypeAttr, colgroupAttr } from './config/constants';
4
4
  import { DOMSerializer } from './DOMSerializer';
5
+ import { setStyleAttr } from './utils';
5
6
  const blockWrappers = [
6
7
  'div', 'ol', 'ul', 'li', 'table', 'tbody', 'thead', 'tfoot', 'caption', 'td', 'th', 'p',
7
8
  'tr', 'col', 'colgroup', 'article', 'main', 'nav', 'header', 'footer', 'aside', 'section'
@@ -138,15 +139,11 @@ const replacer = (match) => {
138
139
  const replaceStyleAttr = (html) => {
139
140
  return html.replace(reTag, replacer);
140
141
  };
141
- const applyStyle = (styleString, element) => styleString.split(';').filter(s => s.trim() !== '').forEach(s => {
142
- const parts = s.split(':');
143
- element.style[parts[0].trim()] = parts[1].trim();
144
- });
145
142
  const restoreStyleAttr = (container) => {
146
143
  Array.from(container.querySelectorAll('[' + styleAttr + ']')).forEach((element) => {
147
144
  const styleString = element.getAttribute(styleAttr);
148
145
  element.removeAttribute(styleAttr);
149
- applyStyle(styleString, element);
146
+ setStyleAttr(element, styleString);
150
147
  });
151
148
  };
152
149
  /**
@@ -267,7 +267,7 @@ export const applyStyle = (styleText, styleType, styleValue) => {
267
267
  .join('; ');
268
268
  return result ? result + ';' : null;
269
269
  };
270
- const setStyleAttr = (element, styleString) => {
270
+ export const setStyleAttr = (element, styleString) => {
271
271
  const styles = parseStyle(styleString);
272
272
  for (const style in styles) {
273
273
  if (style && typeof element.style[style] !== 'undefined') {
@@ -5,6 +5,7 @@ var prosemirror_model_1 = require("prosemirror-model");
5
5
  var prosemirror_state_1 = require("prosemirror-state");
6
6
  var constants_1 = require("./config/constants");
7
7
  var DOMSerializer_1 = require("./DOMSerializer");
8
+ var utils_1 = require("./utils");
8
9
  var blockWrappers = [
9
10
  'div', 'ol', 'ul', 'li', 'table', 'tbody', 'thead', 'tfoot', 'caption', 'td', 'th', 'p',
10
11
  'tr', 'col', 'colgroup', 'article', 'main', 'nav', 'header', 'footer', 'aside', 'section'
@@ -143,17 +144,11 @@ var replacer = function (match) {
143
144
  var replaceStyleAttr = function (html) {
144
145
  return html.replace(reTag, replacer);
145
146
  };
146
- var applyStyle = function (styleString, element) {
147
- return styleString.split(';').filter(function (s) { return s.trim() !== ''; }).forEach(function (s) {
148
- var parts = s.split(':');
149
- element.style[parts[0].trim()] = parts[1].trim();
150
- });
151
- };
152
147
  var restoreStyleAttr = function (container) {
153
148
  Array.from(container.querySelectorAll('[' + styleAttr + ']')).forEach(function (element) {
154
149
  var styleString = element.getAttribute(styleAttr);
155
150
  element.removeAttribute(styleAttr);
156
- applyStyle(styleString, element);
151
+ (0, utils_1.setStyleAttr)(element, styleString);
157
152
  });
158
153
  };
159
154
  /**
@@ -65,4 +65,5 @@ export declare const parseStyle: (styleText: string | null) => {
65
65
  [key: string]: string;
66
66
  };
67
67
  export declare const applyStyle: (styleText: string | null, styleType: string, styleValue: string) => string;
68
+ export declare const setStyleAttr: (element: HTMLElement, styleString: string) => void;
68
69
  export declare const setAttribute: (node: HTMLElement, attrName: string, value?: string) => void;
package/dist/npm/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setAttribute = exports.applyStyle = exports.parseStyle = exports.expandToWordWrap = exports.expandSelection = exports.shallowEqual = exports.indentHtml = exports.selectedLineTextOnly = exports.getNodeFromSelection = exports.getSelectionText = exports.hasSameMarkup = exports.insertNode = exports.parentNode = exports.findNthParentNodeOfType = exports.canInsert = exports.setNodeStyle = exports.changeStylesString = void 0;
3
+ exports.setAttribute = exports.setStyleAttr = exports.applyStyle = exports.parseStyle = exports.expandToWordWrap = exports.expandSelection = exports.shallowEqual = exports.indentHtml = exports.selectedLineTextOnly = exports.getNodeFromSelection = exports.getSelectionText = exports.hasSameMarkup = exports.insertNode = exports.parentNode = exports.findNthParentNodeOfType = exports.canInsert = exports.setNodeStyle = exports.changeStylesString = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var prosemirror_model_1 = require("prosemirror-model");
6
6
  var prosemirror_state_1 = require("prosemirror-state");
@@ -300,12 +300,13 @@ var setStyleAttr = function (element, styleString) {
300
300
  }
301
301
  }
302
302
  };
303
+ exports.setStyleAttr = setStyleAttr;
303
304
  var setAttribute = function (node, attrName, value) {
304
305
  var current = node.getAttribute(attrName);
305
306
  if (value !== undefined && value !== current) {
306
307
  if (attrName === 'style') {
307
308
  node.removeAttribute(attrName);
308
- setStyleAttr(node, value);
309
+ (0, exports.setStyleAttr)(node, value);
309
310
  }
310
311
  else {
311
312
  node.setAttribute(attrName, value);