Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Layer List Plugin #11

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
491d2af
WIP
mirko314 Feb 23, 2024
73a9357
Initial commit with inline tailwindcss
mirko314 Mar 22, 2024
3f41648
Enable layer list app in web example, add translations
mirko314 Mar 22, 2024
e927cf7
Improve Semantic, Make layer component fully clickable
mirko314 Mar 22, 2024
7701fde
Remove unused packages
mirko314 Mar 25, 2024
bd34623
ENABLE_VISIBILITY_TOGGLE=false
mirko314 Mar 25, 2024
d36a8b4
Remove esbuild tailwind
mirko314 Mar 25, 2024
ddb054a
Add package.json
mirko314 Mar 25, 2024
eded87f
npx tailwind
mirko314 Mar 25, 2024
c10adac
yarn
mirko314 Mar 25, 2024
c647057
Move folder
mirko314 Mar 25, 2024
94a336a
Rename Plugin
mirko314 Mar 25, 2024
38dc873
Add license
mirko314 Mar 25, 2024
28c1cb7
Remove unused tailwindconfig duplicate
mirko314 Mar 25, 2024
86703e8
Add Barebones Readme
mirko314 Mar 25, 2024
3520e60
Rename QRCodePanel
mirko314 Mar 25, 2024
06cbdf7
Fix package.json
mirko314 Apr 2, 2024
7190dbc
tailwind compile
mirko314 Apr 2, 2024
6325371
Cleanup
mirko314 Apr 2, 2024
46c176b
Update only when history is updated
mirko314 Apr 2, 2024
ba7586d
fix typing
mirko314 Apr 2, 2024
ffff0d6
Add information on css style issue
mirko314 Apr 2, 2024
7be893d
Bump version
mirko314 Apr 2, 2024
2ca8c06
Add undo step after dnd
mirko314 Apr 2, 2024
aa0c076
version bump
mirko314 Apr 3, 2024
d777212
Add cutout icon
mirko314 Apr 3, 2024
8a0f67b
Add cutout type
mirko314 Apr 3, 2024
12ce662
Bump version
mirko314 Apr 3, 2024
8470bcc
Add vector path to layer list asset for theming
mirko314 Apr 9, 2024
98a91ad
Move layerlist into `plugin-layer-list-web` folder
mirko314 Apr 9, 2024
36743d9
Add fallback icon for graphics without kind
mirko314 Apr 9, 2024
fa7a68e
Add scene upload to example app
mirko314 Apr 9, 2024
ff2b142
Version bump
mirko314 Apr 9, 2024
85999af
Cleanup Readme
mirko314 Apr 11, 2024
56bc86c
Cleanup
mirko314 Apr 11, 2024
ed3f487
Add dblclick to edit functionality
mirko314 Apr 22, 2024
999b9b8
Update examples/web/src/addPlugins.ts
mirko314 May 17, 2024
dd6c1cc
Update packages/plugin-layer-list-web/README.md
mirko314 May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
packages/*/dist
examples/*/dist
examples/*/public/assets
.env.local
.nvmrc

Expand Down
4 changes: 2 additions & 2 deletions examples/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"build": "tsc && vite build --force",
"build": "tsc && vite build ",
"clean": "npx rimraf dist",
"dev": "vite --clearScreen=false --force"
},
"dependencies": {
"@imgly/plugin-background-removal-web": "*",
"@imgly/plugin-remote-asset-source-web": "*",
"@cesdk/cesdk-js": "^1.21.0",
"@cesdk/cesdk-js": "^1.22.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
75 changes: 68 additions & 7 deletions examples/web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CreativeEditorSDK from '@cesdk/cesdk-js';
import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';
import { useRef } from 'react';

import addPlugins, { prepareAssetEntries } from './addPlugins';
import addPlugins, { Apps, prepareAssetEntries } from './addPlugins';

function App() {
const cesdk = useRef<CreativeEditorSDK>();
Expand All @@ -12,24 +12,67 @@ function App() {
if (domElement != null) {
CreativeEditorSDK.create(domElement, {
license: import.meta.env.VITE_CESDK_LICENSE_KEY,
callbacks: { onUpload: 'local' },
callbacks: { onUpload: 'local', onLoad: 'upload' },
// We need to load assets from the same domain to enable custom dom panels (like e.g created in the layer list panel).
// Otherwise, the panel only shows an error message.
baseURL: '/assets',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have to copy asset from the CE.SDK with this changes? At least I cannot start the app without WASM errors.

ui: {
elements: {
navigation: {
action: {
load: true
}
},
libraries: {
insert: {
entries: (d) => {
if (!cesdk.current) return;
return prepareAssetEntries(d, cesdk.current!.engine);
if (!cesdk.current) return [];

return [
...prepareAssetEntries(d, cesdk.current!.engine),
{
id: 'ly.img.apps',
sourceIds: ['ly.img.apps'],
cardLabel: (assetResult: AssetResult) =>
assetResult.label,
cardLabelPosition: () => 'bottom',
gridItemHeight: 'square',
icon: ({ theme }: { theme: 'light' | 'dark' }) =>
`https://staticimgly.com/imgly/cesdk-icons/0.0.1/output/apps-${theme}.svg`
}
];
}
},
replace: {
entries: (d) => {
if (!cesdk.current) return;
if (!cesdk.current) return [];

return prepareAssetEntries(d, cesdk.current!.engine);
}
}
},
panels: { settings: true }
panels: { settings: true },
dock: {
groups: [
{
id: 'ly.img.apps',
entryIds: ['ly.img.apps']
},
{
id: 'ly.img.template',
entryIds: ['ly.img.template']
},
{
id: 'ly.img.defaultGroup',
showOverview: true
}
]
}
}
},
i18n: {
en: {
'libraries.ly.img.apps.label': 'Apps'
}
}
}).then(async (instance) => {
Expand All @@ -43,7 +86,25 @@ function App() {
instance.addDefaultAssetSources(),
instance.addDemoAssetSources({ sceneMode: 'Design' })
]);
const engine = instance.engine;
engine.asset.addLocalSource(
'ly.img.apps',
undefined,
async (asset: AssetResult) => {
const appHandler = Apps.find(
(app) => app.asset.id === asset.id
);
if (!appHandler) {
console.error('No app handler found for asset:', asset.id);
return;
}
appHandler.handler(instance as any);
return undefined;
}
);

await addPlugins(instance);

await instance.createDesignScene();
});
} else if (cesdk.current != null) {
Expand Down
25 changes: 22 additions & 3 deletions examples/web/src/addPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
import type CreativeEditorSDK from '@cesdk/cesdk-js';
import CreativeEditorSDK from '@cesdk/cesdk-js';

import BackgroundRemovalPlugin from '@imgly/plugin-background-removal-web';
import LayerListPlugin, {
Apps as LayerListApps
} from '@imgly/plugin-layer-list-web';
import RemoteAssetSourcePlugin from '@imgly/plugin-remote-asset-source-web';

// Add more apps when available
export const Apps = LayerListApps;

const ENABLE_DEMO_ASSET_SOURCES = false;

async function addPlugins(cesdk: CreativeEditorSDK): Promise<void> {
console.log('Adding plugins', RemoteAssetSourcePlugin);
console.log('Adding plugins');
try {
await Promise.all([
cesdk.unstable_addPlugin(
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this is needed?

BackgroundRemovalPlugin({ ui: { locations: 'canvasMenu' } })
),
...addDemoRemoteAssetSourcesPlugins(cesdk)
...addDemoRemoteAssetSourcesPlugins(cesdk),
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here...

cesdk.unstable_addPlugin(LayerListPlugin())
]);
// Add all exported apps to the 'ly.img.apps' asset source
const engine = cesdk.engine;
if (
engine.asset.findAllSources().includes('ly.img.apps')
) {
const appAssets = Apps.map((a) => a.asset);
appAssets.forEach((appAsset) => {
engine.asset.addAssetToSource('ly.img.apps', appAsset);
});
}
} catch (error) {
console.error('Could not add all plugins: ', error);
}
Expand Down
Loading