Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVinicius Reis <vinicius.reis@nextcloud.com>2022-03-07 21:12:11 +0300
committerVinicius Reis <vinicius.reis@nextcloud.com>2022-03-14 17:38:28 +0300
commit7f49c2a9e61dc3772048d860734cfaccc42a55c5 (patch)
tree4bed0b915efa8fe85333f0614dddc29f9a061ea9 /src
parent867c24c065391bc03692aebf16169af9e615f91b (diff)
🐛 (#2184): fix customContainer behavior
- Only paragraph inside container - Change and remove container Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
Diffstat (limited to 'src')
-rw-r--r--src/nodes/CustomContainer.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/nodes/CustomContainer.js b/src/nodes/CustomContainer.js
index 1e5e45a71..0e12833fa 100644
--- a/src/nodes/CustomContainer.js
+++ b/src/nodes/CustomContainer.js
@@ -20,14 +20,14 @@
*
*/
-import { Node, mergeAttributes } from '@tiptap/core'
+import { Node, mergeAttributes, isNodeActive } from '@tiptap/core'
import { typesAvailable } from '../markdownit/containers'
export default Node.create({
name: 'customContainer',
- content: 'block+',
+ content: 'paragraph+',
group: 'block',
@@ -90,8 +90,16 @@ export default Node.create({
setCustomContainer: attributes => ({ commands }) => {
return commands.wrapIn(this.name, attributes)
},
- toggleCustomContainer: attributes => ({ commands }) => {
- return commands.toggleWrap(this.name, attributes)
+ toggleCustomContainer: attributes => ({ commands, state }) => {
+ if (!isNodeActive(state, this.name)) {
+ return commands.setCustomContainer(attributes)
+ }
+
+ if (!isNodeActive(state, this.name, attributes)) {
+ return commands.updateAttributes(this.name, attributes)
+ }
+
+ return commands.unsetCustomContainer()
},
unsetCustomContainer: () => ({ commands }) => {
return commands.lift(this.name)