@antscorp/antsomi-ui 1.3.5-beta.74 → 1.3.5-beta.75
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.
|
@@ -59,6 +59,21 @@ if (window.getSelection && document.createRange) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
let sel = window.getSelection();
|
|
62
|
+
// NOTE: add new text node after span contain shortlink content
|
|
63
|
+
if (range.endContainer) {
|
|
64
|
+
const { parentNode } = range.endContainer;
|
|
65
|
+
if (parentNode && parentNode.classList && parentNode.classList.contains('detect-url')) {
|
|
66
|
+
const textNode = document.createTextNode('\u00A0'); // Create a text node with a non-breaking space
|
|
67
|
+
if (parentNode.nextSibling) {
|
|
68
|
+
parentNode.parentNode.insertBefore(textNode, parentNode.nextSibling);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
parentNode.parentNode.appendChild(textNode);
|
|
72
|
+
}
|
|
73
|
+
range.setStart(textNode, textNode.length);
|
|
74
|
+
range.collapse(true);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
62
77
|
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges();
|
|
63
78
|
sel === null || sel === void 0 ? void 0 : sel.addRange(range);
|
|
64
79
|
};
|
|
@@ -144,15 +144,17 @@ export const InputDynamic = (props) => {
|
|
|
144
144
|
if (innerHTML) {
|
|
145
145
|
// remove span url và focus vào vị trí remove để add tag shortlink vào vị trí này.
|
|
146
146
|
const index = Array.from((_a = personalizationInputRef.current) === null || _a === void 0 ? void 0 : _a.childNodes).findIndex((element) => element.id === data.id);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
147
|
+
if (index !== -1) {
|
|
148
|
+
const range = document.createRange(); // Tạo một đối tượng Range
|
|
149
|
+
const sel = window.getSelection(); // Lấy đối tượng Selection hiện tại
|
|
150
|
+
range.setStart((_b = personalizationInputRef.current) === null || _b === void 0 ? void 0 : _b.childNodes[index], 0); // Đặt điểm bắt đầu của Range
|
|
151
|
+
range.collapse(true); // Thu gọn Range để tập trung vào điểm bắt đầu
|
|
152
|
+
sel === null || sel === void 0 ? void 0 : sel.removeAllRanges(); // Xóa tất cả các Range hiện có
|
|
153
|
+
sel === null || sel === void 0 ? void 0 : sel.addRange(range); // Thêm Range mới vào Selection
|
|
154
|
+
caretPositionRef.current = CaretPositioning.saveSelection(personalizationInputRef.current);
|
|
155
|
+
const newDataUpdate = innerHTML.replace(data.outerHTML, '');
|
|
156
|
+
personalizationInputRef.current.innerHTML = newDataUpdate;
|
|
157
|
+
}
|
|
156
158
|
}
|
|
157
159
|
break;
|
|
158
160
|
}
|
package/es/test.js
CHANGED
|
@@ -194,16 +194,20 @@ export const App = () => {
|
|
|
194
194
|
// borderRadius: '10px',
|
|
195
195
|
// }}
|
|
196
196
|
// >
|
|
197
|
-
// <
|
|
198
|
-
// errors={[]}
|
|
199
|
-
// onChange={dataOut => setValueShortlink(dataOut)}
|
|
200
|
-
// onError={() => {}}
|
|
201
|
-
// isViewMode={false}
|
|
202
|
-
// canMultipleLine={false}
|
|
203
|
-
// value={valueShortlink}
|
|
204
|
-
// />
|
|
197
|
+
// <SlideBar {...stateSlideBar} callback={callbackSlideBar} />
|
|
205
198
|
// </div>
|
|
206
199
|
// );
|
|
200
|
+
// --------------------------- Test SlideBar end -------------------------------------------
|
|
201
|
+
// ---------------------------- Test Input Dynamic start ------------------------------
|
|
202
|
+
return (React.createElement("div", { style: {
|
|
203
|
+
width: 500,
|
|
204
|
+
height: 500,
|
|
205
|
+
border: '1px solid black',
|
|
206
|
+
margin: '0 auto',
|
|
207
|
+
padding: 12,
|
|
208
|
+
borderRadius: '10px',
|
|
209
|
+
} },
|
|
210
|
+
React.createElement(InputDynamic, { errors: [], onChange: dataOut => setValueShortlink(dataOut), onError: () => { }, isRealTime: true, isViewMode: false, canMultipleLine: false, value: valueShortlink })));
|
|
207
211
|
// ---------------------------- Test Input Dynamic End ------------------------------
|
|
208
212
|
// ---------------------------- Test Helps Start ------------------------------
|
|
209
213
|
// return (
|