@dotcms/uve 0.0.1-beta.9 → 1.0.0

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/index.esm.js CHANGED
@@ -1,83 +1,3 @@
1
- import { UVE_MODE } from './types.esm.js';
2
- import { __UVE_EVENT_ERROR_FALLBACK__, __UVE_EVENTS__ } from './internal.esm.js';
3
-
4
- /**
5
- * Gets the current state of the Universal Visual Editor (UVE).
6
- *
7
- * This function checks if the code is running inside the DotCMS Universal Visual Editor
8
- * and returns information about its current state, including the editor mode.
9
- *
10
- * @export
11
- * @return {UVEState | undefined} Returns the UVE state object if running inside the editor,
12
- * undefined otherwise.
13
- *
14
- * The state includes:
15
- * - mode: The current editor mode (preview, edit, live)
16
- * - languageId: The language ID of the current page setted on the UVE
17
- * - persona: The persona of the current page setted on the UVE
18
- * - variantName: The name of the current variant
19
- * - experimentId: The ID of the current experiment
20
- * - publishDate: The publish date of the current page setted on the UVE
21
- *
22
- * @note The absence of any of these properties means that the value is the default one.
23
- *
24
- * @example
25
- * ```ts
26
- * const editorState = getUVEState();
27
- * if (editorState?.mode === 'edit') {
28
- * // Enable editing features
29
- * }
30
- * ```
31
- */
32
- function getUVEState() {
33
- if (typeof window === 'undefined' || window.parent === window || !window.location) {
34
- return;
35
- }
36
- const url = new URL(window.location.href);
37
- const possibleModes = Object.values(UVE_MODE);
38
- let mode = url.searchParams.get('mode') ?? UVE_MODE.EDIT;
39
- const languageId = url.searchParams.get('language_id');
40
- const persona = url.searchParams.get('personaId');
41
- const variantName = url.searchParams.get('variantName');
42
- const experimentId = url.searchParams.get('experimentId');
43
- const publishDate = url.searchParams.get('publishDate');
44
- if (!possibleModes.includes(mode)) {
45
- mode = UVE_MODE.EDIT;
46
- }
47
- return {
48
- mode,
49
- languageId,
50
- persona,
51
- variantName,
52
- experimentId,
53
- publishDate
54
- };
55
- }
56
- /**
57
- * Creates a subscription to a UVE event.
58
- *
59
- * @param {string} event - The event to subscribe to.
60
- * @param {UVECallback} callback - The callback to call when the event is triggered.
61
- * @return {UnsubscribeUVE | undefined} The unsubscribe function if the event is valid, undefined otherwise.
62
- *
63
- * @example
64
- * ```ts
65
- * const unsubscribeChanges = createUVESubscription('changes', (payload) => {
66
- * console.log(payload);
67
- * });
68
- * ```
69
- */
70
- function createUVESubscription(event, callback) {
71
- if (!getUVEState()) {
72
- console.warn('UVE Subscription: Not running inside UVE');
73
- return __UVE_EVENT_ERROR_FALLBACK__(event);
74
- }
75
- const eventCallback = __UVE_EVENTS__[event];
76
- if (!eventCallback) {
77
- console.error(`UVE Subscription: Event ${event} not found`);
78
- return __UVE_EVENT_ERROR_FALLBACK__(event);
79
- }
80
- return eventCallback(callback);
81
- }
82
-
83
- export { createUVESubscription, getUVEState };
1
+ export { c as createUVESubscription, e as editContentlet, a as enableBlockEditorInline, g as getUVEState, i as initInlineEditing, b as initUVE, r as reorderMenu, s as sendMessageToUVE, u as updateNavigation } from './public.esm.js';
2
+ import '@dotcms/types';
3
+ import '@dotcms/types/internal';
package/internal.cjs.js CHANGED
@@ -1,76 +1,103 @@
1
1
  'use strict';
2
2
 
3
+ var _public = require('./public.cjs.js');
4
+ require('@dotcms/types');
5
+ require('@dotcms/types/internal');
6
+
3
7
  /**
4
- * Actions received from the dotcms editor
8
+ * TinyMCE default config across all versions
5
9
  *
6
- * @export
7
- * @enum {number}
10
+ * @internal
8
11
  */
