Skip to content

Commit e5f25ad

Browse files
committed
Add footnotes feature to markup type
1 parent 80e25f9 commit e5f25ad

7 files changed

+64
-9
lines changed
Binary file not shown.

packages/admin/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"sortablejs": "^1.15.3",
7777
"tinycolor2": "^1.6.0",
7878
"tippy.js": "^6.3.7",
79+
"tiptap-footnotes": "^2.0.1",
7980
"type-fest": "^4.26.1",
8081
"vue": "^3.5.12",
8182
"vue-multiselect": "^3.1.0",

packages/admin/src/types/DitoTypeMarkup.vue

+26-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import { HorizontalRule } from '@tiptap/extension-horizontal-rule'
5252
import { OrderedList } from '@tiptap/extension-ordered-list'
5353
import { BulletList } from '@tiptap/extension-bullet-list'
5454
import { ListItem } from '@tiptap/extension-list-item'
55+
// Footnotes:
56+
import { Footnotes, FootnoteReference, Footnote } from 'tiptap-footnotes'
5557
// TODO:
5658
// import { Image } from '@tiptap/extension-image'
5759
// import { Mention } from '@tiptap/extension-mention'
@@ -139,7 +141,10 @@ export default DitoTypeComponent.register('markup', {
139141
toolButtons() {
140142
return this.getButtons('tools', {
141143
undo: true,
142-
redo: true
144+
redo: true,
145+
footnotes: {
146+
command: 'addFootnote'
147+
}
143148
})
144149
},
145150
@@ -341,7 +346,10 @@ export default DitoTypeComponent.register('markup', {
341346
} = this.schema
342347
return [
343348
// Essentials:
344-
Document,
349+
tools.footnotes
350+
? Document.extend({ content: 'block+ footnotes?' })
351+
: Document,
352+
345353
Text,
346354
Paragraph, // button can be controlled, but node needs to be on.
347355
@@ -364,6 +372,10 @@ export default DitoTypeComponent.register('markup', {
364372
(nodes.orderedList || nodes.bulletList) && ListItem,
365373
nodes.bulletList && BulletList,
366374
nodes.orderedList && OrderedList,
375+
376+
// Footnotes:
377+
...(tools.footnotes ? [Footnotes, Footnote, FootnoteReference] : []),
378+
367379
// TODO:
368380
// nodes.todoList && TodoItem,
369381
// nodes.todoList && TodoList,
@@ -625,12 +637,23 @@ const LinkWithTitle = Link.extend({
625637
626638
blockquote {
627639
border-left: 3px solid $color-lighter;
628-
padding-left: 1rem;
640+
padding-left: 1em;
629641
font-style: italic;
630642
631643
p {
632644
margin: 0;
633645
}
634646
}
647+
648+
ol.footnotes {
649+
margin-top: 1em;
650+
padding: 1em 0;
651+
list-style-type: decimal;
652+
padding-left: 2em;
653+
654+
&:has(li) {
655+
border-top: 1px solid $color-light;
656+
}
657+
}
635658
}
636659
</style>

packages/ui/src/icons/footnotes.svg

+16
Loading

packages/ui/src/icons/subscript.svg

+3-3
Loading

packages/ui/src/icons/superscript.svg

+3-3
Loading

yarn.lock

+15
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ __metadata:
10871087
sortablejs: "npm:^1.15.3"
10881088
tinycolor2: "npm:^1.6.0"
10891089
tippy.js: "npm:^6.3.7"
1090+
tiptap-footnotes: "npm:^2.0.1"
10901091
type-fest: "npm:^4.26.1"
10911092
typescript: "npm:^5.6.3"
10921093
vite: "npm:^5.4.10"
@@ -13390,6 +13391,20 @@ __metadata:
1339013391
languageName: node
1339113392
linkType: hard
1339213393

13394+
"tiptap-footnotes@npm:^2.0.1":
13395+
version: 2.0.1
13396+
resolution: "tiptap-footnotes@npm:2.0.1"
13397+
dependencies:
13398+
uuid: "npm:^9.0.1"
13399+
peerDependencies:
13400+
"@tiptap/core": ^2.4.0
13401+
"@tiptap/extension-list-item": ^2.4.0
13402+
"@tiptap/extension-ordered-list": ^2.4.0
13403+
"@tiptap/pm": ^2.4.0
13404+
checksum: 10/85735b10dd9b9827213eae8d4913ba36ef32d0c4d87d2efe548d44825fb20a1a3f9512cebdee87702d7b6b0908536de3bd4a0aaba84930adc425e72610e457c6
13405+
languageName: node
13406+
linkType: hard
13407+
1339313408
"tmp@npm:^0.0.33":
1339413409
version: 0.0.33
1339513410
resolution: "tmp@npm:0.0.33"

0 commit comments

Comments
 (0)