Skip to content

Commit

Permalink
fix: Disable nested embedding fully
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Mar 6, 2024
1 parent 57402de commit 7a052e5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/EditorFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ const loadSyntaxHighlight = async (language) => {
}
}

const createEditor = ({ language, onCreate, onUpdate = () => {}, extensions, enableRichEditing, session, relativePath }) => {
const createEditor = ({ language, onCreate, onUpdate = () => {}, extensions, enableRichEditing, session, relativePath, isEmbedded = false }) => {
let defaultExtensions
if (enableRichEditing) {
defaultExtensions = [
RichText.configure({
relativePath,
isEmbedded,
component: this,
extensions: [
Mention.configure({
Expand Down
2 changes: 2 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export default {
return val
},
inject: ['isEmbedded'],
props: {
richWorkspace: {
type: Boolean,
Expand Down Expand Up @@ -542,6 +543,7 @@ export default {
}),
],
enableRichEditing: this.isRichEditor,
isEmbedded: this.isEmbedded,
})
this.hasEditor = true
if (!documentState && documentSource) {
Expand Down
10 changes: 10 additions & 0 deletions src/components/ViewerComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
:active="active"
:autofocus="autofocus"
:share-token="shareToken"
:is-embedded="isEmbedded"
:mime="mime"
:show-outline-outside="showOutlineOutside" />
<div v-else
Expand Down Expand Up @@ -54,6 +55,11 @@ export default {
PlainTextReader,
Editor: getEditorInstance,
},
provide() {
return {
isEmbedded: this.isEmbedded,
}
},
props: {
filename: {
type: String,
Expand Down Expand Up @@ -91,6 +97,10 @@ export default {
type: String,
default: undefined,
},
isEmbedded: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand Down
5 changes: 4 additions & 1 deletion src/extensions/RichText.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default Extension.create({
extensions: [],
component: null,
relativePath: null,
isEmbedded: false,
}
},

Expand All @@ -80,7 +81,9 @@ export default Extension.create({
this.options.editing ? Markdown : null,
Document,
Text,
Paragraph,
Paragraph.configure({
isEmbedded: this.options.isEmbedded,
}),
HardBreak,
Heading,
Strong,
Expand Down
6 changes: 6 additions & 0 deletions src/nodes/Paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ const Paragraph = TiptapParagraph.extend({
return VueNodeViewRenderer(ParagraphView)
},

addOptions() {
return {
isEmbedded: false,
}
},

parseHTML() {
return this.parent().map(rule => Object.assign(rule, { preserveWhitespace: 'full' }))
},
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/ParagraphView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
<template>
<NodeViewWrapper class="vue-component" as="p">
<NodeViewContent class="paragraph-content" />
<NcReferenceList v-if="isLoggedIn && text"
<NcReferenceList v-if="isLoggedIn && text && !extension.options.isEmbedded"
:text="text"
:limit="1"
:interactive="true"
:interactive="!extension.options.isEmbedded"
contenteditable="false" />
</NodeViewWrapper>
</template>
Expand Down

0 comments on commit 7a052e5

Please sign in to comment.