@storyblok/svelte 2.4.8 → 2.4.10
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/README.md +261 -12
- package/{StoryblokComponent.svelte → dist/StoryblokComponent.svelte} +3 -2
- package/dist/StoryblokComponent.svelte.d.ts +18 -0
- package/dist/index.js +53 -0
- package/dist/types.js +1 -0
- package/package.json +17 -17
- package/dist/main.d.ts +0 -11
- package/dist/storyblok-svelte.js +0 -10
- package/dist/storyblok-svelte.mjs +0 -996
- package/dist/vite.config.d.ts +0 -2
- package/index.ts +0 -81
- package/types.ts +0 -35
package/dist/vite.config.d.ts
DELETED
package/index.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
storyblokEditable as sbEdit,
|
|
3
|
-
storyblokInit as sbInit,
|
|
4
|
-
} from "@storyblok/js";
|
|
5
|
-
export {
|
|
6
|
-
useStoryblokBridge,
|
|
7
|
-
apiPlugin,
|
|
8
|
-
renderRichText,
|
|
9
|
-
RichTextSchema,
|
|
10
|
-
} from "@storyblok/js";
|
|
11
|
-
|
|
12
|
-
import type {
|
|
13
|
-
SbSvelteSDKOptions,
|
|
14
|
-
SbSvelteComponentsMap,
|
|
15
|
-
StoryblokClient,
|
|
16
|
-
SbBlokData,
|
|
17
|
-
} from "./types";
|
|
18
|
-
|
|
19
|
-
export const storyblokEditable = (node: HTMLElement, value: SbBlokData) => {
|
|
20
|
-
const updateDom = (value: SbBlokData) => {
|
|
21
|
-
const options = sbEdit(value);
|
|
22
|
-
if (options["data-blok-c"]) {
|
|
23
|
-
node.setAttribute("data-blok-c", options["data-blok-c"]);
|
|
24
|
-
node.setAttribute("data-blok-uid", options["data-blok-uid"]);
|
|
25
|
-
node.classList.add("storyblok__outline");
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
updateDom(value); // when is mounted
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
update(newValue: SbBlokData) {
|
|
33
|
-
// when value changes
|
|
34
|
-
updateDom(newValue);
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
let storyblokApiInstance: StoryblokClient = null;
|
|
40
|
-
export const useStoryblokApi = (): StoryblokClient => {
|
|
41
|
-
if (!storyblokApiInstance) {
|
|
42
|
-
console.log(
|
|
43
|
-
`You can't use getStoryblokApi if you're not loading apiPlugin.`
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
return storyblokApiInstance;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export { useStoryblokApi as getStoryblokApi };
|
|
50
|
-
|
|
51
|
-
let componentsMap: SbSvelteComponentsMap | CallableFunction = null;
|
|
52
|
-
|
|
53
|
-
export const storyblokInit = (options: SbSvelteSDKOptions) => {
|
|
54
|
-
const { storyblokApi } = sbInit(options);
|
|
55
|
-
storyblokApiInstance = storyblokApi;
|
|
56
|
-
componentsMap = options.components || {};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const getComponent = (componentName: string) => {
|
|
60
|
-
let component = null;
|
|
61
|
-
component =
|
|
62
|
-
typeof componentsMap === "function"
|
|
63
|
-
? componentsMap()[componentName]
|
|
64
|
-
: componentsMap[componentName];
|
|
65
|
-
|
|
66
|
-
if (!component) {
|
|
67
|
-
console.error(`You didn't load the ${componentName} component. Please load it in storyblokInit. For example:
|
|
68
|
-
storyblokInit({
|
|
69
|
-
accessToken: "<your-token>",
|
|
70
|
-
components: {
|
|
71
|
-
"teaser": Teaser
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return component;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export * from "./types";
|
|
81
|
-
export { default as StoryblokComponent } from "./StoryblokComponent.svelte";
|
package/types.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { SbSDKOptions } from "@storyblok/js";
|
|
2
|
-
import type { SvelteComponent } from "svelte";
|
|
3
|
-
|
|
4
|
-
export interface SbSvelteComponentsMap {
|
|
5
|
-
[name: string]: typeof SvelteComponent;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface SbSvelteSDKOptions extends SbSDKOptions {
|
|
9
|
-
components?: SbSvelteComponentsMap | CallableFunction;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { apiPlugin } from "@storyblok/js";
|
|
13
|
-
|
|
14
|
-
export type {
|
|
15
|
-
ISbAlternateObject,
|
|
16
|
-
ISbRichtext,
|
|
17
|
-
RichTextResolver,
|
|
18
|
-
SbBlokData,
|
|
19
|
-
SbBlokKeyDataTypes,
|
|
20
|
-
SbSDKOptions,
|
|
21
|
-
ISbStories,
|
|
22
|
-
ISbStoriesParams,
|
|
23
|
-
ISbStory,
|
|
24
|
-
ISbStoryData,
|
|
25
|
-
ISbStoryParams,
|
|
26
|
-
StoryblokBridgeConfigV2,
|
|
27
|
-
StoryblokBridgeV2,
|
|
28
|
-
ISbCache,
|
|
29
|
-
StoryblokClient,
|
|
30
|
-
StoryblokComponentType,
|
|
31
|
-
ISbConfig,
|
|
32
|
-
ISbManagmentApiResult,
|
|
33
|
-
ISbResult,
|
|
34
|
-
useStoryblokBridge,
|
|
35
|
-
} from "@storyblok/js";
|