@dotcms/client 0.0.1-alpha.50 → 0.0.1-alpha.52

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.cjs.js CHANGED
@@ -1100,6 +1100,7 @@ exports.NOTIFY_CLIENT = void 0;
1100
1100
 
1101
1101
  const INITIAL_DOT_UVE = {
1102
1102
  editContentlet,
1103
+ initInlineEditing,
1103
1104
  reorderMenu,
1104
1105
  lastScrollYPosition: 0
1105
1106
  };
@@ -1164,10 +1165,6 @@ exports.CLIENT_ACTIONS = void 0;
1164
1165
  * Tell the editor to edit a contentlet
1165
1166
  */
1166
1167
  CLIENT_ACTIONS["EDIT_CONTENTLET"] = "edit-contentlet";
1167
- /**
1168
- * Tell the editor to open the block editor sidebar
1169
- */
1170
- CLIENT_ACTIONS["INIT_BLOCK_EDITOR_INLINE_EDITING"] = "init-editor-inline-editing";
1171
1168
  /**
1172
1169
  * Tell the editor to do nothing
1173
1170
  */
@@ -1560,6 +1557,30 @@ function editContentlet(contentlet) {
1560
1557
  });
1561
1558
  }
1562
1559
  /**
1560
+ * Initializes the inline editing in the editor.
1561
+ *
1562
+ * @export
1563
+ * @param {INLINE_EDITING_EVENT_KEY} type
1564
+ * @param {InlineEditEventData} eventData
1565
+ * @return {*}
1566
+ *
1567
+ * * @example
1568
+ * ```html
1569
+ * <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })">
1570
+ * ${My Content}
1571
+ * </div>
1572
+ * ```
1573
+ */
1574
+ function initInlineEditing(type, data) {
1575
+ postMessageToEditor({
1576
+ action: exports.CLIENT_ACTIONS.INIT_INLINE_EDITING,
1577
+ payload: {
1578
+ type,
1579
+ data
1580
+ }
1581
+ });
1582
+ }
1583
+ /*
1563
1584
  * Reorders the menu based on the provided configuration.
1564
1585
  *
1565
1586
  * @param {ReorderMenuConfig} [config] - Optional configuration for reordering the menu.
@@ -2013,6 +2034,7 @@ exports.editContentlet = editContentlet;
2013
2034
  exports.getPageRequestParams = getPageRequestParams;
2014
2035
  exports.graphqlToPageEntity = graphqlToPageEntity;
2015
2036
  exports.initEditor = initEditor;
2037
+ exports.initInlineEditing = initInlineEditing;
2016
2038
  exports.isInsideEditor = isInsideEditor;
2017
2039
  exports.postMessageToEditor = postMessageToEditor;
2018
2040
  exports.reorderMenu = reorderMenu;
package/index.esm.js CHANGED
@@ -1098,6 +1098,7 @@ var NOTIFY_CLIENT;
1098
1098
 
1099
1099
  const INITIAL_DOT_UVE = {
1100
1100
  editContentlet,
1101
+ initInlineEditing,
1101
1102
  reorderMenu,
1102
1103
  lastScrollYPosition: 0
1103
1104
  };
@@ -1162,10 +1163,6 @@ var CLIENT_ACTIONS;
1162
1163
  * Tell the editor to edit a contentlet
1163
1164
  */
1164
1165
  CLIENT_ACTIONS["EDIT_CONTENTLET"] = "edit-contentlet";
1165
- /**
1166
- * Tell the editor to open the block editor sidebar
1167
- */
1168
- CLIENT_ACTIONS["INIT_BLOCK_EDITOR_INLINE_EDITING"] = "init-editor-inline-editing";
1169
1166
  /**
1170
1167
  * Tell the editor to do nothing
1171
1168
  */
@@ -1558,6 +1555,30 @@ function editContentlet(contentlet) {
1558
1555
  });
1559
1556
  }
