@storyblok/vue 2.0.0 → 3.0.1

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 CHANGED
@@ -30,7 +30,7 @@
30
30
  </a>
31
31
  </p>
32
32
 
33
- **Note**: This plugin is for Vue 2. [Check out the @next version for Vue 3](https://github.com/storyblok/storyblok-vue/tree/next)
33
+ **Note**: This plugin is for Vue 3. [Check out the docs for Vue 2 version](https://github.com/storyblok/storyblok-vue/tree/master).
34
34
 
35
35
  ## 🚀 Usage
36
36
 
@@ -38,20 +38,22 @@
38
38
 
39
39
  ### Installation
40
40
 
41
- Install `@storyblok/vue`:
41
+ Install `@storyblok/vue@next`:
42
42
 
43
43
  ```bash
44
- npm install --save-dev @storyblok/vue
45
- // yarn add -D @storyblok/vue
44
+ npm install --save-dev @storyblok/vue@next
45
+ # yarn add -D @storyblok/vue@next
46
46
  ```
47
47
 
48
48
  Register it globally on your application (usually in `main.js`):
49
49
 
50
50
  ```js
51
- import Vue from "vue";
51
+ import { createApp } from "vue";
52
52
  import StoryblokVue from "@storyblok/vue";
53
+ import App from "./App.vue";
53
54
 
54
- Vue.use(StoryblokVue);
55
+ const app = createApp(App);
56
+ app.use(StoryblokVue);
55
57
  ```
56
58
 
57
59
  #### From a CDN
@@ -59,12 +61,10 @@ Vue.use(StoryblokVue);
59
61
  Install the file from the CDN:
60
62
 
61
63
  ```html
62
- <script src="https://unpkg.com/@storyblok/vue"></script>
64
+ <script src="https://unpkg.com/@storyblok/vue@next"></script>
63
65
  ```
64
66
 
65
- That's it, the plugin is auto-registered for you 😉.
66
-
67
- ### Getting Started
67
+ ### Getting started
68
68
 
69
69
  For every component you've defined in your Storyblok space, add the `v-editable` directive with the blok content:
70
70
 
@@ -76,11 +76,11 @@ For every component you've defined in your Storyblok space, add the `v-editable`
76
76
 
77
77
  Where `blok` is the actual blok data coming from [Storblok's Content Delivery API](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue).
78
78
 
79
- Check out the [playground](/../../tree/master/playground) for a full example.
79
+ Check out the [playground](/../../tree/next/playground) for a full example.
80
80
 
81
81
  ### Compatibility
82
82
 
83
- This plugin is for Vue 2. Thus, it supports the [same browsers as Vue 2](https://vuejs.org/v2/guide/installation.html#Compatibility-Note).
83
+ This plugin is for Vue 3. Thus, it supports the [same browsers as Vue 3](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0038-vue3-ie11-support.md). In short: all modern browsers, dropping IE support.
84
84
 
85
85
  ## 🔗 Related Links
86
86
 
@@ -5,23 +5,22 @@ const addClass = (el, className) => {
5
5
  el.className += " " + className;
6
6
  }
7
7
  };
8
- function install(Vue) {
9
- Vue.directive("editable", {
10
- bind: function(el, binding) {
11
- if (typeof binding.value._editable === "undefined" || binding.value._editable === null) {
12
- return;
8
+ var index = {
9
+ install: (app) => {
10
+ app.directive("editable", {
11
+ beforeMount(el, binding) {
12
+ if (binding.value) {
13
+ const node = binding.value._editable;
14
+ if (typeof node === "undefined" || node === null)
15
+ return;
16
+ const cleared = node.replace("<!--#storyblok#", "").replace("-->", "");
17
+ const options = JSON.parse(cleared);
18
+ el.setAttribute("data-blok-c", JSON.stringify(options));
19
+ el.setAttribute("data-blok-uid", options.id + "-" + options.uid);
20
+ addClass(el, "storyblok__outline");
21
+ }
13
22
  }
14
- var options = JSON.parse(binding.value._editable.replace("<!--#storyblok#", "").replace("-->", ""));
15
- el.setAttribute("data-blok-c", JSON.stringify(options));
16
- el.setAttribute("data-blok-uid", options.id + "-" + options.uid);
17
- addClass(el, "storyblok__outline");
18
- }
19
- });
20
- if (typeof window !== "undefined" && typeof window.storyblok !== "undefined") {
21
- Vue.prototype.$storyblok = window.storyblok;
23
+ });
22
24
  }
23
- }
24
- if (typeof window !== "undefined" && window.Vue) {
25
- window.Vue.use(install);
26
- }
27
- export { install as default };
25
+ };
26
+ export { index as default };
@@ -1 +1 @@
1
- (function(o,i){typeof exports=="object"&&typeof module!="undefined"?module.exports=i():typeof define=="function"&&define.amd?define(i):(o=typeof globalThis!="undefined"?globalThis:o||self,o.storyblok=i())})(this,function(){"use strict";const o=(e,t)=>{e.classList?e.classList.add(t):new RegExp("\\b"+t+"\\b").test(e.className)||(e.className+=" "+t)};function i(e){e.directive("editable",{bind:function(t,d){if(!(typeof d.value._editable=="undefined"||d.value._editable===null)){var n=JSON.parse(d.value._editable.replace("<!--#storyblok#","").replace("-->",""));t.setAttribute("data-blok-c",JSON.stringify(n)),t.setAttribute("data-blok-uid",n.id+"-"+n.uid),o(t,"storyblok__outline")}}}),typeof window!="undefined"&&typeof window.storyblok!="undefined"&&(e.prototype.$storyblok=window.storyblok)}return typeof window!="undefined"&&window.Vue&&window.Vue.use(i),i});
1
+ (function(i,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(i=typeof globalThis!="undefined"?globalThis:i||self,i.storyblok=s())})(this,function(){"use strict";const i=(t,e)=>{t.classList?t.classList.add(e):new RegExp("\\b"+e+"\\b").test(t.className)||(t.className+=" "+e)};var s={install:t=>{t.directive("editable",{beforeMount(e,d){if(d.value){const o=d.value._editable;if(typeof o=="undefined"||o===null)return;const u=o.replace("<!--#storyblok#","").replace("-->",""),n=JSON.parse(u);e.setAttribute("data-blok-c",JSON.stringify(n)),e.setAttribute("data-blok-uid",n.id+"-"+n.uid),i(e,"storyblok__outline")}}})}};return s});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyblok/vue",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Storyblok directive for get editable elements.",
5
5
  "main": "./dist/storyblok-vue.umd.js",
6
6
  "module": "./dist/storyblok-vue.es.js",
@@ -25,30 +25,30 @@
25
25
  "devDependencies": {
26
26
  "@babel/core": "^7.15.0",
27
27
  "@cypress/vite-dev-server": "^2.0.7",
28
- "@cypress/vue": "^2.2.3",
28
+ "@cypress/vue": "^3.0.3",
29
29
  "@vitejs/plugin-vue": "^1.3.0",
30
30
  "@vue/babel-preset-app": "^4.5.13",
31
- "@vue/test-utils": "^1.2.2",
31
+ "@vue/compiler-sfc": "^3.2.1",
32
+ "@vue/test-utils": "next",
32
33
  "babel-jest": "^26.6.3",
33
34
  "cypress": "^8.3.0",
34
35
  "eslint-plugin-cypress": "^2.12.1",
35
36
  "eslint-plugin-jest": "^25.2.4",
36
37
  "jest": "^26.6.3",
37
38
  "vite": "^2.4.4",
38
- "vue": "^2.6.14",
39
- "vue-jest": "^4.0.1",
40
- "vue-template-compiler": "^2.6.14"
41
- },
42
- "babel": {
43
- "presets": [
44
- "@vue/babel-preset-app"
45
- ]
39
+ "vue": "^3.0.0",
40
+ "vue-jest": "next"
46
41
  },
47
42
  "eslintConfig": {
48
43
  "env": {
49
44
  "node": true
50
45
  }
51
46
  },
47
+ "babel": {
48
+ "presets": [
49
+ "@vue/babel-preset-app"
50
+ ]
51
+ },
52
52
  "jest": {
53
53
  "moduleFileExtensions": [
54
54
  "js",
@@ -73,5 +73,11 @@
73
73
  "bugs": {
74
74
  "url": "https://github.com/storyblok/storyblok-vue/issues"
75
75
  },
76
- "homepage": "https://github.com/storyblok/storyblok-vue"
76
+ "homepage": "https://github.com/storyblok/storyblok-vue",
77
+ "release": {
78
+ "branches": [
79
+ "master",
80
+ "next"
81
+ ]
82
+ }
77
83
  }