diff --git a/webapp/components/Editor/nodes/Embed.js b/webapp/components/Editor/nodes/Embed.js
index 0a12e06ef..60f5eab76 100644
--- a/webapp/components/Editor/nodes/Embed.js
+++ b/webapp/components/Editor/nodes/Embed.js
@@ -1,6 +1,8 @@
import { Node } from 'tiptap'
import pasteRule from '../commands/pasteRule'
import { compileToFunctions } from 'vue-template-compiler'
+import { mapGetters, mapMutations } from 'vuex'
+import { allowEmbedIframesMutation } from '~/graphql/User.js'
const template = `
@@ -8,7 +10,58 @@ const template = `
{{ dataEmbedUrl }}
`
+
+const templateVideoPreview = `
+
+
+
+
+ {{embedPublisher}} - @{{ embedAuthor }}
+
+
+
+
+ Deine Daten sind noch nicht weitergegeben. Wenn Du die das jetzt ansiehst dann werden auch Daten mit dem Anbieter ausgetauscht!
+ dauerhaft speichern
+ jetzt ansehen
+
+
+
+
+ Deine Daten sind noch nicht weitergegeben. Wenn Du die das jetzt ansiehst dann werden auch Daten mit dem Anbieter ausgetauscht!
+ dauerhaft speichern
+ abstellen
+
+
+
![]()
+
+
+ {{ embedTitle }}
+ {{ embedDescription }}
+
+
+ automatisches Einbinden abgestellt | ändern
+
+ automatisches Einbinden zugelassen | ändern
+
+
+
+`
+
const compiledTemplate = compileToFunctions(template)
+const compiledTemplateVideoPreview = compileToFunctions(templateVideoPreview)
export default class Embed extends Node {
get name() {
@@ -65,12 +118,22 @@ export default class Embed extends Node {
props: ['node', 'updateAttrs', 'options'],
data: () => ({
embedData: {},
+ showEmbed: true,
+ showOverlay: false,
+ embedcode: null,
+ isOpen: false,
+ showchangeEmbedStatus: false,
+ // allowEmbedIframes: this.currentUser.allowEmbedIframes
}),
async created() {
if (!this.options) return {}
this.embedData = await this.options.onEmbed({ url: this.dataEmbedUrl })
+ this.showEmbed = this.currentUser.allowEmbedIframes
},
computed: {
+ ...mapGetters({
+ currentUser: 'auth/user',
+ }),
embedClass() {
return this.embedHtml ? 'embed' : ''
},
@@ -78,6 +141,26 @@ export default class Embed extends Node {
const { html = '' } = this.embedData
return html
},
+ embedImage() {
+ const { image = '' } = this.embedData
+ return image
+ },
+ embedPublisher() {
+ const { publisher = '' } = this.embedData
+ return publisher
+ },
+ embedTitle() {
+ const { title = '' } = this.embedData
+ return title
+ },
+ embedAuthor() {
+ const { author = '' } = this.embedData
+ return author
+ },
+ embedDescription() {
+ const { description = '' } = this.embedData
+ return description
+ },
dataEmbedUrl: {
get() {
return this.node.attrs.dataEmbedUrl
@@ -89,8 +172,63 @@ export default class Embed extends Node {
},
},
},
+ methods: {
+ ...mapMutations({
+ setCurrentUser: 'auth/SET_USER',
+ }),
+ clickPreview: function(xx, html) {
+ this.showOverlay = true
+ },
+ allowEmbedTemporar: function(xx, html) {
+ if (xx === 'openIframe') {
+ this.embedcode = html
+ this.showEmbed = true
+ } else {
+ this.embedcode = null
+ this.showEmbed = false
+ }
+ this.showOverlay = false
+ },
+ modalOpen: function() {
+ this.showOverlay = false
+ this.showchangeEmbedStatus = true
+ },
+ setConfirm: function() {
+ this.submit(true)
+ this.showOverlay = false
+ this.showchangeEmbedStatus = false
+ },
+ setCancel: function() {
+ this.submit(false)
+ this.showchangeEmbedStatus = false
+ },
+ async submit(allowEmbedIframes) {
+ try {
+ await this.$apollo.mutate({
+ mutation: allowEmbedIframesMutation(),
+ variables: {
+ id: this.currentUser.id,
+ allowEmbedIframes,
+ },
+ update: (store, { data: { UpdateUser } }) => {
+ const { allowEmbedIframes } = UpdateUser
+ this.setCurrentUser({
+ ...this.currentUser,
+ allowEmbedIframes,
+ })
+ },
+ })
+ this.$toast.success(this.$t('contribution.success'))
+ this.showEmbed = this.currentUser.allowEmbedIframes
+ } catch (err) {
+ this.$toast.error(err.message)
+ }
+ },
+ },
render(createElement) {
- return compiledTemplate.render.call(this, createElement)
+ if (this.embedHtml !== '')
+ return compiledTemplateVideoPreview.render.call(this, createElement)
+ if (this.embedHtml === '') return compiledTemplate.render.call(this, createElement)
},
}
}
diff --git a/webapp/graphql/User.js b/webapp/graphql/User.js
index 11149f398..d3c32362f 100644
--- a/webapp/graphql/User.js
+++ b/webapp/graphql/User.js
@@ -134,3 +134,14 @@ export const unfollowUserMutation = i18n => {
}
`
}
+
+export const allowEmbedIframesMutation = () => {
+ return gql`
+ mutation($id: ID!, $allowEmbedIframes: Boolean) {
+ UpdateUser(id: $id, allowEmbedIframes: $allowEmbedIframes) {
+ id
+ allowEmbedIframes
+ }
+ }
+ `
+}
diff --git a/webapp/pages/settings/allow-embeds.vue b/webapp/pages/settings/allow-embeds.vue
index 61f544af9..db6e7552e 100644
--- a/webapp/pages/settings/allow-embeds.vue
+++ b/webapp/pages/settings/allow-embeds.vue
@@ -45,16 +45,9 @@