* feat: Add mermaidjs integration (#3523) * Add mermaidjs to dependencies and CodeFenceNode * Fix diagram id for mermaidjs diagrams * Fix typescript compiler errors on mermaid integration * Fix id generation for mermaid diagrams * Refactor mermaidjs integration into prosemirror plugin * Remove unnecessary class attribute in mermaidjs integration * Change mermaidjs label to singular * Change decorator.inline to decorator.node for mermaid diagram id * Fix diagram toggle state * Add border and background to mermaid diagrams * Stop mermaidjs from overwriting fontFamily inside diagrams * Add stable diagramId to mermaid diagrams * Separate text for hide/show diagram Use uuid as diagramId, avoid storing in state Fix cursor on diagrams * fix: Base diagram visibility off presence of source * fix: More cases where our font-family is ignored * Disable HTML labels * fix: Button styling – not technically required but now we have a third button this felt all the more needed closes #3116 * named chunks * Upgrade mermaid 9.1.3 Co-authored-by: Jan Niklas Richter <5812215+ArcticXWolf@users.noreply.github.com>
35 lines
765 B
TypeScript
35 lines
765 B
TypeScript
/**
|
|
* Loads required polyfills.
|
|
*
|
|
* @returns A promise that resolves when all required polyfills are loaded
|
|
*/
|
|
export async function loadPolyfills() {
|
|
const polyfills = [];
|
|
|
|
if (!supportsResizeObserver()) {
|
|
polyfills.push(
|
|
import(
|
|
/* webpackChunkName: "resize-observer" */
|
|
"@juggle/resize-observer"
|
|
).then((module) => {
|
|
window.ResizeObserver = module.ResizeObserver;
|
|
})
|
|
);
|
|
}
|
|
|
|
return Promise.all(polyfills);
|
|
}
|
|
|
|
/**
|
|
* Detect ResizeObserver compatability.
|
|
*
|
|
* @returns true if the current browser supports ResizeObserver
|
|
*/
|
|
function supportsResizeObserver() {
|
|
return (
|
|
"ResizeObserver" in global &&
|
|
"ResizeObserverEntry" in global &&
|
|
"contentRect" in ResizeObserverEntry.prototype
|
|
);
|
|
}
|