@team-monolith/cds 1.15.0 → 1.15.1
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.
|
@@ -34,6 +34,12 @@ export const COMPONENT_ADDER_MENU_CLASSNAME = "component-adder-menu";
|
|
|
34
34
|
function isOnMenu(element) {
|
|
35
35
|
return !!element.closest(`.${COMPONENT_ADDER_MENU_CLASSNAME}`);
|
|
36
36
|
}
|
|
37
|
+
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
|
38
|
+
// Component Picker에도 비슷한 코드가 있지만 LexicalTypeaheadMenuPlugin 에서
|
|
39
|
+
// 유사한 Escape 처리를 합니다.
|
|
40
|
+
function escapeRegExp(string) {
|
|
41
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
|
|
42
|
+
}
|
|
37
43
|
// https://github.com/facebook/lexical/blob/4d2e3102b90d09662cbd70b014464be0ff80c7a0/packages/lexical-react/src/LexicalTypeaheadMenuPlugin.tsx#L37
|
|
38
44
|
function getTextUpToAnchor(selection) {
|
|
39
45
|
const anchor = selection.anchor;
|
|
@@ -136,7 +142,7 @@ export function ComponentAdderPlugin(props) {
|
|
|
136
142
|
if (!query) {
|
|
137
143
|
return true;
|
|
138
144
|
}
|
|
139
|
-
const regex = new RegExp(query, "i");
|
|
145
|
+
const regex = new RegExp(escapeRegExp(query), "i");
|
|
140
146
|
return (option instanceof ComponentPickerOption &&
|
|
141
147
|
(regex.test(option.title) ||
|
|
142
148
|
option.keywords.some((keyword) => regex.test(keyword))));
|