9
- exports.__DOTCMS_UVE_EVENT__ = void 0;
10
- (function (__DOTCMS_UVE_EVENT__) {
11
- /**
12
- * Request to page to reload
13
- */
14
- __DOTCMS_UVE_EVENT__["UVE_RELOAD_PAGE"] = "uve-reload-page";
15
- /**
16
- * Request the bounds for the elements
17
- */
18
- __DOTCMS_UVE_EVENT__["UVE_REQUEST_BOUNDS"] = "uve-request-bounds";
19
- /**
20
- * Received pong from the editor
21
- */
22
- __DOTCMS_UVE_EVENT__["UVE_EDITOR_PONG"] = "uve-editor-pong";
23
- /**
24
- * Received scroll event trigger from the editor
25
- */
26
- __DOTCMS_UVE_EVENT__["UVE_SCROLL_INSIDE_IFRAME"] = "uve-scroll-inside-iframe";
27
- /**
28
- * Set the page data
29
- */
30
- __DOTCMS_UVE_EVENT__["UVE_SET_PAGE_DATA"] = "uve-set-page-data";
31
- /**
32
- * Copy contentlet inline editing success
33
- */
34
- __DOTCMS_UVE_EVENT__["UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS"] = "uve-copy-contentlet-inline-editing-success";
35
- })(exports.__DOTCMS_UVE_EVENT__ || (exports.__DOTCMS_UVE_EVENT__ = {}));
36
-
37
- // TODO: WE NEED TO LOOK FOR ALL THE NOTIFY_CLIENT EVENTS AND ADD THEM TO THE UVE_EVENTS CONSTANT WHEN WE MIGRATE THE EDITOR TO THE NEW UVE LIBRARY
12
+ const __DEFAULT_TINYMCE_CONFIG__ = {
13
+ menubar: false,
14
+ inline: true,
15
+ valid_styles: {
16
+ '*': 'font-size,font-family,color,text-decoration,text-align'
17
+ },
18
+ powerpaste_word_import: 'clean',
19
+ powerpaste_html_import: 'clean',
20
+ suffix: '.min' // Suffix to use when loading resources
21
+ };
38
22
  /**
39
- * Events that can be subscribed to in the UVE
23
+ * TinyMCE config to use per mode
40
24
  *
41
25
  * @internal
42
- * @type {Record<string, UVEEvent>}
43
26
  */
