Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 18 additions & 18 deletions docs/dev/web/embed-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,30 @@ To maintain uniformity and ease of handling, each event encapsulates the same st
<script>
function selectEventHandler(event) {
if (event.data?.name !== 'opencloud-embed:select') {
return;
return
}

const resources = event.data.data;
const resources = event.data.data

doSomethingWithSelectedResources(resources);
doSomethingWithSelectedResources(resources)
}

function shareLinksEventHandler(event) {
if (event.data?.name !== 'opencloud-embed:share-links') {
return;
return
}

const links = event.data.data; // Array<{ url: string, password?: string }>
const links = event.data.data // Array<{ url: string, password?: string }>

links.forEach((link) => {
console.log('Shared link:', link.url, link.password);
});
console.log('Shared link:', link.url, link.password)
})

doSomethingWithSharedLinks(links);
doSomethingWithSharedLinks(links)
}

window.addEventListener('message', selectEventHandler);
window.addEventListener('message', shareLinksEventHandler);
window.addEventListener('message', selectEventHandler)
window.addEventListener('message', shareLinksEventHandler)
</script>
```

Expand All @@ -80,15 +80,15 @@ In special scenarios you also want the user to set a file name, this can be achi
<script>
function selectEventHandler(event) {
if (event.data?.name !== 'opencloud-embed:select') {
return;
return
}

const resources = event.data.data[0];
const resources = event.data.data[0]

doSomethingWithSelectedResources(resources);
doSomethingWithSelectedResources(resources)
}

window.addEventListener('message', selectEventHandler);
window.addEventListener('message', selectEventHandler)
</script>
```

Expand All @@ -110,15 +110,15 @@ combination of both. If the embed-file-types parameter is not provided, all file
<script>
function selectEventHandler(event) {
if (event.data?.name !== 'opencloud-embed:file-pick') {
return;
return
}

const file = event.data.data;
const file = event.data.data

doSomethingWithPickedFile(file);
doSomethingWithPickedFile(file)
}

window.addEventListener('message', selectEventHandler);
window.addEventListener('message', selectEventHandler)
</script>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ There are two ways to override the defaults:
The merged config is passed to the `setup` function of your app definition as `applicationConfig`:

```typescript title="src/index.ts"
import { defineWebApplication } from '@opencloud-eu/web-pkg';
import { defineWebApplication } from '@opencloud-eu/web-pkg'

export default defineWebApplication({
setup({ applicationConfig }) {
const showPreview = applicationConfig?.showPreview ?? true;
const showPreview = applicationConfig?.showPreview ?? true

// ...
}
});
})
```

Always provide a fallback value. The config can be empty, and an administrator can set any value.
2 changes: 1 addition & 1 deletion docs/dev/web/extension-system/advanced-topics/styling.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The `@opencloud-eu/extension-sdk` package ships a preconfigured [Tailwind CSS](h
its stylesheet in your entrypoint (typically `src/index.ts`) to use it:

```typescript title="src/index.ts"
import '@opencloud-eu/extension-sdk/tailwind.css';
import '@opencloud-eu/extension-sdk/tailwind.css'
```

Tailwind classes need the `ext:` prefix in apps. The prefix avoids style conflicts with the OpenCloud Web runtime.
Expand Down
12 changes: 6 additions & 6 deletions docs/dev/web/extension-system/advanced-topics/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ The `@opencloud-eu/web-test-helpers` package provides utilities for mounting com
context. Without them, every component that uses a composable of `web-pkg` fails to mount.

```typescript title="tests/unit/App.spec.ts"
import { defaultPlugins, mount } from '@opencloud-eu/web-test-helpers';
import App from '../../src/App.vue';
import { defaultPlugins, mount } from '@opencloud-eu/web-test-helpers'
import App from '../../src/App.vue'

describe('App', () => {
it('renders the title', () => {
const wrapper = mount(App, { global: { plugins: [...defaultPlugins()] } });
expect(wrapper.text()).toContain('My app');
});
});
const wrapper = mount(App, { global: { plugins: [...defaultPlugins()] } })
expect(wrapper.text()).toContain('My app')
})
})
```

For details, please refer to the package's
Expand Down
26 changes: 13 additions & 13 deletions docs/dev/web/extension-system/advanced-topics/translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Translations are optional. An app without them simply shows its original strings
In a script or a composable, get `$gettext` from `useGettext`:

```typescript
import { useGettext } from 'vue3-gettext';
import { useGettext } from 'vue3-gettext'

const { $gettext } = useGettext();
const { $gettext } = useGettext()

const title = $gettext('Your application name');
const title = $gettext('Your application name')
```

In a template, `$gettext` is globally available:
Expand All @@ -33,20 +33,20 @@ Pass variables as an object. Use the `%{name}` syntax in the string, never strin
changes between languages:

```typescript
$gettext('Open «%{resource}»', { resource: resource.name });
$gettext('Open «%{resource}»', { resource: resource.name })
```

For plurals, use `$ngettext` with the singular form, the plural form, the count, and the variables:

```typescript
const { $ngettext } = useGettext();
const { $ngettext } = useGettext()

$ngettext(
'Delete the selected resource?',
'Delete %{amount} selected resources?',
resources.length,
{ amount: resources.length.toString() }
);
)
```

:::warning
Expand Down Expand Up @@ -76,7 +76,7 @@ module.exports = {
flat: false,
linguas: false
}
};
}
```

Add two scripts to your `package.json`:
Expand Down Expand Up @@ -105,23 +105,23 @@ Import `translations.json` and return it from your app definition. The Web runti
translations when your app is loaded.

```typescript title="src/index.ts"
import { defineWebApplication } from '@opencloud-eu/web-pkg';
import { useGettext } from 'vue3-gettext';
import translations from '../l10n/translations.json';
import { defineWebApplication } from '@opencloud-eu/web-pkg'
import { useGettext } from 'vue3-gettext'
import translations from '../l10n/translations.json'

