import { Platform } from 'react-native'; import type BridgeExtension from '../bridges/base'; import type { EditorBridge } from '../types'; /** * Creates a new style element and appends it to the head of the document. * If the style element already exists, it will update the content of the existing element. * @param css - array of css strings * @param styleSheetTag - a unique tag to identify the style element - if not provided, a new style element will be created * @returns a string of javascript that is ready to be injected into the rich text webview */ export const getStyleSheetCSS = (css: string, styleSheetTag: string) => { return ` cssContent = \`${css}\`; head = document.head || document.getElementsByTagName('head')[0], styleElement = head.querySelector('style[data-tag="${styleSheetTag}"]'); if (!styleElement) { // If no such element exists, create a new