44
- const __UVE_EVENTS__ = {
45
- changes: callback => {
46
- const messageCallback = event => {
47
- if (event.data.name === exports.__DOTCMS_UVE_EVENT__.UVE_SET_PAGE_DATA) {
48
- callback(event.data.payload);
49
- }
50
- };
51
- window.addEventListener('message', messageCallback);
52
- return {
53
- unsubscribe: () => {
54
- window.removeEventListener('message', messageCallback);
55
- },
56
- event: 'changes'
57
- };
27
+ const __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ = {
28
+ full: {
29
+ plugins: 'link lists autolink charmap',
30
+ toolbar: ['styleselect undo redo | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | hr charmap removeformat | link'],
31
+ style_formats: [{
32
+ title: 'Paragraph',
33
+ format: 'p'
34
+ }, {
35
+ title: 'Header 1',
36
+ format: 'h1'
37
+ }, {
38
+ title: 'Header 2',
39
+ format: 'h2'
40
+ }, {
41
+ title: 'Header 3',
42
+ format: 'h3'
43
+ }, {
44
+ title: 'Header 4',
45
+ format: 'h4'
46
+ }, {
47
+ title: 'Header 5',
48
+ format: 'h5'
49
+ }, {
50
+ title: 'Header 6',
51
+ format: 'h6'
52
+ }, {
53
+ title: 'Pre',
54
+ format: 'pre'
55
+ }, {
56
+ title: 'Code',
57
+ format: 'code'
58
+ }]
59
+ },
60
+ plain: {
61
+ plugins: '',
62
+ toolbar: ''
63
+ },
64
+ minimal: {
65
+ plugins: 'link autolink',
66
+ toolbar: 'bold italic underline | link',
67
+ valid_elements: 'strong,em,span[style],a[href]'
58
68
  }
59
69
  };
60
70
  /**
61
- * Default UVE event
71
+ * TinyMCE path
62
72
  *
63
- * @param {string} event - The event to subscribe to.
64
73
  * @internal
65
74
  */
66
- const __UVE_EVENT_ERROR_FALLBACK__ = event => {
67
- return {
68
- unsubscribe: () => {
69
- /* do nothing */
70
- },
71
- event
72
- };
73
- };
75
+ const __TINYMCE_PATH_ON_DOTCMS__ = '/ext/tinymcev7/tinymce.min.js';
74
76
 
75
- exports.__UVE_EVENTS__ = __UVE_EVENTS__;
76
- exports.__UVE_EVENT_ERROR_FALLBACK__ = __UVE_EVENT_ERROR_FALLBACK__;
77
+ exports.CUSTOM_NO_COMPONENT = _public.CUSTOM_NO_COMPONENT;
78
+ exports.DEVELOPMENT_MODE = _public.DEVELOPMENT_MODE;
79
+ exports.EMPTY_CONTAINER_STYLE_ANGULAR = _public.EMPTY_CONTAINER_STYLE_ANGULAR;
80
+ exports.EMPTY_CONTAINER_STYLE_REACT = _public.EMPTY_CONTAINER_STYLE_REACT;
81
+ exports.END_CLASS = _public.END_CLASS;
82
+ exports.PRODUCTION_MODE = _public.PRODUCTION_MODE;
83
+ exports.START_CLASS = _public.START_CLASS;
84
+ exports.__UVE_EVENTS__ = _public.__UVE_EVENTS__;
85
+ exports.__UVE_EVENT_ERROR_FALLBACK__ = _public.__UVE_EVENT_ERROR_FALLBACK__;
86
+ exports.combineClasses = _public.combineClasses;
87
+ exports.computeScrollIsInBottom = _public.computeScrollIsInBottom;
88
+ exports.findDotCMSElement = _public.findDotCMSElement;
89
+ exports.findDotCMSVTLData = _public.findDotCMSVTLData;
90
+ exports.getClosestDotCMSContainerData = _public.getClosestDotCMSContainerData;
91
+ exports.getColumnPositionClasses = _public.getColumnPositionClasses;
92
+ exports.getContainersData = _public.getContainersData;
93
+ exports.getContentletsInContainer = _public.getContentletsInContainer;
94
+ exports.getDotCMSContainerData = _public.getDotCMSContainerData;
95
+ exports.getDotCMSContentletsBound = _public.getDotCMSContentletsBound;
96
+ exports.getDotCMSPageBounds = _public.getDotCMSPageBounds;
97
+ exports.getDotContainerAttributes = _public.getDotContainerAttributes;
98
+ exports.getDotContentletAttributes = _public.getDotContentletAttributes;
99
+ exports.isValidBlocks = _public.isValidBlocks;
100
+ exports.setBounds = _public.setBounds;
101
+ exports.__BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ = __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__;
102
+ exports.__DEFAULT_TINYMCE_CONFIG__ = __DEFAULT_TINYMCE_CONFIG__;
103
+ exports.__TINYMCE_PATH_ON_DOTCMS__ = __TINYMCE_PATH_ON_DOTCMS__;
package/internal.esm.js CHANGED
@@ -1,73 +1,75 @@
1
+ export { C as CUSTOM_NO_COMPONENT, D as DEVELOPMENT_MODE, h as EMPTY_CONTAINER_STYLE_ANGULAR, f as EMPTY_CONTAINER_STYLE_REACT, E as END_CLASS, P as PRODUCTION_MODE, S as START_CLASS, _ as __UVE_EVENTS__, d as __UVE_EVENT_ERROR_FALLBACK__, q as combineClasses, p as computeScrollIsInBottom, n as findDotCMSElement, o as findDotCMSVTLData, m as getClosestDotCMSContainerData, t as getColumnPositionClasses, w as getContainersData, x as getContentletsInContainer, l as getDotCMSContainerData, k as getDotCMSContentletsBound, j as getDotCMSPageBounds, y as getDotContainerAttributes, v as getDotContentletAttributes, A as isValidBlocks, z as setBounds } from './public.esm.js';
2
+ import '@dotcms/types';
3
+ import '@dotcms/types/internal';
4
+
1
5
  /**
2
- * Actions received from the dotcms editor
6
+ * TinyMCE default config across all versions
3
7
  *
4
- * @export
5
- * @enum {number}
8
+ * @internal
6
9
  */
7
- var __DOTCMS_UVE_EVENT__;
8
- (function (__DOTCMS_UVE_EVENT__) {
9
- /**
10
- * Request to page to reload
11
- */
12
- __DOTCMS_UVE_EVENT__["UVE_RELOAD_PAGE"] = "uve-reload-page";
13
- /**
14
- * Request the bounds for the elements
15
- */
16
- __DOTCMS_UVE_EVENT__["UVE_REQUEST_BOUNDS"] = "uve-request-bounds";
17
- /**
18
- * Received pong from the editor
19
- */
20
- __DOTCMS_UVE_EVENT__["UVE_EDITOR_PONG"] = "uve-editor-pong";
21
- /**
22
- * Received scroll event trigger from the editor
23
- */
24
- __DOTCMS_UVE_EVENT__["UVE_SCROLL_INSIDE_IFRAME"] = "uve-scroll-inside-iframe";
25
- /**
26
- * Set the page data
27
- */
28
- __DOTCMS_UVE_EVENT__["UVE_SET_PAGE_DATA"] = "uve-set-page-data";
29
- /**
30
- * Copy contentlet inline editing success
31
- */
32
- __DOTCMS_UVE_EVENT__["UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS"] = "uve-copy-contentlet-inline-editing-success";
33
- })(__DOTCMS_UVE_EVENT__ || (__DOTCMS_UVE_EVENT__ = {}));
34
-
35
- // TODO: WE NEED TO LOOK FOR ALL THE NOTIFY_CLIENT EVENTS AND ADD THEM TO THE UVE_EVENTS CONSTANT WHEN WE MIGRATE THE EDITOR TO THE NEW UVE LIBRARY
10
+ const __DEFAULT_TINYMCE_CONFIG__ = {
11
+ menubar: false,
12
+ inline: true,
13
+ valid_styles: {
14
+ '*': 'font-size,font-family,color,text-decoration,text-align'
15
+ },
16
+ powerpaste_word_import: 'clean',
17
+ powerpaste_html_import: 'clean',
18
+ suffix: '.min' // Suffix to use when loading resources
19
+ };
36
20
  /**
37
- * Events that can be subscribed to in the UVE
21
+ * TinyMCE config to use per mode
38
22
  *
39
23
  * @internal
40
- * @type {Record<string, UVEEvent>}
41
24
  */
42
- const __UVE_EVENTS__ = {
43
- changes: callback => {
44
- const messageCallback = event => {
45
- if (event.data.name === __DOTCMS_UVE_EVENT__.UVE_SET_PAGE_DATA) {
46
- callback(event.data.payload);
47
- }
48
- };
49
- window.addEventListener('message', messageCallback);
50
- return {
51
- unsubscribe: () => {
52
- window.removeEventListener('message', messageCallback);
53
- },
54
- event: 'changes'
55
- };
25
+ const __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ = {
26
+ full: {
27
+ plugins: 'link lists autolink charmap',
28
+ toolbar: ['styleselect undo redo | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | hr charmap removeformat | link'],
29
+ style_formats: [{
30
+ title: 'Paragraph',
31
+ format: 'p'
32
+ }, {
33
+ title: 'Header 1',
34
+ format: 'h1'
35
+ }, {
36
+ title: 'Header 2',
37
+ format: 'h2'
38
+ }, {
39
+ title: 'Header 3',
40
+ format: 'h3'
41
+ }, {
42
+ title: 'Header 4',
43
+ format: 'h4'
44
+ }, {
45
+ title: 'Header 5',
46
+ format: 'h5'
47
+ }, {
48
+ title: 'Header 6',
49
+ format: 'h6'
50
+ }, {
51
+ title: 'Pre',
52
+ format: 'pre'
53
+ }, {
54
+ title: 'Code',
55
+ format: 'code'
56
+ }]
57
+ },
58
+ plain: {
59
+ plugins: '',
60
+ toolbar: ''
61
+ },
62
+ minimal: {
63
+ plugins: 'link autolink',
64
+ toolbar: 'bold italic underline | link',
65
+ valid_elements: 'strong,em,span[style],a[href]'
56
66
  }
57
67
  };
58
68
  /**
59
- * Default UVE event
69
+ * TinyMCE path
60
70
  *
61
- * @param {string} event - The event to subscribe to.
62
71
  * @internal
63
72
  */
64
- const __UVE_EVENT_ERROR_FALLBACK__ = event => {
65
- return {
66
- unsubscribe: () => {
67
- /* do nothing */
68
- },
69
- event
70
- };
71
- };
73
+ const __TINYMCE_PATH_ON_DOTCMS__ = '/ext/tinymcev7/tinymce.min.js';
72
74
 
73
- export { __DOTCMS_UVE_EVENT__, __UVE_EVENTS__, __UVE_EVENT_ERROR_FALLBACK__ };
75
+ export { __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__, __DEFAULT_TINYMCE_CONFIG__, __TINYMCE_PATH_ON_DOTCMS__ };
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@dotcms/uve",
3
- "version": "0.0.1-beta.9",
3
+ "version": "1.0.0",
4
4
  "description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/dotCMS/core.git#main"
8
8
  },
9
+ "devDependencies": {
10
+ "@dotcms/types": "latest"
11
+ },
9
12
  "keywords": [
10
13
  "dotCMS",
11
14
  "CMS",
@@ -21,12 +24,6 @@
21
24
  "import": "./index.cjs.mjs",
22
25
  "default": "./index.cjs.js"
23
26
  },
24
- "./types": {
25
- "module": "./types.esm.js",
26
- "types": "./types.esm.d.ts",
27
- "import": "./types.cjs.mjs",
28
- "default": "./types.cjs.js"
29
- },
30
27
  "./internal": {
31
28
  "module": "./internal.esm.js",
32
29
  "types": "./internal.esm.d.ts",
@@ -39,9 +36,6 @@
39
36
  ".": [
40
37
  "./src/index.d.ts"
41
38
  ],
42
- "types": [
43
- "./src/types.d.ts"
44
- ],
45
39
  "internal": [
46
40
  "./src/internal.d.ts"
47
41
  ]