fix: links in quill mentions (#13633)

* fix: links in quill mentions

* fix: unit tests

* fix: explore flockering
This commit is contained in:
karanh37 2023-10-18 22:50:37 +05:30 committed by GitHub
parent e1a19f7c7e
commit d15f415460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 12 deletions

View File

@ -73,6 +73,10 @@ jest.mock('react-quill', () => {
};
});
jest.mock('../../utils/QuillLink/QuillLink', () => {
return jest.fn();
});
describe('Test FeedEditor Component', () => {
it('Should render FeedEditor Component', async () => {
const { container } = render(<FeedEditor {...mockFeedEditorProp} />, {

View File

@ -33,6 +33,7 @@ import {
TOOLBAR_ITEMS,
} from '../../constants/Feeds.constants';
import { HTMLToMarkdown, matcher } from '../../utils/FeedUtils';
import { LinkBlot } from '../../utils/QuillLink/QuillLink';
import { insertMention, insertRef } from '../../utils/QuillUtils';
import { getEntityIcon } from '../../utils/TableUtils';
import { editorRef } from '../common/rich-text-editor/RichTextEditor.interface';
@ -41,6 +42,7 @@ import { FeedEditorProp } from './FeedEditor.interface';
Quill.register('modules/markdownOptions', QuillMarkdown);
Quill.register('modules/emoji', Emoji);
Quill.register(LinkBlot);
const Delta = Quill.import('delta');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const strikethrough = (_node: any, delta: typeof Delta) => {
@ -81,6 +83,7 @@ export const FeedEditor = forwardRef<editorRef, FeedEditorProp>(
mention: {
allowedChars: MENTION_ALLOWED_CHARS,
mentionDenotationChars: MENTION_DENOTATION_CHARS,
blotName: 'link-mention',
onOpen: () => {
toggleMentionList(false);
},

View File

@ -428,7 +428,8 @@ export const AuthProvider = ({
if (config.url?.includes('/search/query')) {
// Parse and update the query parameter
const queryParams = Qs.parse(config.url.split('?')[1]);
const domainStatement = `(domain.fullyQualifiedName:${activeDomain})`;
// adding quotes for exact matching
const domainStatement = `(domain.fullyQualifiedName:"${activeDomain}")`;
queryParams.q = queryParams.q ?? '';
queryParams.q += isEmpty(queryParams.q)
? domainStatement

View File

@ -199,20 +199,18 @@ const ExplorePageV1: FunctionComponent = () => {
};
const searchIndex = useMemo(() => {
if (searchHitCounts) {
const tabInfo = Object.entries(tabsInfo).find(
([, tabInfo]) => tabInfo.path === tab
);
if (isNil(tabInfo)) {
const activeKey = findActiveSearchIndex(searchHitCounts);
const tabInfo = Object.entries(tabsInfo).find(
([, tabInfo]) => tabInfo.path === tab
);
if (searchHitCounts && isNil(tabInfo)) {
const activeKey = findActiveSearchIndex(searchHitCounts);
return activeKey ? activeKey : SearchIndex.DATA_PRODUCT;
}
return tabInfo[0] as ExploreSearchIndex;
return activeKey ? activeKey : SearchIndex.DATA_PRODUCT;
}
return SearchIndex.DATA_PRODUCT;
return !isNil(tabInfo)
? (tabInfo[0] as ExploreSearchIndex)
: SearchIndex.DATA_PRODUCT;
}, [tab, searchHitCounts]);
const tabItems = useMemo(() => {

View File

@ -0,0 +1,27 @@
/*
* Copyright 2023 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Quill } from 'react-quill';
const MentionBlot = Quill.import('blots/mention');
export class LinkBlot extends MentionBlot {
static render(data: { value: string; link: string; id: string }) {
const element = document.createElement('a');
element.innerText = data.value;
element.href = data.link;
element.id = data.id;
return element;
}
}
LinkBlot.blotName = 'link-mention';