mmhglobal-dynamicform 2.44.1 → 2.44.2
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/README.md +6 -0
- package/esm2020/lib/ztexteditor/ztexteditor.component.mjs +54 -7
- package/fesm2015/mmhglobal-dynamicform.mjs +57 -6
- package/fesm2015/mmhglobal-dynamicform.mjs.map +1 -1
- package/fesm2020/mmhglobal-dynamicform.mjs +53 -6
- package/fesm2020/mmhglobal-dynamicform.mjs.map +1 -1
- package/lib/ztexteditor/ztexteditor.component.d.ts +6 -0
- package/package.json +1 -1
|
@@ -92,7 +92,7 @@ import 'brace/mode/javascript';
|
|
|
92
92
|
import 'brace/mode/html';
|
|
93
93
|
import { trigger, transition, style, animate, state } from '@angular/animations';
|
|
94
94
|
import { event as event$1 } from 'jquery';
|
|
95
|
-
import { keymap, chainCommands, exitCode } from '@progress/kendo-editor-common';
|
|
95
|
+
import { DOMParser as DOMParser$1, keymap, chainCommands, exitCode, splitBlock } from '@progress/kendo-editor-common';
|
|
96
96
|
import * as i7$2 from '@progress/kendo-angular-toolbar';
|
|
97
97
|
import { MultiSelect, DropDownList } from '@syncfusion/ej2-dropdowns';
|
|
98
98
|
import { createElement, getComponent } from '@syncfusion/ej2-base';
|
|
@@ -9902,14 +9902,42 @@ class ZtexteditorComponent extends InputFieldBase {
|
|
|
9902
9902
|
if (htmlHasImg || cleanedHasTags) {
|
|
9903
9903
|
return false;
|
|
9904
9904
|
}
|
|
9905
|
-
// Plain-text paste: prevent Kendo from inserting encoded entities as literal text.
|
|
9906
|
-
e.preventDefault();
|
|
9907
|
-
// Decode common entities once so user sees correct characters.
|
|
9908
|
-
// This is intentionally limited to common entities to avoid unexpected transformations.
|
|
9909
9905
|
const normalized = this.normalizePastedText(plainText || cleanedHtml);
|
|
9910
|
-
|
|
9906
|
+
e.preventDefault();
|
|
9907
|
+
this.insertPlainTextWithEditorLineBreaks(this.normalizeLineEndings(normalized));
|
|
9911
9908
|
return true;
|
|
9912
9909
|
}
|
|
9910
|
+
normalizeLineEndings(value) {
|
|
9911
|
+
return value.replace(/\r\n|\r/g, '\n');
|
|
9912
|
+
}
|
|
9913
|
+
insertPlainTextWithEditorLineBreaks(value) {
|
|
9914
|
+
const view = this.editor?.view;
|
|
9915
|
+
if (!view) {
|
|
9916
|
+
console.warn('[Ztexteditor] Editor view is not ready. Cannot insert pasted text.');
|
|
9917
|
+
return;
|
|
9918
|
+
}
|
|
9919
|
+
const container = document.createElement('div');
|
|
9920
|
+
container.innerHTML = this.plainTextToEditorHtml(value);
|
|
9921
|
+
const slice = DOMParser$1.fromSchema(view.state.schema).parseSlice(container);
|
|
9922
|
+
view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
|
|
9923
|
+
}
|
|
9924
|
+
plainTextToEditorHtml(value) {
|
|
9925
|
+
const lines = value.split('\n');
|
|
9926
|
+
if (this.data?.EnterKeyBehavior === 'paragraph') {
|
|
9927
|
+
return lines
|
|
9928
|
+
.map(line => line.trim() ? `<p>${this.escapeHtml(line)}</p>` : '<p><br></p>')
|
|
9929
|
+
.join('');
|
|
9930
|
+
}
|
|
9931
|
+
return `<p>${lines.map(line => this.escapeHtml(line)).join('<br>')}</p>`;
|
|
9932
|
+
}
|
|
9933
|
+
escapeHtml(value) {
|
|
9934
|
+
return value
|
|
9935
|
+
.replaceAll('&', '&')
|
|
9936
|
+
.replaceAll('<', '<')
|
|
9937
|
+
.replaceAll('>', '>')
|
|
9938
|
+
.replaceAll('"', '"')
|
|
9939
|
+
.replaceAll("'", ''');
|
|
9940
|
+
}
|
|
9913
9941
|
/** Normalize text nodes inside pasted HTML without touching tags, styles, links, or image attributes. */
|
|
9914
9942
|
normalizePastedHtml(e) {
|
|
9915
9943
|
if (!this.symbolNormalizationSettings.Enabled) {
|
|
@@ -9933,8 +9961,26 @@ class ZtexteditorComponent extends InputFieldBase {
|
|
|
9933
9961
|
node.textContent = this.normalizePastedText(node.textContent ?? '');
|
|
9934
9962
|
node = walker.nextNode();
|
|
9935
9963
|
}
|
|
9964
|
+
this.removeEmptyParagraphs(doc);
|
|
9936
9965
|
e.cleanedHtml = doc.body.innerHTML;
|
|
9937
9966
|
}
|
|
9967
|
+
removeEmptyParagraphs(doc) {
|
|
9968
|
+
const emptyParagraphs = Array.from(doc.body.querySelectorAll('p')).filter(paragraph => this.isEmptyParagraph(paragraph));
|
|
9969
|
+
emptyParagraphs.forEach(paragraph => paragraph.remove());
|
|
9970
|
+
}
|
|
9971
|
+
isEmptyParagraph(paragraph) {
|
|
9972
|
+
const allowedEmptyNodes = Array.from(paragraph.childNodes).every(node => {
|
|
9973
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
9974
|
+
return !(node.textContent ?? '').trim();
|
|
9975
|
+
}
|
|
9976
|
+
if (node.nodeType !== Node.ELEMENT_NODE) {
|
|
9977
|
+
return false;
|
|
9978
|
+
}
|
|
9979
|
+
const element = node;
|
|
9980
|
+
return element.tagName.toLowerCase() === 'br';
|
|
9981
|
+
});
|
|
9982
|
+
return allowedEmptyNodes && !(paragraph.textContent ?? '').trim();
|
|
9983
|
+
}
|
|
9938
9984
|
/** Normalize known paste symbol variants from Office/email content into stable display characters. */
|
|
9939
9985
|
normalizePastedText(value) {
|
|
9940
9986
|
if (!this.symbolNormalizationSettings.Enabled || !value) {
|
|
@@ -10077,6 +10123,7 @@ class ZtexteditorComponent extends InputFieldBase {
|
|
|
10077
10123
|
}
|
|
10078
10124
|
enterAsLineBreakPlugin() {
|
|
10079
10125
|
return keymap({
|
|
10126
|
+
'Shift-Enter': chainCommands(exitCode, splitBlock),
|
|
10080
10127
|
Enter: chainCommands(exitCode, (state, dispatch) => {
|
|
10081
10128
|
const hardBreak = state.schema.nodes.hard_break;
|
|
10082
10129
|
if (!hardBreak || !state.selection.$from.parent.inlineContent) {
|