import type { QuillMention } from 'src/types'; export const create_quill = ( id: string, toolbar: 'false' | string, clipboard: string, placeholder: string, theme: 'snow' | 'bubble', customFonts: Array = [], customJS: string, mention?: QuillMention ) => { let font = ''; if (customFonts.length > 0) { const fontList = "'" + customFonts.join("','") + "'"; font = ` // Add fonts to whitelist var Font = Quill.import('formats/font'); Font.whitelist = [${fontList}]; Quill.register(Font, true); `; } let clipboardModule = ''; if (clipboard) { clipboardModule = `clipboard: ${clipboard},`; } let mentionModule = ''; var mentionFunction = ''; if (mention) { mentionModule = `mention: { allowedChars: ${mention.allowedChars}, mentionDenotationChars: ${mention.mentionDenotationChars}, source: mentionSource, fixMentionsToQuill: ${mention.fixMentionsToQuill || false}, dataAttributes: ['id', 'value', 'denotationChar', 'link', 'target', '__typename'] }`; mentionFunction = ` var renderListHolder; var mentionSource = function (searchTerm, renderList, mentionChar) { window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'mention', data: { searchTerm, mentionChar } })); renderListHolder = renderList; } `; } return ` `; };