@tridion-docs/extensions 1.0.4 → 2.1.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/CHANGELOG.md CHANGED
@@ -1,13 +1,30 @@
1
1
  # @tridion-docs/extensions
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added possibility to specify long label for action buttons.
8
+ - Added support for Translation Jobs, now extensions can be added to that view as well.
9
+
10
+ ## 2.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - Added zIndex property to an useItemSelector hook
15
+ - Updated package dependencies
16
+ - Fixed export for ItemSelectorObjectType and PublicationObjectType
17
+ - Added support for Publication Hub
18
+ - Updated types to support Nswag
19
+
3
20
  ## 1.0.4
4
21
 
5
22
  ### Patch Changes
6
23
 
7
- - For useNotification hook optional property area for adding action button is added
24
+ - For useNotification hook optional property area for adding action button is added
8
25
 
9
26
  ## 1.0.3
10
27
 
11
28
  ### Major Changes
12
29
 
13
- - Tridion Docs extensions for Organize Space
30
+ - Tridion Docs extensions for Organize Space
package/LICENSE.md CHANGED
@@ -1,2 +1,2 @@
1
1
  License: https://www.rws.com/legal/terms-and-conditions/rws-technology/
2
- Copyright (c) 2014-2023. All Rights Reserved by RWS Group for and on behalf of its affiliates and subsidiaries.
2
+ Copyright © 2024 RWS Holdings plc including its subsidiaries and affiliated companies. All rights reserved.
package/README.md CHANGED
@@ -5,11 +5,31 @@ This project contains the helper function, components and hooks for working wit
5
5
  # License
6
6
  License: https://www.rws.com/legal/terms-and-conditions/rws-technology/
7
7
 
8
- Copyright (c) 2014-2023. All Rights Reserved by RWS Group for and on behalf of its affiliates and subsidiaries.
8
+ Copyright © 2024 RWS Holdings plc including its subsidiaries and affiliated companies. All rights reserved.
9
9
 
10
10
  # Compatibility
11
11
 
12
- This version of the package is compatible with Tridion Docs 15.0
12
+ This version of the package is compatible with Tridion Docs 15.2
13
+
14
+ # Upgrade instruction
15
+
16
+ ## Packages
17
+ To use latest version of extension and extension-cli you need to update versions of package.json in your extension application.
18
+
19
+ You need to update versions of these two packages `@tridion-docs/extensions` and `@tridion-docs/extensions-cli`. We also recommend you to keep all other dependencies up to date. You can find examples of packages and their versions in package.json of extension-example application available on CD.
20
+
21
+ ```
22
+ "dependencies": {
23
+ ...
24
+ "@tridion-docs/extensions": "2.1.0",
25
+ ...
26
+ },
27
+ "devDependencies": {
28
+ ...
29
+ "@tridion-docs/extensions-cli": "2.1.0",
30
+ ...
31
+ }
32
+ ```
13
33
 
14
34
  # Documentation
15
35
 