1560
1557
  /**
1558
+ * Initializes the inline editing in the editor.
1559
+ *
1560
+ * @export
1561
+ * @param {INLINE_EDITING_EVENT_KEY} type
1562
+ * @param {InlineEditEventData} eventData
1563
+ * @return {*}
1564
+ *
1565
+ * * @example
1566
+ * ```html
1567
+ * <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })">
1568
+ * ${My Content}
1569
+ * </div>
1570
+ * ```
1571
+ */
1572
+ function initInlineEditing(type, data) {
1573
+ postMessageToEditor({
1574
+ action: CLIENT_ACTIONS.INIT_INLINE_EDITING,
1575
+ payload: {
1576
+ type,
1577
+ data
1578
+ }
1579
+ });
1580
+ }
1581
+ /*
1561
1582
  * Reorders the menu based on the provided configuration.
1562
1583
  *
1563
1584
  * @param {ReorderMenuConfig} [config] - Optional configuration for reordering the menu.
@@ -2005,4 +2026,4 @@ const getPageRequestParams = ({ path = '', params = {} }) => {
2005
2026
  };
2006
2027
  };
2007
2028
 
2008
- export { CLIENT_ACTIONS, DotCmsClient, NOTIFY_CLIENT, destroyEditor, editContentlet, getPageRequestParams, graphqlToPageEntity, initEditor, isInsideEditor, postMessageToEditor, reorderMenu, updateNavigation };
2029
+ export { CLIENT_ACTIONS, DotCmsClient, NOTIFY_CLIENT, destroyEditor, editContentlet, getPageRequestParams, graphqlToPageEntity, initEditor, initInlineEditing, isInsideEditor, postMessageToEditor, reorderMenu, updateNavigation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/client",
3
- "version": "0.0.1-alpha.50",
3
+ "version": "0.0.1-alpha.52",
4
4
  "description": "Official JavaScript library for interacting with DotCMS REST APIs.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { ClientConfig, DotCmsClient } from './lib/client/sdk-js-client';
2
2
  import { CLIENT_ACTIONS, postMessageToEditor } from './lib/editor/models/client.model';
3
3
  import { CustomClientParams, DotCMSPageEditorConfig, EditorConfig } from './lib/editor/models/editor.model';
4
+ import { InlineEditorData, INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './lib/editor/models/inline-event.model';
4
5
  import { NOTIFY_CLIENT } from './lib/editor/models/listeners.model';
5
- import { destroyEditor, editContentlet, reorderMenu, initEditor, isInsideEditor, updateNavigation } from './lib/editor/sdk-editor';
6
+ import { destroyEditor, editContentlet, reorderMenu, initEditor, isInsideEditor, updateNavigation, initInlineEditing } from './lib/editor/sdk-editor';
6
7
  import { getPageRequestParams, graphqlToPageEntity } from './lib/utils';
7
- export { graphqlToPageEntity, getPageRequestParams, isInsideEditor, editContentlet, reorderMenu, DotCmsClient, DotCMSPageEditorConfig, CLIENT_ACTIONS, NOTIFY_CLIENT, CustomClientParams, postMessageToEditor, EditorConfig, initEditor, updateNavigation, destroyEditor, ClientConfig };
8
+ export { graphqlToPageEntity, getPageRequestParams, isInsideEditor, editContentlet, reorderMenu, DotCmsClient, DotCMSPageEditorConfig, CLIENT_ACTIONS, NOTIFY_CLIENT, CustomClientParams, postMessageToEditor, EditorConfig, initEditor, updateNavigation, destroyEditor, ClientConfig, initInlineEditing, InlineEditEventData, InlineEditorData, INLINE_EDITING_EVENT_KEY };
@@ -1,4 +1,4 @@
1
- import { editContentlet, reorderMenu } from '../sdk-editor';
1
+ import { editContentlet, initInlineEditing, reorderMenu } from '../sdk-editor';
2
2
  declare global {
3
3
  interface Window {
4
4
  dotUVE: DotUVE;
@@ -65,10 +65,6 @@ export declare enum CLIENT_ACTIONS {
65
65
  * Tell the editor to edit a contentlet
66
66
  */
67
67
  EDIT_CONTENTLET = "edit-contentlet",
68
- /**
69
- * Tell the editor to open the block editor sidebar
70
- */
71
- INIT_BLOCK_EDITOR_INLINE_EDITING = "init-editor-inline-editing",
72
68
  /**
73
69
  * Tell the editor to do nothing
74
70
  */
@@ -95,6 +91,7 @@ type PostMessageProps<T> = {
95
91
  export declare function postMessageToEditor<T = unknown>(message: PostMessageProps<T>): void;
96
92
  export interface DotUVE {
97
93
  editContentlet: typeof editContentlet;
94
+ initInlineEditing: typeof initInlineEditing;
98
95
  reorderMenu: typeof reorderMenu;
99
96
  lastScrollYPosition: number;
100
97
  }
@@ -0,0 +1,9 @@
1
+ export type INLINE_EDITING_EVENT_KEY = 'BLOCK_EDITOR' | 'WYSIWYG';
2
+ export interface InlineEditorData {
3
+ inode: string;
4
+ language: number;
5
+ contentType: string;
6
+ fieldName: string;
7
+ content: Record<string, unknown>;
8
+ }
9
+ export type InlineEditEventData = InlineEditorData;
@@ -1,4 +1,5 @@
1
1
  import { DotCMSPageEditorConfig, ReorderMenuConfig } from './models/editor.model';
2
+ import { INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './models/inline-event.model';
2
3
  import { Contentlet } from '../client/content/shared/types';
3
4
  /**
4
5
  * Updates the navigation in the editor.
@@ -20,15 +21,21 @@ export declare function updateNavigation(pathname: string): void;
20
21
  */
21
22
  export declare function editContentlet<T>(contentlet: Contentlet<T>): void;
22
23
  /**
23
- * Reorders the menu based on the provided configuration.
24
+ * Initializes the inline editing in the editor.
24
25
  *
25
- * @param {ReorderMenuConfig} [config] - Optional configuration for reordering the menu.
26
- * @param {number} [config.startLevel=1] - The starting level of the menu to reorder.
27
- * @param {number} [config.depth=2] - The depth of the menu to reorder.
26
+ * @export
27
+ * @param {INLINE_EDITING_EVENT_KEY} type
28
+ * @param {InlineEditEventData} eventData
29
+ * @return {*}
28
30
  *
29
- * This function constructs a URL for the reorder menu page with the specified
30
- * start level and depth, and sends a message to the editor to perform the reorder action.
31
+ * * @example
32
+ * ```html
33
+ * <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })">
34
+ * ${My Content}
35
+ * </div>
36
+ * ```
31
37
  */
38
+ export declare function initInlineEditing(type: INLINE_EDITING_EVENT_KEY, data?: InlineEditEventData): void;
32
39
  export declare function reorderMenu(config?: ReorderMenuConfig): void;
33
40
  /**
34
41
  * Checks if the code is running inside an editor.
@@ -1,5 +1,4 @@
1
1
  /**
2
2
  * Listen for block editor inline event.
3
- *
4
3
  */
5
4
  export declare const listenBlockEditorInlineEvent: () => void;