kamotive_ui 17.3.26 → 19.3.26
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.
|
@@ -113,22 +113,6 @@ export const TextEditor = ({ defaultValue, attachedFiles, label, onSubmit, onCan
|
|
|
113
113
|
}
|
|
114
114
|
return false;
|
|
115
115
|
}, [editor]);
|
|
116
|
-
const hasStyle = useCallback((element, property, values) => {
|
|
117
|
-
let current = element;
|
|
118
|
-
while (current && current !== (editor === null || editor === void 0 ? void 0 : editor.content)) {
|
|
119
|
-
const computedStyle = window.getComputedStyle(current);
|
|
120
|
-
const styleValue = computedStyle.getPropertyValue(property);
|
|
121
|
-
if (values.some((value) => styleValue.includes(value))) {
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
current = current.parentElement;
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
}, [editor]);
|
|
128
|
-
const isFormatActive = useCallback((element, tagNames, styleProperty, styleValues) => {
|
|
129
|
-
return (checkFormatting(element, tagNames) ||
|
|
130
|
-
(styleProperty && styleValues ? hasStyle(element, styleProperty, styleValues) : false));
|
|
131
|
-
}, [checkFormatting, hasStyle]);
|
|
132
116
|
const setCursorToEnd = () => {
|
|
133
117
|
var _a;
|
|
134
118
|
try {
|
|
@@ -200,19 +184,17 @@ export const TextEditor = ({ defaultValue, attachedFiles, label, onSubmit, onCan
|
|
|
200
184
|
}
|
|
201
185
|
const range = selection.getRangeAt(0);
|
|
202
186
|
const element = getElementFromRange(range);
|
|
203
|
-
if (!element)
|
|
204
|
-
return;
|
|
205
187
|
const newStates = {
|
|
206
|
-
bold:
|
|
207
|
-
italic:
|
|
208
|
-
underline:
|
|
209
|
-
strikethrough:
|
|
210
|
-
heading2: checkFormatting(element, ['H2']),
|
|
211
|
-
olist: checkFormatting(element, ['OL']) || !!element.closest('ol'),
|
|
188
|
+
bold: document.queryCommandState('bold'),
|
|
189
|
+
italic: document.queryCommandState('italic'),
|
|
190
|
+
underline: document.queryCommandState('underline'),
|
|
191
|
+
strikethrough: document.queryCommandState('strikethrough'),
|
|
192
|
+
heading2: element ? checkFormatting(element, ['H2']) : false,
|
|
193
|
+
olist: element ? (checkFormatting(element, ['OL']) || !!element.closest('ol')) : false,
|
|
212
194
|
};
|
|
213
195
|
setActiveStates(newStates);
|
|
214
196
|
updateButtonStates(newStates);
|
|
215
|
-
}, [
|
|
197
|
+
}, [checkFormatting, updateButtonStates]);
|
|
216
198
|
const toggleHeading2 = () => {
|
|
217
199
|
var _a;
|
|
218
200
|
const selection = window.getSelection();
|