@seafile/sdoc-editor 0.5.56 → 0.5.57
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.
|
@@ -104,9 +104,14 @@ const CodeBlockHoverMenu = _ref2 => {
|
|
|
104
104
|
setSelectedLanguageText(selectedLanguageOption.text);
|
|
105
105
|
}, [language]);
|
|
106
106
|
const onChange = useCallback(e => {
|
|
107
|
+
// Escapes all special characters in a string for safe use in regular expressions.
|
|
108
|
+
const escapeRegExp = string => string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
107
109
|
const filterData = [];
|
|
110
|
+
const value = e.currentTarget.value.toLowerCase().trim();
|
|
111
|
+
// Generate a RegExp object and perform case-insensitive matching thereafter.
|
|
112
|
+
const regex = new RegExp(escapeRegExp(value), 'i');
|
|
108
113
|
genCodeLangs().forEach(item => {
|
|
109
|
-
if (
|
|
114
|
+
if (regex.test(item.value)) {
|
|
110
115
|
filterData.push(item);
|
|
111
116
|
}
|
|
112
117
|
});
|