@@ -93,7 +113,7 @@ export const CustomPage = () => {
93
113
 
94
114
  The extension library provides hooks to assist with extension development.
95
115
 
96
- ## `useItemSelector`
116
+ ## `useItemSelector`
97
117
 
98
118
  The `useItemSelector` allows you to show dialog with a structured folder tree on the left side and the content of the folder on the right side. This dialog supposes to help you to select one of the multiple objects based on your configuration.
99
119
 
@@ -107,11 +127,11 @@ export const useCustomHook = () => {
107
127
 
108
128
  const itemSelectorProps = {
109
129
  objectTypesToSelect: [
110
- DocumentObjectType.ILLUSTRATION,
111
- DocumentObjectType.LIBRARY,
112
- DocumentObjectType.MAP,
113
- DocumentObjectType.OTHER,
114
- DocumentObjectType.TOPIC,
130
+ DocumentObjectType.Illustration,
131
+ DocumentObjectType.Library,
132
+ DocumentObjectType.Map,
133
+ DocumentObjectType.Other,
134
+ DocumentObjectType.Topic,
115
135
  ],
116
136
  isMultiSelect: false,
117
137
  onOk: async (values: Content[]) => {
@@ -138,6 +158,7 @@ export const useCustomHook = () => {
138
158
  `onOk` | `function` | Function that will be called when a user clicks the OK button
139
159
  `okLabel` | `string` | Label of the 'Ok' button
140
160
  `cancelLabel` | `string` | Label of the 'Cancel' button
161
+ `modalZindex` | `number` | Property to set z-index property on the item selector modal
141
162
 
142
163
 
143
164
  **Return**
@@ -460,7 +481,10 @@ builder.header.addMainNavigationLink(() => ({
460
481
  `component` | `ComponentType` | Component that will be rendered after mouse click
461
482
 
462
483
  ## Action
463
- Custom action button that might be used for executing custom logic for selected items.Registration of new navigation items is required to call the builder function `builder.header.builder.action.addExplorerAction`
484
+ Custom action button that might be used for executing custom logic for selected items. Registration of new navigation items is required to call the builder function `builder.header.builder.action.addExplorerAction`.
485
+
486
+ `addExplorerAction` supports generic type definition, so we specify expected selected object type [more about generics](#generic-types).
487
+
464
488
 
465
489
  ```typescript jsx
466
490
 
@@ -474,6 +498,19 @@ builder.action.addExplorerAction(() => ({
474
498
  icon: CustomIcon,
475
499
  hook: useCustomHook,
476
500
  }));
501
+
502
+ /* if we expect type other than `Content` we can define it here */
503
+ import { Project, ViewType } from '@tridion-docs/extensions';
504
+ builder.action.addExplorerAction<Project>(() => ({
505
+ id: 'id',
506
+ title: 'title',
507
+ tooltip: '',
508
+ isVisible: ({ activeView }) => {
509
+ return activeView === ViewType.project;
510
+ },
511
+ icon: CustomIcon,
512
+ hook: useCustomHook,
513
+ }));
477
514
  ```
478
515
 
479
516
  **Props**
@@ -490,6 +527,7 @@ builder.action.addExplorerAction(() => ({
490
527
  ## Object Insight
491
528
  The object right side panel is representing a custom data view for one or multiple selected items. Registration of new object insight is required to call the builder function `builder.objectInsight.addObjectInsightItem`
492
529
 
530
+ `addObjectInsightItem` supports generic type definition, so we specify expected selected object type [more about generics](#generic-types).
493
531
  ```typescript jsx
494
532
  builder.objectInsight.addObjectInsightItem(() => ({
495
533
  id: 'id',
@@ -501,6 +539,17 @@ builder.objectInsight.addObjectInsightItem(() => ({
501
539
  component: CustomComponent,
502
540
  }));
503
541
 
542
+ /* if we expect type other than `Content` we can define it here */
543
+ builder.objectInsight.addObjectInsightItem<Project>(() => ({
544
+ id: 'id',
545
+ tooltip: 'tooltip',
546
+ isVisible: (props) => {
547
+ return false;
548
+ },
549
+ icon: CustomIcon,
550
+ component: CustomComponent,
551
+ }));
552
+
504
553
  ```
505
554
 
506
555
 
@@ -530,6 +579,13 @@ builder.objectInsight.addObjectInsightItem(() => ({
530
579
  `item` | `string` | Id of the navigation item that will be used for positioning. Default navigation items ('content', 'events', 'settings'), also you can use a previously added custom navigation items id
531
580
  `PositioningType` | `PositioningType`| `string` | Indicate where should be located navigation item relative to previously selected item (`after` or `before`)
532
581
 
582
+ ### Generic types
583
+ As far as we're supporting extensions in different areas like Publication Hub and Content Explorer hooks or components will operate with different types of input parameters. It doesn't not affect the API of the function but it will affect the types of arguments. For example, if we define action in Project or Project assignees in "Publication hub" we will get a `Project` type object instead of `Content` type. To support this case we introduced a generic type for some of the functions like `addExplorerAction` where you may specify the expected type of the active objects.
584
+
585
+ The default type is `Content`. That means `addExplorerAction<Content>()` and `addExplorerAction()` are equal code blocks.
586
+
587
+ [More about typescript generics](https://www.typescriptlang.org/docs/handbook/2/generics.html)
588
+
533
589
 
534
590
  ## Translations
535
591
  Translation records can be registered per language by using the function `builder.translations.addTranslation`
@@ -546,6 +602,7 @@ Translation records can be registered per language by using the function `builde
546
602
  //....
547
603
  ```
548
604
 
605
+
549
606
  ### Usage
550
607
  Import ```t``` function returned by ```createExtensionGlobals``` and pass it the translation key.
551
608
 
@@ -560,6 +617,7 @@ Import ```t``` function returned by ```createExtensionGlobals``` and pass it the
560
617
  | Deutsch | `de` |
561
618
  | Spanish | `es` |
562
619
  | French | `fr` |
620
+ | French (Canada) | `fr-CA` |
563
621
  | Italian | `it` |
564
622
  | Japanese | `ja` |
565
623
  | Chinese (Simplified) | `zh` |
@@ -635,3 +693,137 @@ const getExtensionsBaseUrl = () => {
635
693
  const baseUrl = getExtensionsBaseUrl();
636
694
  const client = new Client(baseUrl);
637
695
  ```
696
+
697
+ # FAQ
698
+ **I want to use [useItemSelector](#useitemselector) inside [Antd Modal](https://ant.design/components/modal) component but I can't see popups and filters in item selector.**
699
+
700
+ This is a known issue caused by mixing two different UI frameworks. To resolve this issue, there are two approaches:
701
+
702
+ *Preferable way*
703
+
704
+ Reset the zIndex property for the Antd Modal and specify a custom container that positions it correctly relative to the ItemSelector.
705
+
706
+ ```js
707
+ const popupContainer = useMemo(() => {
708
+ const container = document.createElement('div');
709
+ document.body.append(container);
710
+ return container;
711
+ }, []);
712
+
713
+ <Modal
714
+ zIndex={0}
715
+ getContainer={popupContainer}
716
+ ```
717
+
718
+ *Complete page example*
719
+
720
+ ```js
721
+ import { Content, DocumentObjectType, useItemSelector } from '@tridion-docs/extensions';
722
+ import { useMemo, useState } from 'react';
723
+ import { Button, Modal } from 'antd';
724
+
725
+ export const CustomPage = () => {
726
+ const [isModalOpen, setIsModalOpen] = useState(false);
727
+
728
+ const showModal = () => setIsModalOpen(true);
729
+ const handleOk = () => setIsModalOpen(false);
730
+ const handleCancel = () => setIsModalOpen(false);
731
+
732
+ const itemSelectorProps = {
733
+ objectTypesToSelect: [DocumentObjectType.Library],
734
+ isMultiSelect: false,
735
+ onOk: (selectedItems: Content[]) => console.log(selectedItems),
736
+ okLabel: 'ok',
737
+ cancelLabel: 'cancel',
738
+ };
739
+
740
+ const { execute: showItemSelector } = useItemSelector(itemSelectorProps);
741
+
742
+ const popupContainer = useMemo(() => {
743
+ const container = document.createElement('div');
744
+ document.body.append(container);
745
+ return container;
746
+ }, []);
747
+
748
+ return (
749
+ <>
750
+ <Button type="primary" onClick={showModal}>Open Modal </Button>
751
+ <Modal
752
+ title="Basic Modal"
753
+ open={isModalOpen}
754
+ onOk={handleOk}
755
+ onCancel={handleCancel}
756
+ zIndex={0}
757
+ getContainer={popupContainer}
758
+ >
759
+ <Button onClick={showItemSelector}>show</Button>
760
+ </Modal>
761
+ </>
762
+ );
763
+ };
764
+ ```
765
+
766
+ *Alternative way*
767
+
768
+ If you prefer a simpler fix, you can use CSS to globally adjust the z-index for popups. However, this may cause issues with other components and is less reliable across different library versions.
769
+
770
+ ```js
771
+ import { Content, DocumentObjectType, useItemSelector } from '@tridion-docs/extensions';
772
+ import { useState } from 'react';
773
+
774
+ import { Button, Modal } from 'antd';
775
+
776
+ import './CustomPage.module.css';
777
+
778
+ export const CustomPage = () => {
779
+ const [isModalOpen, setIsModalOpen] = useState(false);
780
+
781
+ const showModal = () => setIsModalOpen(true);
782
+ const handleOk = () => setIsModalOpen(false);
783
+ const handleCancel = () => setIsModalOpen(false);
784
+
785
+ const itemSelectorProps = {
786
+ objectTypesToSelect: [DocumentObjectType.Library],
787
+ isMultiSelect: false,
788
+ onOk: (selectedItems: Content[]) => console.log(selectedItems),
789
+ okLabel: 'ok',
790
+ cancelLabel: 'cancel',
791
+ modalZindex: 1002
792
+ };
793
+
794
+ const { execute: showItemSelector } = useItemSelector(itemSelectorProps);
795
+
796
+ return (
797
+ <>
798
+ <Button type="primary" onClick={showModal}>Open Modal </Button>
799
+ <Modal
800
+ title="Basic Modal"
801
+ open={isModalOpen}
802
+ onOk={handleOk}
803
+ onCancel={handleCancel}
804
+ >
805
+ <Button onClick={showItemSelector}>show</Button>
806
+ </Modal>
807
+ </>
808
+ );
809
+ };
810
+
811
+ ```
812
+
813
+
814
+ ```css
815
+ /* CustomPage.module.css */
816
+
817
+ div[data-test~='popup'] {
818
+ z-index: 9999;
819
+ }
820
+
821
+ body > div > div[class*='ant-select-dropdown'] {
822
+ z-index: 10000;
823
+ }
824
+ ```
825
+
826
+
827
+
828
+ *Note:* This solution applies globally, affecting all popups on the page. It is not guaranteed to work consistently across future releases, as the CSS selector may change.
829
+
@@ -43,6 +43,13 @@ export interface ItemSelectorProps {
43
43
  * @memberof ItemSelectorProps
44
44
  */
45
45
  cancelLabel: string;
46
+ /**
47
+ * Property to set z-index property on the item selector modal.
48
+ *
49
+ * @type {number}
50
+ * @memberof ItemSelectorProps
51
+ */
52
+ modalZindex?: number;
46
53
  }
47
54
  export type ItemSelectorHook = (props: ItemSelectorProps) => ItemSelectorHookResult;
48
55
  /**
@@ -2,9 +2,9 @@
2
2
  * Enumeration holding all base folders.
3
3
  */
4
4
  export declare enum BaseFolder {
5
- NONE = "none",
6
- DATA = "data",
7
- SYSTEM = "system",
8
- FAVORITES = "favorites",
9
- EDITOR_TEMPLATE = "editorTemplate"
5
+ None = "none",
6
+ Data = "data",
7
+ System = "system",
8
+ Favorites = "favorites",
9
+ EditorTemplate = "editorTemplate"
10
10
  }
@@ -3,11 +3,11 @@
3
3
  */
4
4
  var BaseFolder;
5
5
  (function (BaseFolder) {
6
- BaseFolder["NONE"] = "none";
7
- BaseFolder["DATA"] = "data";
8
- BaseFolder["SYSTEM"] = "system";
9
- BaseFolder["FAVORITES"] = "favorites";
10
- BaseFolder["EDITOR_TEMPLATE"] = "editorTemplate";
6
+ BaseFolder["None"] = "none";
7
+ BaseFolder["Data"] = "data";
8
+ BaseFolder["System"] = "system";
9
+ BaseFolder["Favorites"] = "favorites";
10
+ BaseFolder["EditorTemplate"] = "editorTemplate";
11
11
  })(BaseFolder || (BaseFolder = {}));
12
12
 
13
13
  export { BaseFolder };
@@ -0,0 +1,18 @@
1
+ export interface BaseObject {
2
+ /**
3
+ * The identifier.
4
+ */
5
+ id?: string;
6
+ /**
7
+ * The title.
8
+ */
9
+ title?: string | null;
10
+ /**
11
+ * The description.
12
+ */
13
+ description?: string | null;
14
+ /**
15
+ * The type of the current object.
16
+ */
17
+ type: string;
18
+ }
@@ -1,22 +1,5 @@
1
1
  import { BaseFolder, DocumentObjectType, FolderType } from "..";
2
- interface BaseObject {
3
- /**
4
- * The identifier.
5
- */
6
- id?: string;
7
- /**
8
- * The title.
9
- */
10
- title?: string | null;
11
- /**
12
- * The description.
13
- */
14
- description?: string | null;
15
- /**
16
- * The type of the current object.
17
- */
18
- type: string;
19
- }
2
+ import { BaseObject } from './BaseObject';
20
3
  export interface DocumentObject extends BaseObject {
21
4
  /**
22
5
  * The document object type.
@@ -55,7 +38,7 @@ export interface Folder extends BaseObject {
55
38
  /**
56
39
  * The type of the base folder (e.g. Data, System, Favorites, EditorTemplate).
57
40
  */
58
- baseFolder?: BaseFolder | null;
41
+ baseFolder?: BaseFolder;
59
42
  }
60
43
  export interface Publication extends BaseObject {
61
44
  /**
@@ -84,4 +67,3 @@ export interface Publication extends BaseObject {
84
67
  languageCombinationIds?: Array<string> | null;
85
68
  }
86
69
  export type Content = DocumentObject | Folder | Publication;
87
- export {};
@@ -2,10 +2,10 @@
2
2
  * Enumeration holding the type of document.
3
3
  */
4
4
  export declare enum DocumentObjectType {
5
- UNDEFINED = "undefined",
6
- ILLUSTRATION = "illustration",
7
- LIBRARY = "library",
8
- MAP = "map",
9
- OTHER = "other",
10
- TOPIC = "topic"
5
+ Undefined = "undefined",
6
+ Illustration = "illustration",
7
+ Library = "library",
8
+ Map = "map",
9
+ Other = "other",
10
+ Topic = "topic"
11
11
  }
@@ -3,12 +3,12 @@
3
3
  */
4
4
  var DocumentObjectType;
5
5
  (function (DocumentObjectType) {
6
- DocumentObjectType["UNDEFINED"] = "undefined";
7
- DocumentObjectType["ILLUSTRATION"] = "illustration";
8
- DocumentObjectType["LIBRARY"] = "library";
9
- DocumentObjectType["MAP"] = "map";
10
- DocumentObjectType["OTHER"] = "other";
11
- DocumentObjectType["TOPIC"] = "topic";
6
+ DocumentObjectType["Undefined"] = "undefined";
7
+ DocumentObjectType["Illustration"] = "illustration";
8
+ DocumentObjectType["Library"] = "library";
9
+ DocumentObjectType["Map"] = "map";
10
+ DocumentObjectType["Other"] = "other";
11
+ DocumentObjectType["Topic"] = "topic";
12
12
  })(DocumentObjectType || (DocumentObjectType = {}));
13
13
 
14
14
  export { DocumentObjectType };
@@ -2,12 +2,12 @@
2
2
  * Enumeration holding the type of a folder.
3
3
  */
4
4
  export declare enum FolderType {
5
- FOLDER = "folder",
6
- ILLUSTRATION_FOLDER = "illustrationFolder",
7
- LIBRARY_FOLDER = "libraryFolder",
8
- MAP_FOLDER = "mapFolder",
9
- OTHER_FOLDER = "otherFolder",
10
- PUBLICATION_FOLDER = "publicationFolder",
11
- REFERENCE_FOLDER = "referenceFolder",
12
- TOPIC_FOLDER = "topicFolder"
5
+ Folder = "folder",
6
+ IllustrationFolder = "illustrationFolder",
7
+ LibraryFolder = "libraryFolder",
8
+ MapFolder = "mapFolder",
9
+ OtherFolder = "otherFolder",
10
+ PublicationFolder = "publicationFolder",
11
+ ReferenceFolder = "referenceFolder",
12
+ TopicFolder = "topicFolder"
13
13
  }
@@ -3,14 +3,14 @@
3
3
  */
4
4
  var FolderType;
5
5
  (function (FolderType) {
6
- FolderType["FOLDER"] = "folder";
7
- FolderType["ILLUSTRATION_FOLDER"] = "illustrationFolder";
8
- FolderType["LIBRARY_FOLDER"] = "libraryFolder";
9
- FolderType["MAP_FOLDER"] = "mapFolder";
10
- FolderType["OTHER_FOLDER"] = "otherFolder";
11
- FolderType["PUBLICATION_FOLDER"] = "publicationFolder";
12
- FolderType["REFERENCE_FOLDER"] = "referenceFolder";
13
- FolderType["TOPIC_FOLDER"] = "topicFolder";
6
+ FolderType["Folder"] = "folder";
7
+ FolderType["IllustrationFolder"] = "illustrationFolder";
8
+ FolderType["LibraryFolder"] = "libraryFolder";
9
+ FolderType["MapFolder"] = "mapFolder";
10
+ FolderType["OtherFolder"] = "otherFolder";
11
+ FolderType["PublicationFolder"] = "publicationFolder";
12
+ FolderType["ReferenceFolder"] = "referenceFolder";
13
+ FolderType["TopicFolder"] = "topicFolder";
14
14
  })(FolderType || (FolderType = {}));
15
15
 
16
16
  export { FolderType };
@@ -0,0 +1,11 @@
1
+ import { BaseObject } from './BaseObject';
2
+ export interface Project extends BaseObject {
3
+ /** The element name of the project. */
4
+ projectId?: string;
5
+ /** The CardId of the Assignee (if available). */
6
+ assigneeCardId?: number | null;
7
+ /** The title of the publication. */
8
+ publicationTitle?: string | null;
9
+ /** The version number of the publication version. */
10
+ publicationVersion?: string | null;
11
+ }
@@ -2,5 +2,5 @@
2
2
  * Enumeration holding the type of publication.
3
3
  */
4
4
  export declare enum PublicationObjectType {
5
- PUBLICATION = "publication"
5
+ Publication = "publication"
6
6
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Enumeration holding the type of publication.
3
+ */
4
+ var PublicationObjectType;
5
+ (function (PublicationObjectType) {
6
+ PublicationObjectType["Publication"] = "publication";
7
+ })(PublicationObjectType || (PublicationObjectType = {}));
8
+
9
+ export { PublicationObjectType };
@@ -0,0 +1,3 @@
1
+ import { BaseObject } from './BaseObject';
2
+ export interface TranslationJob extends BaseObject {
3
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Indicates in which part of the UI object insight panel is visible
2
+ * Indicates in which part of the UI object insight panel or action button is visible
3
3
  *
4
4
  * @export
5
5
  * @enum {number}
@@ -8,5 +8,8 @@ export declare enum ViewType {
8
8
  explore = "Explore",
9
9
  details = "Details",
10
10
  search = "Search",
11
- inbox = "Inbox"
11
+ inbox = "Inbox",
12
+ project = "Project",
13
+ projectAssignee = "ProjectAssignee",
14
+ translationJobs = "TranslationJobs"
12
15
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Indicates in which part of the UI object insight panel is visible
2
+ * Indicates in which part of the UI object insight panel or action button is visible
3
3
  *
4
4
  * @export
5
5
  * @enum {number}
@@ -10,6 +10,9 @@ var ViewType;
10
10
  ViewType["details"] = "Details";
11
11
  ViewType["search"] = "Search";
12
12
  ViewType["inbox"] = "Inbox";
13
+ ViewType["project"] = "Project";
14
+ ViewType["projectAssignee"] = "ProjectAssignee";
15
+ ViewType["translationJobs"] = "TranslationJobs";
13
16
  })(ViewType || (ViewType = {}));
14
17
 
15
18
  export { ViewType };
@@ -1,4 +1,5 @@
1
1
  export * from './Content';
2
+ export * from './Project';
2
3
  export * from './BaseFolder';
3
4
  export * from './DocumentObjectType';
4
5
  export * from './FolderType';
@@ -11,3 +12,6 @@ export * from './FrontendAddon';
11
12
  export * from './FrontendAddons';
12
13
  export * from './Hierarchy';
13
14
  export * from './UserInfo';
15
+ export * from './ItemSelectorObjectType';
16
+ export * from './PublicationObjectType';
17
+ export * from './TranslationJob';
@@ -1,4 +1,4 @@
1
1
  import { ExplorerActionExtension } from './explorerAction';
2
2
  export interface ActionExtensions {
3
- explorerActions: ReadonlyArray<ExplorerActionExtension>;
3
+ explorerActions: ReadonlyArray<ExplorerActionExtension<any>>;
4
4
  }
@@ -2,6 +2,6 @@ import { ActionExtensions } from './actionExtensions';
2
2
  import { ExplorerActionExtension } from './explorerAction';
3
3
  export declare class ActionExtensionsBuilder {
4
4
  private _explorerActionExtensions;
5
- addExplorerAction: (item: ExplorerActionExtension) => this;
5
+ addExplorerAction: <T>(item: ExplorerActionExtension<T>) => this;
6
6
  build: () => ActionExtensions;
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { Content, Folder, ViewType, UserInfo } from "../../api";
2
- export type ExplorerActionExtension = () => ExplorerActionExtensionConfiguration;
3
- export interface ExplorerActionExtensionConfiguration {
2
+ export type ExplorerActionExtension<T> = () => ExplorerActionExtensionConfiguration<T>;
3
+ export interface ExplorerActionExtensionConfiguration<T = Content> {
4
4
  /**
5
5
  * Action id (should be unique)
6
6
  *
@@ -15,10 +15,20 @@ export interface ExplorerActionExtensionConfiguration {
15
15
  readonly tooltip: string;
16
16
  /**
17
17
  * Action button label
18
+ * used to show the label when the button is under a group button
19
+ * and in other places if a long label is not set
18
20
  *
19
21
  * @type {string}
20
22
  */
21
23
  readonly label: string;
24
+ /**
25
+ * Action button long label,
26
+ * used to show the label when the button is outside of a group
27
+ * or under a more button
28
+ *
29
+ * @type {string}
30
+ */
31
+ readonly longLabel?: string;
22
32
  /**
23
33
  * Action button icon (SVG)
24
34
  *
@@ -31,15 +41,15 @@ export interface ExplorerActionExtensionConfiguration {
31
41
  *
32
42
  * @type {(props: ExplorerActionExtensionVisibilityConfiguration) => boolean}
33
43
  */
34
- readonly isVisible?: (props: ExplorerActionExtensionVisibilityConfiguration) => boolean;
44
+ readonly isVisible?: (props: ExplorerActionExtensionVisibilityConfiguration<T>) => boolean;
35
45
  /**
36
46
  * Hook to place on action button
37
47
  *
38
48
  * @memberof ExplorerActionExtensionConfiguration
39
49
  */
40
- readonly hook: (props: ExplorerActionExtensionHookConfiguration) => ExplorerActionExtensionHookResults;
50
+ readonly hook: (props: ExplorerActionExtensionHookConfiguration<T>) => ExplorerActionExtensionHookResults;
41
51
  }
42
- export interface ExplorerActionExtensionVisibilityConfiguration extends ExplorerActionExtensionBaseConfiguration {
52
+ export interface ExplorerActionExtensionVisibilityConfiguration<T = Content> extends ExplorerActionExtensionBaseConfiguration<T> {
43
53
  /**
44
54
  * Indicates in which part of the UI explorer action is visible
45
55
  *
@@ -63,6 +73,13 @@ export type ExplorerActionExtensionHookResults = {
63
73
  * @memberof ExplorerActionExtensionHookResults
64
74
  */
65
75
  readonly isAvailable: boolean;
76
+ /**
77
+ * Return true if you want to switch the button to the loading state. Loading state changing icon to the spinner and disables the button
78
+ *
79
+ * @type {boolean}
80
+ * @memberof ExplorerActionExtensionHookResults
81
+ */
82
+ readonly isLoading?: boolean;
66
83
  /**
67
84
  * Method that is called when the action is clicked
68
85
  *
@@ -71,21 +88,22 @@ export type ExplorerActionExtensionHookResults = {
71
88
  */
72
89
  readonly execute: () => void | Promise<void>;
73
90
  };
74
- export interface ExplorerActionExtensionHookConfiguration extends ExplorerActionExtensionBaseConfiguration {
91
+ export interface ExplorerActionExtensionHookConfiguration<T = Content> extends ExplorerActionExtensionBaseConfiguration<T> {
75
92
  }
76
93
  /**
77
94
  * Base properties for visibility and hook
78
95
  *
79
96
  * @interface ExplorerActionExtensionBaseConfiguration
97
+ * @typeParam T - type of active item, `Content` is default type
80
98
  */
81
- interface ExplorerActionExtensionBaseConfiguration {
99
+ interface ExplorerActionExtensionBaseConfiguration<T = Content> {
82
100
  /**
83
101
  * The currently selected items inside the Explorer
84
102
  *
85
- * @type {Content[]}
103
+ * @type {T[]}
86
104
  * @memberof ExplorerActionExtensionBaseConfiguration
87
105
  */
88
- readonly selectedItems: Content[];
106
+ readonly selectedItems: T[];
89
107
  /**
90
108
  * Folder we are currently in
91
109
  *
@@ -1,4 +1,4 @@
1
1
  import { ObjectInsightItemExtension } from './objectInsightItem';
2
2
  export interface ObjectInsightExtensions {
3
- objectInsightItems: ReadonlyArray<ObjectInsightItemExtension>;
3
+ objectInsightItems: ReadonlyArray<ObjectInsightItemExtension<any>>;
4
4
  }
@@ -2,6 +2,6 @@ import { ObjectInsightExtensions } from './objectInsightExtensions';
2
2
  import { ObjectInsightItemExtension } from './objectInsightItem';
3
3
  export declare class ObjectInsightExtensionsBuilder {
4
4
  private _objectInsightItemExtensions;
5
- addObjectInsightItem: (item: ObjectInsightItemExtension) => this;
5
+ addObjectInsightItem: <T>(item: ObjectInsightItemExtension<T>) => this;
6
6
  build: () => ObjectInsightExtensions;
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import { Content, Folder, UserInfo, ViewType } from "../../api";
2
2
  import type { ComponentType } from 'react';
3
- export type ObjectInsightItemExtension = () => ObjectInsightItemExtensionConfiguration;
4
- export interface ObjectInsightItemExtensionConfiguration {
3
+ export type ObjectInsightItemExtension<T> = () => ObjectInsightItemExtensionConfiguration<T>;
4
+ export interface ObjectInsightItemExtensionConfiguration<T = Content> {
5
5
  /**
6
6
  * Object Insight item id (should be unique)
7
7
  *
@@ -26,22 +26,23 @@ export interface ObjectInsightItemExtensionConfiguration {
26
26
  *
27
27
  * @type {(props: ObjectInsightItemExtensionsVisibilityConfiguration) => boolean}
28
28
  */
29
- readonly isVisible?: (props: ObjectInsightItemExtensionsVisibilityConfiguration) => boolean;
29
+ readonly isVisible?: (props: ObjectInsightItemExtensionsVisibilityConfiguration<T>) => boolean;
30
30
  /**
31
31
  * Menu item component to render on this path
32
32
  *
33
33
  * @type {ComponentType}
34
34
  * @memberof ObjectInsightItemExtensionConfiguration
35
35
  */
36
- readonly component: ComponentType<ObjectInsightItemExtensionComponentConfiguration>;
36
+ readonly component: ComponentType<ObjectInsightItemExtensionComponentConfiguration<T>>;
37
37
  }
38
38
  /**
39
39
  * Component properties in object insight panel
40
40
  *
41
41
  * @export
42
42
  * @interface ObjectInsightItemExtensionComponentConfiguration
43
+ * @typeParam T - type of active item, default value is Content
43
44
  */
44
- export interface ObjectInsightItemExtensionComponentConfiguration extends ObjectInsightItemExtensionBaseConfiguration {
45
+ export interface ObjectInsightItemExtensionComponentConfiguration<T = Content> extends ObjectInsightItemExtensionBaseConfiguration<T> {
45
46
  /**
46
47
  * Indicates when item is in loading state or part of the UI is refreshing,
47
48
  * so item can get new information after
@@ -56,8 +57,10 @@ export interface ObjectInsightItemExtensionComponentConfiguration extends Object
56
57
  *
57
58
  * @export
58
59
  * @interface ObjectInsightItemExtensionsVisibilityConfiguration
60
+ * @typeParam T - type of active item, `Content` is default type
61
+ *
59
62
  */
60
- export interface ObjectInsightItemExtensionsVisibilityConfiguration extends ObjectInsightItemExtensionBaseConfiguration {
63
+ export interface ObjectInsightItemExtensionsVisibilityConfiguration<T = Content> extends ObjectInsightItemExtensionBaseConfiguration<T> {
61
64
  /**
62
65
  * Indicates in which part of the UI object insight panel is visible
63
66
  *
@@ -77,15 +80,16 @@ export interface ObjectInsightItemExtensionsVisibilityConfiguration extends Obje
77
80
  * Base properties for component and visibility
78
81
  *
79
82
  * @interface ObjectInsightItemExtensionBaseConfiguration
83
+ * @typeParam T - type of active item, `Content` is default type
80
84
  */
81
- interface ObjectInsightItemExtensionBaseConfiguration {
85
+ interface ObjectInsightItemExtensionBaseConfiguration<T = Content> {
82
86
  /**
83
87
  * Active item in the view, can be document object, folder or publication
84
88
  *
85
- * @type {Content}
89
+ * @type {T}
86
90
  * @memberof ObjectInsightItemExtensionBaseConfiguration
87
91
  */
88
- activeItem: Content;
92
+ activeItem: T;
89
93
  /**
90
94
  * Folder in which active items is in UI. Usually the same as parent folder,
91
95
  * exception is when item is visible in reference folder and in search results
@@ -1,4 +1,4 @@
1
- import { version, peerDependencies } from './package.json.js';
1
+ import { peerDependencies, version } from './package.json.js';
2
2
 
3
3
  const frameworkInfo = {
4
4
  version,
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ export { FolderType } from './api/typings/FolderType.js';
14
14
  export { MessageSeverity } from './api/typings/Notification.js';
15
15
  export { NavigationItemIdType, PositioningType } from './api/typings/Position.js';
16
16
  export { ViewType } from './api/typings/ViewType.js';
17
+ export { PublicationObjectType } from './api/typings/PublicationObjectType.js';
17
18
  export { initializeExtensionApiStorage } from './apiStorage/apiStorage.js';
18
19
  import 'react';
19
20
  export { ActionExtensionsBuilder } from './extensionPoints/action/actionExtensionsBuilder.js';
@@ -1,9 +1,9 @@
1
- const version = "1.0.4";
1
+ const version = "2.1.0";
2
2
  const peerDependencies = {
3
- react: "18.2.0",
4
- "react-dom": "18.2.0",
5
- "react-is": "18.2.0",
6
- "styled-components": "5.3.6"
3
+ react: "18.3.1",
4
+ "react-dom": "18.3.1",
5
+ "react-is": "18.3.1",
6
+ "styled-components": "6.1.15"
7
7
  };
8
8
 
9
9
  export { peerDependencies, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tridion-docs/extensions",
3
- "version": "1.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "Tridion Docs Extensions API",
5
5
  "author": "RWS Group for and on behalf of its affiliates and subsidiaries",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -21,34 +21,34 @@
21
21
  "build": "rollup -c",
22
22
  "release": "rollup -c",
23
23
  "start": "rollup -c -w",
24
- "lint": "eslint . --fix && prettier --write \"src/**/*\"",
24
+ "start:remote": "yarn run start",
25
+ "lint": "eslint .",
26
+ "lint:fix": "eslint . --fix && prettier --write \"src/**/*\"",
25
27
  "prepublish": "yarn build"
26
28
  },
27
29
  "peerDependencies": {
28
- "react": "18.2.0",
29
- "react-dom": "18.2.0",
30
- "react-is": "18.2.0",
31
- "styled-components": "5.3.6"
30
+ "react": "18.3.1",
31
+ "react-dom": "18.3.1",
32
+ "react-is": "18.3.1",
33
+ "styled-components": "6.1.15"
32
34
  },
33
35
  "devDependencies": {
34
- "@rollup/plugin-commonjs": "24.0.1",
35
- "@rollup/plugin-json": "6.0.0",
36
- "@rollup/plugin-node-resolve": "15.0.1",
37
- "@rollup/plugin-typescript": "11.0.0",
38
- "@tridion/graphene": "1.31.0",
39
- "@types/react": "18.0.31",
40
- "@types/react-dom": "18.0.11",
41
- "@types/react-is": "17.0.3",
42
- "@types/styled-components": "5.1.26",
43
- "react": "18.2.0",
44
- "react-dom": "18.2.0",
45
- "react-is": "18.2.0",
46
- "rimraf": "3.0.2",
47
- "rollup": "3.20.2",
48
- "rollup-plugin-delete": "2.0.0",
49
- "rollup-plugin-node-externals": "5.1.2",
50
- "styled-components": "5.3.9",
51
- "typescript": "5.0.2",
52
- "typescript-transform-paths": "3.4.6"
36
+ "@rollup/plugin-commonjs": "28.0.2",
37
+ "@rollup/plugin-json": "6.1.0",
38
+ "@rollup/plugin-node-resolve": "16.0.0",
39
+ "@rollup/plugin-typescript": "12.1.2",
40
+ "@types/react": "18.3.18",
41
+ "@types/react-dom": "18.3.5",
42
+ "@types/react-is": "18.3.1",
43
+ "react": "18.3.1",
44
+ "react-dom": "18.3.1",
45
+ "react-is": "18.3.1",
46
+ "rimraf": "6.0.1",
47
+ "rollup": "4.34.8",
48
+ "rollup-plugin-delete": "2.1.0",
49
+ "rollup-plugin-node-externals": "8.0.0",
50
+ "styled-components": "6.1.15",
51
+ "typescript": "5.7.3",
52
+ "typescript-transform-paths": "3.5.3"
53
53
  }
54
54
  }