@tiny-mce-umbraco/backoffice 16.0.0-rc2 → 16.0.0-rc2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist-cms/README.md +1 -0
- package/dist-cms/api/client.gen.d.ts +13 -0
- package/dist-cms/api/client.gen.d.ts.map +1 -0
- package/dist-cms/api/client.gen.js +5 -0
- package/dist-cms/api/index.d.ts +3 -0
- package/dist-cms/api/index.d.ts.map +1 -0
- package/dist-cms/api/index.js +3 -0
- package/dist-cms/api/sdk.gen.d.ts +19 -0
- package/dist-cms/api/sdk.gen.d.ts.map +1 -0
- package/dist-cms/api/sdk.gen.js +16 -0
- package/dist-cms/api/types.gen.d.ts +72 -0
- package/dist-cms/api/types.gen.d.ts.map +1 -0
- package/dist-cms/api/types.gen.js +7 -0
- package/dist-cms/components/constants.d.ts +2 -0
- package/dist-cms/components/constants.d.ts.map +1 -0
- package/dist-cms/components/constants.js +1 -0
- package/dist-cms/components/index.d.ts +6 -0
- package/dist-cms/components/index.d.ts.map +1 -0
- package/dist-cms/components/index.js +5 -0
- package/dist-cms/components/input-tiny-mce/index.d.ts +7 -0
- package/dist-cms/components/input-tiny-mce/index.d.ts.map +1 -0
- package/dist-cms/components/input-tiny-mce/index.js +6 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.defaults.d.ts +5 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.defaults.d.ts.map +1 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.defaults.js +159 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.element.d.ts +37 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.element.d.ts.map +1 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.element.js +449 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.handlers.d.ts +3 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.handlers.d.ts.map +1 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.handlers.js +8 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.languages.d.ts +2 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.languages.d.ts.map +1 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.languages.js +78 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.sanitizer.d.ts +9 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.sanitizer.d.ts.map +1 -0
- package/dist-cms/components/input-tiny-mce/input-tiny-mce.sanitizer.js +47 -0
- package/dist-cms/components/input-tiny-mce/tiny-mce-plugin.d.ts +24 -0
- package/dist-cms/components/input-tiny-mce/tiny-mce-plugin.d.ts.map +1 -0
- package/dist-cms/components/input-tiny-mce/tiny-mce-plugin.js +16 -0
- package/dist-cms/components/manifests.d.ts +2 -0
- package/dist-cms/components/manifests.d.ts.map +1 -0
- package/dist-cms/components/manifests.js +2 -0
- package/dist-cms/components/stylesheet-rule-input/constants.d.ts +3 -0
- package/dist-cms/components/stylesheet-rule-input/constants.d.ts.map +1 -0
- package/dist-cms/components/stylesheet-rule-input/constants.js +2 -0
- package/dist-cms/components/stylesheet-rule-input/manifests.d.ts +3 -0
- package/dist-cms/components/stylesheet-rule-input/manifests.d.ts.map +1 -0
- package/dist-cms/components/stylesheet-rule-input/manifests.js +9 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-input.element.d.ts +18 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-input.element.d.ts.map +1 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-input.element.js +119 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-settings-modal.element.d.ts +12 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-settings-modal.element.d.ts.map +1 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-settings-modal.element.js +142 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-settings-modal.token.d.ts +7 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-settings-modal.token.d.ts.map +1 -0
- package/dist-cms/components/stylesheet-rule-input/stylesheet-rule-settings-modal.token.js +9 -0
- package/dist-cms/components/stylesheet-rule-ref/stylesheet-rule-ref.element.d.ts +16 -0
- package/dist-cms/components/stylesheet-rule-ref/stylesheet-rule-ref.element.d.ts.map +1 -0
- package/dist-cms/components/stylesheet-rule-ref/stylesheet-rule-ref.element.js +24 -0
- package/dist-cms/constants.d.ts +2 -0
- package/dist-cms/constants.d.ts.map +1 -0
- package/dist-cms/constants.js +1 -0
- package/dist-cms/entry-points/entry-point.d.ts +4 -0
- package/dist-cms/entry-points/entry-point.d.ts.map +1 -0
- package/dist-cms/entry-points/entry-point.js +25 -0
- package/dist-cms/entry-points/manifest.d.ts +2 -0
- package/dist-cms/entry-points/manifest.d.ts.map +1 -0
- package/dist-cms/entry-points/manifest.js +8 -0
- package/dist-cms/external/tinymce/index.d.ts +22 -0
- package/dist-cms/external/tinymce/index.d.ts.map +1 -0
- package/dist-cms/external/tinymce/index.js +18 -0
- package/dist-cms/icons/icons.d.ts +6 -0
- package/dist-cms/icons/icons.d.ts.map +1 -0
- package/dist-cms/icons/icons.js +1 -0
- package/dist-cms/icons/manifests.d.ts +2 -0
- package/dist-cms/icons/manifests.d.ts.map +1 -0
- package/dist-cms/icons/manifests.js +8 -0
- package/dist-cms/index.d.ts +5 -0
- package/dist-cms/index.d.ts.map +1 -0
- package/dist-cms/index.js +3 -0
- package/dist-cms/localizations/ar.d.ts +4 -0
- package/dist-cms/localizations/ar.d.ts.map +1 -0
- package/dist-cms/localizations/ar.js +5 -0
- package/dist-cms/localizations/bs.d.ts +4 -0
- package/dist-cms/localizations/bs.d.ts.map +1 -0
- package/dist-cms/localizations/bs.js +5 -0
- package/dist-cms/localizations/cs.d.ts +4 -0
- package/dist-cms/localizations/cs.d.ts.map +1 -0
- package/dist-cms/localizations/cs.js +5 -0
- package/dist-cms/localizations/cy.d.ts +4 -0
- package/dist-cms/localizations/cy.d.ts.map +1 -0
- package/dist-cms/localizations/cy.js +5 -0
- package/dist-cms/localizations/da.d.ts +4 -0
- package/dist-cms/localizations/da.d.ts.map +1 -0
- package/dist-cms/localizations/da.js +5 -0
- package/dist-cms/localizations/de.d.ts +4 -0
- package/dist-cms/localizations/de.d.ts.map +1 -0
- package/dist-cms/localizations/de.js +5 -0
- package/dist-cms/localizations/en.d.ts +4 -0
- package/dist-cms/localizations/en.d.ts.map +1 -0
- package/dist-cms/localizations/en.js +5 -0
- package/dist-cms/localizations/fr.d.ts +4 -0
- package/dist-cms/localizations/fr.d.ts.map +1 -0
- package/dist-cms/localizations/fr.js +5 -0
- package/dist-cms/localizations/hr.d.ts +4 -0
- package/dist-cms/localizations/hr.d.ts.map +1 -0
- package/dist-cms/localizations/hr.js +5 -0
- package/dist-cms/localizations/it.d.ts +4 -0
- package/dist-cms/localizations/it.d.ts.map +1 -0
- package/dist-cms/localizations/it.js +5 -0
- package/dist-cms/localizations/manifests.d.ts +2 -0
- package/dist-cms/localizations/manifests.d.ts.map +1 -0
- package/dist-cms/localizations/manifests.js +97 -0
- package/dist-cms/localizations/nl.d.ts +4 -0
- package/dist-cms/localizations/nl.d.ts.map +1 -0
- package/dist-cms/localizations/nl.js +5 -0
- package/dist-cms/localizations/tr.d.ts +4 -0
- package/dist-cms/localizations/tr.d.ts.map +1 -0
- package/dist-cms/localizations/tr.js +5 -0
- package/dist-cms/manifests.d.ts +2 -0
- package/dist-cms/manifests.d.ts.map +1 -0
- package/dist-cms/manifests.js +16 -0
- package/dist-cms/plugins/core/a11ychecker.tinymce-api.d.ts +6 -0
- package/dist-cms/plugins/core/a11ychecker.tinymce-api.d.ts.map +1 -0
- package/dist-cms/plugins/core/a11ychecker.tinymce-api.js +7 -0
- package/dist-cms/plugins/core/ai-assistant.tinymce-api.d.ts +9 -0
- package/dist-cms/plugins/core/ai-assistant.tinymce-api.d.ts.map +1 -0
- package/dist-cms/plugins/core/ai-assistant.tinymce-api.js +41 -0
- package/dist-cms/plugins/core/ai-request-factory.d.ts +2 -0
- package/dist-cms/plugins/core/ai-request-factory.d.ts.map +1 -0
- package/dist-cms/plugins/core/ai-request-factory.js +33 -0
- package/dist-cms/plugins/core/basic.tinymce-api.d.ts +6 -0
- package/dist-cms/plugins/core/basic.tinymce-api.d.ts.map +1 -0
- package/dist-cms/plugins/core/basic.tinymce-api.js +7 -0
- package/dist-cms/plugins/manifests.d.ts +3 -0
- package/dist-cms/plugins/manifests.d.ts.map +1 -0
- package/dist-cms/plugins/manifests.js +506 -0
- package/dist-cms/plugins/tiny-mce-block-picker.plugin.d.ts +8 -0
- package/dist-cms/plugins/tiny-mce-block-picker.plugin.d.ts.map +1 -0
- package/dist-cms/plugins/tiny-mce-block-picker.plugin.js +99 -0
- package/dist-cms/plugins/tiny-mce-code-editor.plugin.d.ts +7 -0
- package/dist-cms/plugins/tiny-mce-code-editor.plugin.d.ts.map +1 -0
- package/dist-cms/plugins/tiny-mce-code-editor.plugin.js +42 -0
- package/dist-cms/plugins/tiny-mce-embeddedmedia.plugin.d.ts +7 -0
- package/dist-cms/plugins/tiny-mce-embeddedmedia.plugin.d.ts.map +1 -0
- package/dist-cms/plugins/tiny-mce-embeddedmedia.plugin.js +74 -0
- package/dist-cms/plugins/tiny-mce-mediapicker.plugin.d.ts +7 -0
- package/dist-cms/plugins/tiny-mce-mediapicker.plugin.d.ts.map +1 -0
- package/dist-cms/plugins/tiny-mce-mediapicker.plugin.js +224 -0
- package/dist-cms/plugins/tiny-mce-multi-url-picker.plugin.d.ts +8 -0
- package/dist-cms/plugins/tiny-mce-multi-url-picker.plugin.d.ts.map +1 -0
- package/dist-cms/plugins/tiny-mce-multi-url-picker.plugin.js +172 -0
- package/dist-cms/plugins/tinymce-plugin.extension.d.ts +70 -0
- package/dist-cms/plugins/tinymce-plugin.extension.d.ts.map +1 -0
- package/dist-cms/plugins/tinymce-plugin.extension.js +1 -0
- package/dist-cms/plugins/types.d.ts +2 -0
- package/dist-cms/plugins/types.d.ts.map +1 -0
- package/dist-cms/plugins/types.js +1 -0
- package/dist-cms/property-editors/configEditor/property-editor-ui-tiny-mce-config-editor.element.d.ts +23 -0
- package/dist-cms/property-editors/configEditor/property-editor-ui-tiny-mce-config-editor.element.d.ts.map +1 -0
- package/dist-cms/property-editors/configEditor/property-editor-ui-tiny-mce-config-editor.element.js +102 -0
- package/dist-cms/property-editors/constants.d.ts +2 -0
- package/dist-cms/property-editors/constants.d.ts.map +1 -0
- package/dist-cms/property-editors/constants.js +1 -0
- package/dist-cms/property-editors/manifests.d.ts +2 -0
- package/dist-cms/property-editors/manifests.d.ts.map +1 -0
- package/dist-cms/property-editors/manifests.js +37 -0
- package/dist-cms/property-editors/plugin/property-editor-ui-tiny-mce-plugin-configuration.element.d.ts +25 -0
- package/dist-cms/property-editors/plugin/property-editor-ui-tiny-mce-plugin-configuration.element.d.ts.map +1 -0
- package/dist-cms/property-editors/plugin/property-editor-ui-tiny-mce-plugin-configuration.element.js +212 -0
- package/dist-cms/property-editors/tiny-mce/constants.d.ts +2 -0
- package/dist-cms/property-editors/tiny-mce/constants.d.ts.map +1 -0
- package/dist-cms/property-editors/tiny-mce/constants.js +1 -0
- package/dist-cms/property-editors/tiny-mce/manifests.d.ts +2 -0
- package/dist-cms/property-editors/tiny-mce/manifests.d.ts.map +1 -0
- package/dist-cms/property-editors/tiny-mce/manifests.js +149 -0
- package/dist-cms/property-editors/tiny-mce/property-editor-ui-tiny-mce.element.d.ts +16 -0
- package/dist-cms/property-editors/tiny-mce/property-editor-ui-tiny-mce.element.d.ts.map +1 -0
- package/dist-cms/property-editors/tiny-mce/property-editor-ui-tiny-mce.element.js +79 -0
- package/dist-cms/property-editors/toolbar/property-editor-ui-tiny-mce-toolbar-configuration.element.d.ts +25 -0
- package/dist-cms/property-editors/toolbar/property-editor-ui-tiny-mce-toolbar-configuration.element.d.ts.map +1 -0
- package/dist-cms/property-editors/toolbar/property-editor-ui-tiny-mce-toolbar-configuration.element.js +201 -0
- package/dist-cms/stylesheets/entity-actions/manifests.d.ts +2 -0
- package/dist-cms/stylesheets/entity-actions/manifests.d.ts.map +1 -0
- package/dist-cms/stylesheets/entity-actions/manifests.js +15 -0
- package/dist-cms/stylesheets/entity-actions/rte-stylesheet-create-option-action.d.ts +7 -0
- package/dist-cms/stylesheets/entity-actions/rte-stylesheet-create-option-action.d.ts.map +1 -0
- package/dist-cms/stylesheets/entity-actions/rte-stylesheet-create-option-action.js +8 -0
- package/dist-cms/stylesheets/manifests.d.ts +2 -0
- package/dist-cms/stylesheets/manifests.d.ts.map +1 -0
- package/dist-cms/stylesheets/manifests.js +3 -0
- package/dist-cms/stylesheets/stylesheet-rule-manager.d.ts +20 -0
- package/dist-cms/stylesheets/stylesheet-rule-manager.d.ts.map +1 -0
- package/dist-cms/stylesheets/stylesheet-rule-manager.js +57 -0
- package/dist-cms/stylesheets/workspace-views/manifests.d.ts +2 -0
- package/dist-cms/stylesheets/workspace-views/manifests.d.ts.map +1 -0
- package/dist-cms/stylesheets/workspace-views/manifests.js +22 -0
- package/dist-cms/stylesheets/workspace-views/stylesheet-rich-text-rule-workspace-view.element.d.ts +18 -0
- package/dist-cms/stylesheets/workspace-views/stylesheet-rich-text-rule-workspace-view.element.d.ts.map +1 -0
- package/dist-cms/stylesheets/workspace-views/stylesheet-rich-text-rule-workspace-view.element.js +100 -0
- package/dist-cms/tinymce.d.ts +2 -0
- package/dist-cms/tinymce.d.ts.map +1 -0
- package/dist-cms/tinymce.js +1 -0
- package/dist-cms/types.d.ts +6 -0
- package/dist-cms/types.d.ts.map +1 -0
- package/dist-cms/types.js +1 -0
- package/dist-cms/utils/index.d.ts +26 -0
- package/dist-cms/utils/index.d.ts.map +1 -0
- package/dist-cms/utils/index.js +108 -0
- package/package.json +11 -4
- package/dist/tiny-mce-umbraco.d.ts +0 -252
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
+
};
|
|
18
|
+
var _UmbInputTinyMceElement_instances, _UmbInputTinyMceElement_plugins, _UmbInputTinyMceElement_editorRef, _UmbInputTinyMceElement_stylesheetRepository, _UmbInputTinyMceElement_umbStylesheetRuleManager, _UmbInputTinyMceElement_readonly, _UmbInputTinyMceElement_loadEditor, _UmbInputTinyMceElement_loadPlugins, _UmbInputTinyMceElement_getTinyMceConfig, _UmbInputTinyMceElement_setTinyConfig, _UmbInputTinyMceElement_getLanguage, _UmbInputTinyMceElement_editorSetup, _UmbInputTinyMceElement_onInit, _UmbInputTinyMceElement_onChange;
|
|
19
|
+
import { availableLanguages } from './input-tiny-mce.languages.js';
|
|
20
|
+
import { defaultFallbackConfig, defaultPremiumPluginsList } from './input-tiny-mce.defaults.js';
|
|
21
|
+
import { pastePreProcessHandler } from './input-tiny-mce.handlers.js';
|
|
22
|
+
import { uriAttributeSanitizer } from './input-tiny-mce.sanitizer.js';
|
|
23
|
+
import { UmbStylesheetRuleManager } from '../../stylesheets/stylesheet-rule-manager.js';
|
|
24
|
+
import { css, customElement, html, property, query } from '@umbraco-cms/backoffice/external/lit';
|
|
25
|
+
import { loadManifestApi } from '@umbraco-cms/backoffice/extension-api';
|
|
26
|
+
import { getProcessedImageUrl, umbDeepMerge } from '@umbraco-cms/backoffice/utils';
|
|
27
|
+
import { renderEditor } from '@umbraco-cms/backoffice/external/tinymce';
|
|
28
|
+
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
|
|
29
|
+
import { ImageCropModeModel } from '@umbraco-cms/backoffice/external/backend-api';
|
|
30
|
+
import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';
|
|
31
|
+
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
|
32
|
+
import { UmbStylesheetDetailRepository } from '@umbraco-cms/backoffice/stylesheet';
|
|
33
|
+
import { UUIFormControlMixin } from '@umbraco-cms/backoffice/external/uui';
|
|
34
|
+
import { TinyMceService } from '../../api/index.js';
|
|
35
|
+
import { tryExecute } from '@umbraco-cms/backoffice/resources';
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
import { umbHttpClient } from '@umbraco-cms/backoffice/http-client';
|
|
38
|
+
/**
|
|
39
|
+
* Handles the resize event
|
|
40
|
+
* @param e
|
|
41
|
+
*/
|
|
42
|
+
async function onResize(e) {
|
|
43
|
+
const srcAttr = e.target.getAttribute('src');
|
|
44
|
+
if (!srcAttr) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const path = srcAttr.split('?')[0];
|
|
48
|
+
const resizedPath = await getProcessedImageUrl(path, {
|
|
49
|
+
width: e.width,
|
|
50
|
+
height: e.height,
|
|
51
|
+
mode: ImageCropModeModel.MAX,
|
|
52
|
+
});
|
|
53
|
+
e.target.setAttribute('data-mce-src', resizedPath);
|
|
54
|
+
}
|
|
55
|
+
let UmbInputTinyMceElement = class UmbInputTinyMceElement extends UUIFormControlMixin(UmbLitElement, '') {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
_UmbInputTinyMceElement_instances.add(this);
|
|
59
|
+
//#plugins: Array<ClassConstructor<UmbTinyMcePluginBase> | undefined> = [];
|
|
60
|
+
_UmbInputTinyMceElement_plugins.set(this, []);
|
|
61
|
+
_UmbInputTinyMceElement_editorRef.set(this, null);
|
|
62
|
+
_UmbInputTinyMceElement_stylesheetRepository.set(this, new UmbStylesheetDetailRepository(this));
|
|
63
|
+
_UmbInputTinyMceElement_umbStylesheetRuleManager.set(this, new UmbStylesheetRuleManager());
|
|
64
|
+
_UmbInputTinyMceElement_readonly.set(this, false);
|
|
65
|
+
}
|
|
66
|
+
getFormElement() {
|
|
67
|
+
return this._editorElement?.querySelector('iframe') ?? undefined;
|
|
68
|
+
}
|
|
69
|
+
set value(newValue) {
|
|
70
|
+
const newContent = typeof newValue === 'string' ? newValue : '';
|
|
71
|
+
super.value = newContent;
|
|
72
|
+
if (__classPrivateFieldGet(this, _UmbInputTinyMceElement_editorRef, "f") && __classPrivateFieldGet(this, _UmbInputTinyMceElement_editorRef, "f").getContent() != newContent) {
|
|
73
|
+
__classPrivateFieldGet(this, _UmbInputTinyMceElement_editorRef, "f").setContent(newContent);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
get value() {
|
|
77
|
+
return super.value;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Sets the input to readonly mode, meaning value cannot be changed but still able to read and select its content.
|
|
81
|
+
* @type {boolean}
|
|
82
|
+
* @attr
|
|
83
|
+
* @default
|
|
84
|
+
*/
|
|
85
|
+
get readonly() {
|
|
86
|
+
return __classPrivateFieldGet(this, _UmbInputTinyMceElement_readonly, "f");
|
|
87
|
+
}
|
|
88
|
+
set readonly(value) {
|
|
89
|
+
__classPrivateFieldSet(this, _UmbInputTinyMceElement_readonly, value, "f");
|
|
90
|
+
const editor = this.getEditor();
|
|
91
|
+
const mode = value ? 'readonly' : 'design';
|
|
92
|
+
editor?.mode.set(mode);
|
|
93
|
+
}
|
|
94
|
+
getEditor() {
|
|
95
|
+
return __classPrivateFieldGet(this, _UmbInputTinyMceElement_editorRef, "f");
|
|
96
|
+
}
|
|
97
|
+
firstUpdated() {
|
|
98
|
+
__classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_loadEditor).call(this);
|
|
99
|
+
}
|
|
100
|
+
disconnectedCallback() {
|
|
101
|
+
super.disconnectedCallback();
|
|
102
|
+
__classPrivateFieldGet(this, _UmbInputTinyMceElement_editorRef, "f")?.destroy();
|
|
103
|
+
}
|
|
104
|
+
async getFormatStyles(stylesheetPaths) {
|
|
105
|
+
if (!stylesheetPaths)
|
|
106
|
+
return [];
|
|
107
|
+
const formatStyles = [];
|
|
108
|
+
const promises = stylesheetPaths.map((path) => __classPrivateFieldGet(this, _UmbInputTinyMceElement_stylesheetRepository, "f")?.requestByUnique(path));
|
|
109
|
+
const stylesheetResponses = await Promise.all(promises);
|
|
110
|
+
stylesheetResponses.forEach(({ data }) => {
|
|
111
|
+
if (!data?.content)
|
|
112
|
+
return;
|
|
113
|
+
const rulesFromContent = __classPrivateFieldGet(this, _UmbInputTinyMceElement_umbStylesheetRuleManager, "f").extractRules(data.content);
|
|
114
|
+
rulesFromContent.forEach((rule) => {
|
|
115
|
+
const r = {
|
|
116
|
+
title: rule.name,
|
|
117
|
+
};
|
|
118
|
+
if (!rule.selector)
|
|
119
|
+
return;
|
|
120
|
+
if (rule.selector.startsWith('.')) {
|
|
121
|
+
r.inline = 'span';
|
|
122
|
+
r.classes = rule.selector.substring(1);
|
|
123
|
+
}
|
|
124
|
+
else if (rule.selector.startsWith('#')) {
|
|
125
|
+
r.inline = 'span';
|
|
126
|
+
r.attributes = { id: rule.selector.substring(1) };
|
|
127
|
+
}
|
|
128
|
+
else if (rule.selector.includes('.')) {
|
|
129
|
+
const [block, ...classes] = rule.selector.split('.');
|
|
130
|
+
r.block = block;
|
|
131
|
+
r.classes = classes.join(' ').replace(/\./g, ' ');
|
|
132
|
+
}
|
|
133
|
+
else if (rule.selector.includes('#')) {
|
|
134
|
+
const [block, id] = rule.selector.split('#');
|
|
135
|
+
r.block = block;
|
|
136
|
+
r.classes = id;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
r.block = rule.selector;
|
|
140
|
+
}
|
|
141
|
+
formatStyles.push(r);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
return formatStyles;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Nothing rendered by default - TinyMCE initialization creates
|
|
148
|
+
* a target div and binds the RTE to that element
|
|
149
|
+
*/
|
|
150
|
+
render() {
|
|
151
|
+
return html `<div class="editor"></div>`;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
_UmbInputTinyMceElement_plugins = new WeakMap();
|
|
155
|
+
_UmbInputTinyMceElement_editorRef = new WeakMap();
|
|
156
|
+
_UmbInputTinyMceElement_stylesheetRepository = new WeakMap();
|
|
157
|
+
_UmbInputTinyMceElement_umbStylesheetRuleManager = new WeakMap();
|
|
158
|
+
_UmbInputTinyMceElement_readonly = new WeakMap();
|
|
159
|
+
_UmbInputTinyMceElement_instances = new WeakSet();
|
|
160
|
+
_UmbInputTinyMceElement_loadEditor = async function _UmbInputTinyMceElement_loadEditor() {
|
|
161
|
+
this.observe(umbExtensionsRegistry.byType('tinyMcePlugin'), async (manifests) => {
|
|
162
|
+
__classPrivateFieldGet(this, _UmbInputTinyMceElement_plugins, "f").length = 0;
|
|
163
|
+
__classPrivateFieldSet(this, _UmbInputTinyMceElement_plugins, await __classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_loadPlugins).call(this, manifests), "f");
|
|
164
|
+
//console.log('#plugins', [this.#plugins, manifests]);
|
|
165
|
+
let config = {};
|
|
166
|
+
manifests.forEach((manifest) => {
|
|
167
|
+
if (manifest.meta?.config) {
|
|
168
|
+
config = umbDeepMerge(manifest.meta.config, config);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
__classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_setTinyConfig).call(this, config);
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
_UmbInputTinyMceElement_loadPlugins =
|
|
175
|
+
/**
|
|
176
|
+
* Load all custom plugins - need to split loading and instantiating as these
|
|
177
|
+
* need the editor instance as a ctor argument. If we load them in the editor
|
|
178
|
+
* setup method, the asynchronous nature means the editor is loaded before
|
|
179
|
+
* the plugins are ready and so are not associated with the editor.
|
|
180
|
+
* @param manifests
|
|
181
|
+
*/
|
|
182
|
+
async function _UmbInputTinyMceElement_loadPlugins(manifests) {
|
|
183
|
+
const promises = [];
|
|
184
|
+
for (const manifest of manifests) {
|
|
185
|
+
if (manifest.js) {
|
|
186
|
+
promises.push(await loadManifestApi(manifest.js));
|
|
187
|
+
}
|
|
188
|
+
if (manifest.api) {
|
|
189
|
+
promises.push(await loadManifestApi(manifest.api));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return await Promise.all(promises); // await all together;
|
|
193
|
+
};
|
|
194
|
+
_UmbInputTinyMceElement_getTinyMceConfig = async function _UmbInputTinyMceElement_getTinyMceConfig() {
|
|
195
|
+
// @ts-ignore
|
|
196
|
+
const { data } = await tryExecute(this, TinyMceService.getConfig({ client: umbHttpClient }));
|
|
197
|
+
if (!data)
|
|
198
|
+
return;
|
|
199
|
+
return data;
|
|
200
|
+
};
|
|
201
|
+
_UmbInputTinyMceElement_setTinyConfig = async function _UmbInputTinyMceElement_setTinyConfig(additionalConfig) {
|
|
202
|
+
//console.log('#setTinyConfig start');
|
|
203
|
+
const dimensions = this.configuration?.getValueByAlias('dimensions');
|
|
204
|
+
const stylesheetPaths = this.configuration?.getValueByAlias('stylesheets') ?? [];
|
|
205
|
+
const styleFormats = await this.getFormatStyles(stylesheetPaths);
|
|
206
|
+
const preValueCustomConfig = this.configuration?.getValueByAlias('customConfig') ?? {};
|
|
207
|
+
// Map the stylesheets with server url
|
|
208
|
+
const stylesheets = stylesheetPaths?.map((stylesheetPath) => `/css${stylesheetPath.replace(/\\/g, '/')}`) ?? [];
|
|
209
|
+
stylesheets.push('/umbraco/backoffice/css/rte-content.css');
|
|
210
|
+
const appSettingsConfig = await __classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_getTinyMceConfig).call(this);
|
|
211
|
+
let apiKey = 'no-origin';
|
|
212
|
+
let version = '6';
|
|
213
|
+
let url = '';
|
|
214
|
+
let excludeList = [];
|
|
215
|
+
if (appSettingsConfig) {
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
apiKey = appSettingsConfig.richTextEditor?.cloudApiKey || 'no-origin';
|
|
218
|
+
if (appSettingsConfig.config?.apikey) {
|
|
219
|
+
apiKey = appSettingsConfig.config?.apikey;
|
|
220
|
+
}
|
|
221
|
+
version = appSettingsConfig.config?.tinyMceVersion || '6';
|
|
222
|
+
// @ts-ignore
|
|
223
|
+
if (apiKey && apiKey != 'no-origin') {
|
|
224
|
+
url = appSettingsConfig.config?.tinyMceUrl || `https://cdn.tiny.cloud/1/${apiKey}/tinymce/${version}/`;
|
|
225
|
+
}
|
|
226
|
+
if (Array.isArray(appSettingsConfig.config?.pluginsToExclude)) {
|
|
227
|
+
excludeList = appSettingsConfig.config?.pluginsToExclude;
|
|
228
|
+
if (!apiKey || apiKey == 'no-origin') {
|
|
229
|
+
// Remove pre-loaded premium plugins if no key present
|
|
230
|
+
excludeList = [...new Set([...excludeList, ...defaultPremiumPluginsList])];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//console.log('#setTinyConfig 1', [appSettingsConfig, this.configuration, additionalConfig]);
|
|
235
|
+
// create an object by merging the configuration onto the fallback config
|
|
236
|
+
const configurationOptions = {
|
|
237
|
+
...defaultFallbackConfig,
|
|
238
|
+
height: dimensions?.height ?? defaultFallbackConfig.height,
|
|
239
|
+
width: dimensions?.width ?? defaultFallbackConfig.width,
|
|
240
|
+
content_css: stylesheets.length ? stylesheets : defaultFallbackConfig.content_css,
|
|
241
|
+
style_formats: styleFormats.length ? styleFormats : defaultFallbackConfig.style_formats,
|
|
242
|
+
};
|
|
243
|
+
// no auto resize when a fixed height is set
|
|
244
|
+
if (!configurationOptions.height) {
|
|
245
|
+
if (Array.isArray(configurationOptions.plugins) && configurationOptions.plugins.includes('autoresize')) {
|
|
246
|
+
configurationOptions.plugins.splice(configurationOptions.plugins.indexOf('autoresize'), 1);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// set the configured plugins if any, otherwise false
|
|
250
|
+
const plugins = this.configuration?.getValueByAlias('plugins');
|
|
251
|
+
if (plugins && plugins.length) {
|
|
252
|
+
if (typeof configurationOptions.plugins === 'string' || Array.isArray(configurationOptions.plugins)) {
|
|
253
|
+
configurationOptions.plugins = plugins.concat(configurationOptions.plugins);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
configurationOptions.plugins = plugins;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Exclude plugins explicitly excluded by configuration
|
|
260
|
+
if (Array.isArray(configurationOptions.plugins)) {
|
|
261
|
+
configurationOptions.plugins = configurationOptions.plugins.filter((item) => !excludeList.includes(item));
|
|
262
|
+
}
|
|
263
|
+
// set the configured toolbar if any, otherwise false
|
|
264
|
+
const toolbar = this.configuration?.getValueByAlias('toolbar');
|
|
265
|
+
if (toolbar?.length) {
|
|
266
|
+
configurationOptions.toolbar = toolbar.join(' ');
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
configurationOptions.toolbar = false;
|
|
270
|
+
}
|
|
271
|
+
// set the configured inline mode
|
|
272
|
+
const mode = this.configuration?.getValueByAlias('mode');
|
|
273
|
+
if (mode?.toLocaleLowerCase() === 'inline') {
|
|
274
|
+
configurationOptions.inline = true;
|
|
275
|
+
}
|
|
276
|
+
// set the maximum image size
|
|
277
|
+
const maxImageSize = this.configuration?.getValueByAlias('maxImageSize');
|
|
278
|
+
if (maxImageSize) {
|
|
279
|
+
configurationOptions.maxImageSize = maxImageSize;
|
|
280
|
+
}
|
|
281
|
+
//console.log('#setTinyConfig 2', [configurationOptions]);
|
|
282
|
+
// set the default values that will not be modified via configuration
|
|
283
|
+
let config = {
|
|
284
|
+
autoresize_bottom_margin: 10,
|
|
285
|
+
body_class: 'umb-rte',
|
|
286
|
+
contextMenu: false,
|
|
287
|
+
inline_boundaries_selector: 'a[href],code,.mce-annotation,.umb-embed-holder,.umb-macro-holder',
|
|
288
|
+
menubar: false,
|
|
289
|
+
paste_remove_styles_if_webkit: true,
|
|
290
|
+
paste_preprocess: pastePreProcessHandler,
|
|
291
|
+
relative_urls: false,
|
|
292
|
+
resize: false,
|
|
293
|
+
statusbar: false,
|
|
294
|
+
setup: (editor) => __classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_editorSetup).call(this, editor),
|
|
295
|
+
target: this._editorElement,
|
|
296
|
+
paste_data_images: false,
|
|
297
|
+
language: __classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_getLanguage).call(this),
|
|
298
|
+
promotion: false,
|
|
299
|
+
convert_unsafe_embeds: true, // [JOV] Workaround for CVE-2024-29881
|
|
300
|
+
readonly: __classPrivateFieldGet(this, _UmbInputTinyMceElement_readonly, "f"),
|
|
301
|
+
// Extend with configuration options
|
|
302
|
+
...configurationOptions,
|
|
303
|
+
};
|
|
304
|
+
if (appSettingsConfig && url.length > 0) {
|
|
305
|
+
config.base_url = url;
|
|
306
|
+
}
|
|
307
|
+
// Extend with additional configuration options
|
|
308
|
+
if (additionalConfig) {
|
|
309
|
+
config = umbDeepMerge(additionalConfig, config);
|
|
310
|
+
}
|
|
311
|
+
if (appSettingsConfig) {
|
|
312
|
+
if (appSettingsConfig.richTextEditor) {
|
|
313
|
+
config = umbDeepMerge(appSettingsConfig.richTextEditor.customConfig, config);
|
|
314
|
+
}
|
|
315
|
+
if (appSettingsConfig.config) {
|
|
316
|
+
config = umbDeepMerge(appSettingsConfig.config.customConfig, config);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (preValueCustomConfig) {
|
|
320
|
+
config = umbDeepMerge(preValueCustomConfig, config);
|
|
321
|
+
}
|
|
322
|
+
// Loop through plugins and call extendEditorConfig if it exists to allow plugins to
|
|
323
|
+
// setup some advanced config like javascript before the editor is initialized.
|
|
324
|
+
const promises = [];
|
|
325
|
+
for (const pluginClass of __classPrivateFieldGet(this, _UmbInputTinyMceElement_plugins, "f")) {
|
|
326
|
+
if (pluginClass) {
|
|
327
|
+
if (typeof pluginClass.extendEditorConfig === 'function') {
|
|
328
|
+
promises.push(await pluginClass.extendEditorConfig(config));
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
await Promise.all(promises); // await all together;
|
|
333
|
+
//console.log('#setTinyConfig before init', [config]);
|
|
334
|
+
__classPrivateFieldGet(this, _UmbInputTinyMceElement_editorRef, "f")?.destroy();
|
|
335
|
+
const editors = await renderEditor(config).catch((error) => {
|
|
336
|
+
console.error('Failed to render TinyMCE', error);
|
|
337
|
+
return [];
|
|
338
|
+
});
|
|
339
|
+
__classPrivateFieldSet(this, _UmbInputTinyMceElement_editorRef, editors.pop(), "f");
|
|
340
|
+
// console.log('#setTinyConfig end');
|
|
341
|
+
};
|
|
342
|
+
_UmbInputTinyMceElement_getLanguage = function _UmbInputTinyMceElement_getLanguage() {
|
|
343
|
+
const localeId = this.localize.lang();
|
|
344
|
+
//try matching the language using full locale format
|
|
345
|
+
let languageMatch = availableLanguages.find((x) => localeId?.localeCompare(x) === 0);
|
|
346
|
+
//if no matches, try matching using only the language
|
|
347
|
+
if (!languageMatch) {
|
|
348
|
+
const localeParts = localeId?.split('_');
|
|
349
|
+
if (localeParts) {
|
|
350
|
+
languageMatch = availableLanguages.find((x) => x === localeParts[0]);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return languageMatch;
|
|
354
|
+
};
|
|
355
|
+
_UmbInputTinyMceElement_editorSetup = async function _UmbInputTinyMceElement_editorSetup(editor) {
|
|
356
|
+
//console.log('#editorSetup start');
|
|
357
|
+
editor.suffix = '.min';
|
|
358
|
+
// define keyboard shortcuts
|
|
359
|
+
editor.addShortcut('Ctrl+S', '', () => this.dispatchEvent(new CustomEvent('rte.shortcut.save', { composed: true, bubbles: true })));
|
|
360
|
+
editor.addShortcut('Ctrl+P', '', () => this.dispatchEvent(new CustomEvent('rte.shortcut.saveAndPublish', { composed: true, bubbles: true })));
|
|
361
|
+
// bind editor events
|
|
362
|
+
editor.on('init', () => __classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_onInit).call(this, editor));
|
|
363
|
+
editor.on('Change', () => __classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_onChange).call(this, editor.getContent()));
|
|
364
|
+
editor.on('Dirty', () => __classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_onChange).call(this, editor.getContent()));
|
|
365
|
+
editor.on('Keyup', () => __classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_onChange).call(this, editor.getContent()));
|
|
366
|
+
editor.on('focus', () => this.dispatchEvent(new CustomEvent('umb-rte-focus', { composed: true, bubbles: true })));
|
|
367
|
+
editor.on('blur', () => {
|
|
368
|
+
__classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_onChange).call(this, editor.getContent());
|
|
369
|
+
this.dispatchEvent(new CustomEvent('umb-rte-blur', { composed: true, bubbles: true }));
|
|
370
|
+
});
|
|
371
|
+
editor.on('ObjectResized', (e) => {
|
|
372
|
+
onResize(e);
|
|
373
|
+
__classPrivateFieldGet(this, _UmbInputTinyMceElement_instances, "m", _UmbInputTinyMceElement_onChange).call(this, editor.getContent());
|
|
374
|
+
});
|
|
375
|
+
editor.on('SetContent', () => {
|
|
376
|
+
/**
|
|
377
|
+
* Prevent injecting arbitrary JavaScript execution in on-attributes.
|
|
378
|
+
*
|
|
379
|
+
*/
|
|
380
|
+
const allNodes = Array.from(editor.dom.doc.getElementsByTagName('*'));
|
|
381
|
+
allNodes.forEach((node) => {
|
|
382
|
+
for (const attr of node.attributes) {
|
|
383
|
+
if (attr.name.startsWith('on')) {
|
|
384
|
+
node.removeAttribute(attr.name);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
// instantiate plugins to ensure they are available before setting up the editor.
|
|
390
|
+
// Plugins require a reference to the current editor as a param, so can not
|
|
391
|
+
// be instantiated until we have an editor
|
|
392
|
+
for (const plugin of __classPrivateFieldGet(this, _UmbInputTinyMceElement_plugins, "f")) {
|
|
393
|
+
if (plugin) {
|
|
394
|
+
// [v15]: This might be improved by changing to `createExtensionApi` and avoiding the `#loadPlugins` method altogether, but that would require a breaking change
|
|
395
|
+
// because that function sends the UmbControllerHost as the first argument, which is not the case here.
|
|
396
|
+
const instance = new plugin({ host: this, editor });
|
|
397
|
+
// [Jason]: Added this to allow for some initialization in the plugins before the TinyMCE editor is initialized
|
|
398
|
+
if (typeof instance.init === 'function') {
|
|
399
|
+
await instance.init(); // await only if async init exists
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
//console.log('#editorSetup end');
|
|
404
|
+
};
|
|
405
|
+
_UmbInputTinyMceElement_onInit = function _UmbInputTinyMceElement_onInit(editor) {
|
|
406
|
+
//enable browser based spell checking
|
|
407
|
+
editor.getBody().setAttribute('spellcheck', 'true');
|
|
408
|
+
uriAttributeSanitizer(editor);
|
|
409
|
+
editor.setContent(typeof this.value === 'string' ? this.value : '');
|
|
410
|
+
};
|
|
411
|
+
_UmbInputTinyMceElement_onChange = function _UmbInputTinyMceElement_onChange(value) {
|
|
412
|
+
if (this.value === value)
|
|
413
|
+
return;
|
|
414
|
+
this.value = value;
|
|
415
|
+
this.dispatchEvent(new UmbChangeEvent());
|
|
416
|
+
};
|
|
417
|
+
UmbInputTinyMceElement.styles = [
|
|
418
|
+
css `
|
|
419
|
+
.tox-tinymce {
|
|
420
|
+
position: relative;
|
|
421
|
+
min-height: 100px;
|
|
422
|
+
border-radius: 0;
|
|
423
|
+
border: var(--uui-input-border-width, 1px) solid var(--uui-input-border-color, var(--uui-color-border, #d8d7d9));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.tox-tinymce-fullscreen {
|
|
427
|
+
position: absolute;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/* FIXME: Remove this workaround when https://github.com/tinymce/tinymce/issues/6431 has been fixed */
|
|
431
|
+
.tox .tox-collection__item-label {
|
|
432
|
+
line-height: 1 !important;
|
|
433
|
+
}
|
|
434
|
+
`,
|
|
435
|
+
];
|
|
436
|
+
__decorate([
|
|
437
|
+
property({ attribute: false })
|
|
438
|
+
], UmbInputTinyMceElement.prototype, "configuration", void 0);
|
|
439
|
+
__decorate([
|
|
440
|
+
property({ type: Boolean, reflect: true })
|
|
441
|
+
], UmbInputTinyMceElement.prototype, "readonly", null);
|
|
442
|
+
__decorate([
|
|
443
|
+
query('.editor', true)
|
|
444
|
+
], UmbInputTinyMceElement.prototype, "_editorElement", void 0);
|
|
445
|
+
UmbInputTinyMceElement = __decorate([
|
|
446
|
+
customElement('umb-input-tiny-mce')
|
|
447
|
+
], UmbInputTinyMceElement);
|
|
448
|
+
export { UmbInputTinyMceElement };
|
|
449
|
+
export default UmbInputTinyMceElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-tiny-mce.handlers.d.ts","sourceRoot":"","sources":["../../../src/components/input-tiny-mce/input-tiny-mce.handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,eAAO,MAAM,sBAAsB,EAAE,gBAAgB,CAAC,kBAAkB,CAOvE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const pastePreProcessHandler = (_editor, args) => {
|
|
2
|
+
// Remove spans
|
|
3
|
+
args.content = args.content.replace(/<\s*span[^>]*>(.*?)<\s*\/\s*span>/g, '$1');
|
|
4
|
+
// Convert b to strong.
|
|
5
|
+
args.content = args.content.replace(/<\s*b([^>]*)>(.*?)<\s*\/\s*b([^>]*)>/g, '<strong$1>$2</strong$3>');
|
|
6
|
+
// convert i to em
|
|
7
|
+
args.content = args.content.replace(/<\s*i([^>]*)>(.*?)<\s*\/\s*i([^>]*)>/g, '<em$1>$2</em$3>');
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-tiny-mce.languages.d.ts","sourceRoot":"","sources":["../../../src/components/input-tiny-mce/input-tiny-mce.languages.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,UA6E9B,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const availableLanguages = [
|
|
2
|
+
'ar',
|
|
3
|
+
'ar_SA',
|
|
4
|
+
'hy',
|
|
5
|
+
'az',
|
|
6
|
+
'eu',
|
|
7
|
+
'be',
|
|
8
|
+
'bn_BD',
|
|
9
|
+
'bs',
|
|
10
|
+
'bg_BG',
|
|
11
|
+
'ca',
|
|
12
|
+
'zh_CN',
|
|
13
|
+
'zh_TW',
|
|
14
|
+
'hr',
|
|
15
|
+
'cs',
|
|
16
|
+
'da',
|
|
17
|
+
'dv',
|
|
18
|
+
'nl',
|
|
19
|
+
'en_CA',
|
|
20
|
+
'en_GB',
|
|
21
|
+
'et',
|
|
22
|
+
'fo',
|
|
23
|
+
'fi',
|
|
24
|
+
'fr_FR',
|
|
25
|
+
'gd',
|
|
26
|
+
'gl',
|
|
27
|
+
'ka_GE',
|
|
28
|
+
'de',
|
|
29
|
+
'de_AT',
|
|
30
|
+
'el',
|
|
31
|
+
'he_IL',
|
|
32
|
+
'hi_IN',
|
|
33
|
+
'hu_HU',
|
|
34
|
+
'is_IS',
|
|
35
|
+
'id',
|
|
36
|
+
'it',
|
|
37
|
+
'ja',
|
|
38
|
+
'kab',
|
|
39
|
+
'kk',
|
|
40
|
+
'km_KH',
|
|
41
|
+
'ko_KR',
|
|
42
|
+
'ku',
|
|
43
|
+
'ku_IQ',
|
|
44
|
+
'lv',
|
|
45
|
+
'lt',
|
|
46
|
+
'lb',
|
|
47
|
+
'ml',
|
|
48
|
+
'ml_IN',
|
|
49
|
+
'mn_MN',
|
|
50
|
+
'nb_NO',
|
|
51
|
+
'fa',
|
|
52
|
+
'fa_IR',
|
|
53
|
+
'pl',
|
|
54
|
+
'pt_BR',
|
|
55
|
+
'pt_PT',
|
|
56
|
+
'ro',
|
|
57
|
+
'ru',
|
|
58
|
+
'sr',
|
|
59
|
+
'si_LK',
|
|
60
|
+
'sk',
|
|
61
|
+
'sl_SI',
|
|
62
|
+
'es',
|
|
63
|
+
'es_MX',
|
|
64
|
+
'sv_SE',
|
|
65
|
+
'tg',
|
|
66
|
+
'ta',
|
|
67
|
+
'ta_IN',
|
|
68
|
+
'tt',
|
|
69
|
+
'th_TH',
|
|
70
|
+
'tr',
|
|
71
|
+
'tr_TR',
|
|
72
|
+
'ug',
|
|
73
|
+
'uk',
|
|
74
|
+
'uk_UA',
|
|
75
|
+
'vi',
|
|
76
|
+
'vi_VN',
|
|
77
|
+
'cy',
|
|
78
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Editor } from '@umbraco-cms/backoffice/external/tinymce';
|
|
2
|
+
/**
|
|
3
|
+
* Setup sanitization for preventing injecting arbitrary JavaScript execution in attributes:
|
|
4
|
+
* https://github.com/advisories/GHSA-w7jx-j77m-wp65
|
|
5
|
+
* https://github.com/advisories/GHSA-5vm8-hhgr-jcjp
|
|
6
|
+
* @param editor
|
|
7
|
+
*/
|
|
8
|
+
export declare const uriAttributeSanitizer: (editor: Editor) => void;
|
|
9
|
+
//# sourceMappingURL=input-tiny-mce.sanitizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-tiny-mce.sanitizer.d.ts","sourceRoot":"","sources":["../../../src/components/input-tiny-mce/input-tiny-mce.sanitizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,SA6CnD,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup sanitization for preventing injecting arbitrary JavaScript execution in attributes:
|
|
3
|
+
* https://github.com/advisories/GHSA-w7jx-j77m-wp65
|
|
4
|
+
* https://github.com/advisories/GHSA-5vm8-hhgr-jcjp
|
|
5
|
+
* @param editor
|
|
6
|
+
*/
|
|
7
|
+
export const uriAttributeSanitizer = (editor) => {
|
|
8
|
+
const uriAttributesToSanitize = ['src', 'href', 'data', 'background', 'action', 'formaction', 'poster', 'xlink:href'];
|
|
9
|
+
const parseUri = (function () {
|
|
10
|
+
// Encapsulated JS logic.
|
|
11
|
+
const safeSvgDataUrlElements = ['img', 'video'];
|
|
12
|
+
const scriptUriRegExp = /((java|vb)script|mhtml):/i;
|
|
13
|
+
// eslint-disable-next-line no-control-regex
|
|
14
|
+
const trimRegExp = /[\s\u0000-\u001F]+/g;
|
|
15
|
+
const isInvalidUri = (uri, tagName) => {
|
|
16
|
+
if (/^data:image\//i.test(uri)) {
|
|
17
|
+
return safeSvgDataUrlElements.indexOf(tagName) !== -1 && /^data:image\/svg\+xml/i.test(uri);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return /^data:/i.test(uri);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return function parseUri(uri, tagName) {
|
|
24
|
+
uri = uri.replace(trimRegExp, '');
|
|
25
|
+
uri = decodeURIComponent(uri);
|
|
26
|
+
if (scriptUriRegExp.test(uri)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (isInvalidUri(uri, tagName)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
return uri;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
editor.serializer.addAttributeFilter('uriAttributesToSanitize', function (nodes) {
|
|
36
|
+
nodes.forEach(function (node) {
|
|
37
|
+
if (!node.attributes)
|
|
38
|
+
return;
|
|
39
|
+
for (const attr of node.attributes) {
|
|
40
|
+
const attrName = attr.name.toLowerCase();
|
|
41
|
+
if (uriAttributesToSanitize.indexOf(attrName) !== -1) {
|
|
42
|
+
attr.value = parseUri(attr.value, node.name) ?? '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { UmbInputTinyMceElement } from './input-tiny-mce.element.js';
|
|
2
|
+
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
|
|
3
|
+
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
|
|
4
|
+
import type { Editor } from '@umbraco-cms/backoffice/external/tinymce';
|
|
5
|
+
import type { UmbPropertyEditorConfigCollection } from '@umbraco-cms/backoffice/property-editor';
|
|
6
|
+
import type { ClassConstructor } from '@umbraco-cms/backoffice/extension-api';
|
|
7
|
+
export declare class UmbTinyMcePluginBase extends UmbControllerBase implements UmbApi, TinyMcePluginInterface {
|
|
8
|
+
editor: Editor;
|
|
9
|
+
configuration?: UmbPropertyEditorConfigCollection;
|
|
10
|
+
constructor(arg: TinyMcePluginArguments);
|
|
11
|
+
static extendEditorConfig(_config: any): Promise<void>;
|
|
12
|
+
init(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export type TinyMcePluginArguments = {
|
|
15
|
+
host: UmbInputTinyMceElement;
|
|
16
|
+
editor: Editor;
|
|
17
|
+
};
|
|
18
|
+
export interface TinyMcePluginInterface {
|
|
19
|
+
init(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export interface UmbTinyMcePluginClass extends ClassConstructor<UmbTinyMcePluginBase> {
|
|
22
|
+
extendEditorConfig?: (_config: any) => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=tiny-mce-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiny-mce-plugin.d.ts","sourceRoot":"","sources":["../../../src/components/input-tiny-mce/tiny-mce-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AACjG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,qBAAa,oBAAqB,SAAQ,iBAAkB,YAAW,MAAM,EAAE,sBAAsB;IACpG,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,iCAAiC,CAAC;gBAEtC,GAAG,EAAE,sBAAsB;WAO1B,kBAAkB,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG3B;AAED,MAAM,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AACF,MAAM,WAAW,sBAAsB;IACtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AACD,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB,CAAC,oBAAoB,CAAC;IACpF,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
|
|
2
|
+
export class UmbTinyMcePluginBase extends UmbControllerBase {
|
|
3
|
+
constructor(arg) {
|
|
4
|
+
super(arg.host);
|
|
5
|
+
this.editor = arg.editor;
|
|
6
|
+
this.configuration = arg.host.configuration;
|
|
7
|
+
}
|
|
8
|
+
// Called before the editor is created
|
|
9
|
+
static async extendEditorConfig(_config) {
|
|
10
|
+
// No-op by default
|
|
11
|
+
}
|
|
12
|
+
// Default (empty) implementation so subclasses can override it
|
|
13
|
+
async init() {
|
|
14
|
+
// No-op by default
|
|
15
|
+
}
|
|
16
|
+
}
|