MCPcopy
hub / github.com/codex-team/editor.js / loadStyles

Method loadStyles

src/components/modules/ui.ts:316–351  ·  view source on GitHub ↗

* Appends CSS

()

Source from the content-addressed store, hash-verified

314 * Appends CSS
315 */
316 private loadStyles(): void {
317 /**
318 * Load CSS
319 */
320 // eslint-disable-next-line @typescript-eslint/no-var-requires
321 const styleTagId = 'editor-js-styles';
322
323 /**
324 * Do not append styles again if they are already on the page
325 */
326 if ($.get(styleTagId)) {
327 return;
328 }
329
330 /**
331 * Make tag
332 */
333 const tag = $.make('style', null, {
334 id: styleTagId,
335 textContent: styles.toString(),
336 });
337
338 /**
339 * If user enabled Content Security Policy, he can pass nonce through the config
340 *
341 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
342 */
343 if (this.config.style && !_.isEmpty(this.config.style) && this.config.style.nonce) {
344 tag.setAttribute('nonce', this.config.style.nonce);
345 }
346
347 /**
348 * Append styles at the top of HEAD tag
349 */
350 $.prepend(document.head, tag);
351 }
352
353 /**
354 * Adds listeners that should work both in read-only and read-write modes

Callers 1

prepareMethod · 0.95

Calls 4

prependMethod · 0.80
getMethod · 0.65
makeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected