Skip to content

Commit 0c09db5

Browse files
feat: Asset extension(#14)
2 parents 731323a + bc7884f commit 0c09db5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+19194
-6902
lines changed

.DS_Store

6 KB
Binary file not shown.

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
__test__

.eslintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint"],
5+
"extends": [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/eslint-recommended",
8+
"plugin:@typescript-eslint/recommended"
9+
],
10+
"rules": {
11+
"@typescript-eslint/no-explicit-any": 0,
12+
"@typescript-eslint/prefer-const": 0,
13+
"@typescript-eslint/no-this-alias": 0,
14+
"@typescript-eslint/ban-ts-comment": 0,
15+
"prefer-rest-params": 0,
16+
"@typescript-eslint/no-unused-vars": 0,
17+
"@typescript-eslint/no-empty-function": 0
18+
}
19+
}

.github/workflows/npm-publish.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: 16
18+
- run: npm ci
19+
- run: npm test
20+
21+
publish-npm:
22+
needs: build
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: actions/setup-node@v2
27+
with:
28+
node-version: 16
29+
registry-url: https://registry.npmjs.org/
30+
- run: npm ci
31+
- run: npm publish
32+
env:
33+
NODE_AUTH_TOKEN: ${{secrets.APP_SDK_AUTOMATION}}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ storybook-static
128128
tmp/
129129
temp/
130130

131+
# dist/
132+
131133
### vscode ###
132134
.vscode/*
133135
!.vscode/settings.json

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Contentstack
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,92 @@
11
# App Framework SDK
22

3+
## JSON Rich text editor plugin
34

4-
For more information on styling your extension, refer to our [style guide](https://www.contentstack.com/docs/extensions/style-guide/).
5+
The **JSON Rich Text Editor Plugins** lets you add/create custom plugins to extend the functionality of your [JSON Rich Text Editor](https://www.contentstack.com/docs/developers/json-rich-text-editor/about-json-rich-text-editor/) as per your needs. You can use the prebuilt JSON RTE plugins by modifying the code to suit your requirement.
56

6-
## More information
7-
- [SDK API reference](./docs/api.md)
7+
Some of the examples of the prebuilt JSON Rich Text Editor plugins are:
8+
9+
- Highlight: Allows you to highlight certain parts of your content, such as a whole line of text or a paragraph.
10+
11+
- Info Panel: Allows you to place important content inside a colored panel to make it stand out.
12+
13+
- Word Count: Allows you to track the word count for your JSON Rich Text Editor content.
14+
15+
You can create JSON Rich Text Editor Plugins using the Contentstack App SDK. For more information, read our [documentation](https://www.contentstack.com/docs/developers/json-rich-text-editor-plugins/about-json-rte-plugins/).
16+
17+
## Asset Sidebar Extension
18+
19+
**Asset Sidebar Extensions** enable you to customize and enhance your **asset editing experience**. Using customized extensions, you can tailor your images on Contentstack according to your branding requirements..
20+
21+
You can create Asset Sidebar Extensions using the Contentstack App SDK. For more information, read our documentation.
22+
23+
### AssetSidebarWidget Reference
24+
25+
It is an object representing the current Asset Sidebar Widget reference in the Contentstack UI.
26+
27+
**getData()**
28+
29+
This method returns the object representing the current asset.
30+
31+
**setData(asset: Partial<AssetData>)**
32+
33+
This method modifies the properties of the current asset.
34+
35+
**syncAsset()**
36+
37+
If your asset has been modified externally, you can use this method to load the new asset and sync its settings with the current asset.
38+
39+
**updateWidth(width: number)**
40+
41+
This method is used to modify the width of the asset sidebar panel. Using this method, you can resize the panel depending on the resolution of your content.
42+
43+
**replaceAsset(file: File)**
44+
45+
This method is used to replace the current asset with a new file. Unlike setData(), where you can only modify the properties, you can use this method to replace the actual file.
46+
47+
**onSave(callback: anyFunction)**
48+
49+
This is a callback function that runs after you save the asset settings.
50+
51+
**onChange(callback: anyFunction)**
52+
53+
This is a callback function that runs every time the user modifies the asset data.
54+
55+
**onPublish(callback: anyFunction)**
56+
57+
This is a callback function that is executed after a user publishes an asset.
58+
59+
**onUnPublish(callback: anyFunction)**
60+
61+
This is a callback function that is executed after you unpublish an asset.
62+
63+
**AssetData**
64+
65+
It is the property that you can modify using the setData() method.
66+
67+
## Metadata SDK Reference
68+
69+
**IMetadata**
70+
This object represents the structure of the metadata.
71+
72+
```ts
73+
{
74+
uid: string;
75+
type: "asset" | "entry";
76+
_content_type_uid?: string;
77+
locale?: string;
78+
[key: string]: any;
79+
}
80+
```
81+
82+
**createMetaData(metadataConfig: IMetadata)**
83+
This method adds new metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the `metadata` object and other data you need for your app.
84+
85+
**retrieveMetaData(metadataConfig: IMetadata)**
86+
This method retrieves metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the `metadata` object you want to retrieve.
87+
88+
**updateMetaData(metadataConfig: IMetadata)**
89+
This method updates existing metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the `metadata` object and other data you want to update.
90+
91+
**deleteMetaData(metadataConfig: IMetadata)**
92+
This method deletes existing metadata for an asset or entry. It accepts metadata configuration as required arguments. This config contains basic details that you need to identify the `metadata` object you want to delete.

0 commit comments

Comments
 (0)