export default defineWebApplication({
setup() {
const { $gettext } = useGettext();
const { $gettext } = useGettext()

return {
appInfo: {
name: $gettext('Your application name'),
id: 'your-app'
},
translations
};
}
}
});
})
```

The file is a map of language key to message map:
Expand Down
36 changes: 18 additions & 18 deletions docs/dev/web/extension-system/extensions/extension-points.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ An extension point is a plain object of the `ExtensionPoint` type. Keep it in it
`src/extensionPoints.ts`, so that you can use it in several places:

```typescript title="src/extensionPoints.ts"
import { ActionExtension, ExtensionPoint } from '@opencloud-eu/web-pkg';
import { ActionExtension, ExtensionPoint } from '@opencloud-eu/web-pkg'

export const toolbarExtensionPoint: ExtensionPoint<ActionExtension> = {
id: 'app.my-app.toolbar',
extensionType: 'action',
multiple: true
};
}
```

`ExtensionPoint` accepts the following keys:
Expand All @@ -126,9 +126,9 @@ export const toolbarExtensionPoint: ExtensionPoint<ActionExtension> = {
Return your extension points from the app definition. The key takes a `Ref<ExtensionPoint[]>`, so use a `computed`:

```typescript title="src/index.ts"
import { defineWebApplication } from '@opencloud-eu/web-pkg';
import { computed } from 'vue';
import { toolbarExtensionPoint } from './extensionPoints';
import { defineWebApplication } from '@opencloud-eu/web-pkg'
import { computed } from 'vue'
import { toolbarExtensionPoint } from './extensionPoints'

export default defineWebApplication({
setup() {
Expand All @@ -138,9 +138,9 @@ export default defineWebApplication({
id: 'my-app'
},
extensionPoints: computed(() => [toolbarExtensionPoint])
};
}
}
});
})
```

Registration is not needed to query extensions. It makes your extension point known to the runtime, which is required
Expand All @@ -157,25 +157,25 @@ the registry and respects the user preference:
</template>

<script setup lang="ts">
import { CustomComponentTarget } from '@opencloud-eu/web-pkg';
import { componentExtensionPoint } from './extensionPoints';
import { CustomComponentTarget } from '@opencloud-eu/web-pkg'
import { componentExtensionPoint } from './extensionPoints'
</script>
```

For all other types, query the registry yourself and render the result the way your extension point needs it:

```typescript
import { ActionExtension, useExtensionRegistry } from '@opencloud-eu/web-pkg';
import { computed } from 'vue';
import { toolbarExtensionPoint } from './extensionPoints';
import { ActionExtension, useExtensionRegistry } from '@opencloud-eu/web-pkg'
import { computed } from 'vue'
import { toolbarExtensionPoint } from './extensionPoints'

const extensionRegistry = useExtensionRegistry();
const extensionRegistry = useExtensionRegistry()

const actions = computed(() =>
extensionRegistry
.requestExtensions<ActionExtension>(toolbarExtensionPoint)
.map(({ action }) => action)
);
)
```

### Letting users choose
Expand All @@ -184,10 +184,10 @@ Add a `userPreference` to your extension point to let users pick one of the regi
sense when `multiple` is `false`:

```typescript title="src/extensionPoints.ts"
import { ExtensionPoint, CustomComponentExtension } from '@opencloud-eu/web-pkg';
import { useGettext } from 'vue3-gettext';
import { ExtensionPoint, CustomComponentExtension } from '@opencloud-eu/web-pkg'
import { useGettext } from 'vue3-gettext'

const { $gettext } = useGettext();
const { $gettext } = useGettext()

export const progressBarExtensionPoint: ExtensionPoint<CustomComponentExtension> = {
id: 'app.my-app.progress-bar',
Expand All @@ -196,7 +196,7 @@ export const progressBarExtensionPoint: ExtensionPoint<CustomComponentExtension>
label: $gettext('Progress bar'),
description: $gettext('Choose how the loading state is shown.')
}
};
}
```

The extension point then gets a dropdown on the preferences page, reachable via the top right user menu. The dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ To define an account extension, you implement the `AccountExtension` interface.

```typescript
interface AccountExtension {
id: string;
type: 'accountExtension';
extensionPointIds?: string[];
content: Slot | Component;
label: () => string;
icon: string;
id: string
type: 'accountExtension'
extensionPointIds?: string[]
content: Slot | Component
label: () => string
icon: string
}
```

Expand All @@ -42,5 +42,5 @@ const extension: AccountExtension = {
label: () => $gettext('App Tokens'),
icon: 'key-2',
content: AppTokens
};
}
```
Loading
Loading