@blocknote/core 0.14.0 → 0.14.2

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.
Files changed (35) hide show
  1. package/dist/blocknote.js +2169 -1744
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +5 -5
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/dist/webpack-stats.json +1 -1
  7. package/package.json +2 -2
  8. package/src/api/exporters/markdown/__snapshots__/lists/basic/markdown.md +2 -2
  9. package/src/api/exporters/markdown/__snapshots__/lists/nested/markdown.md +2 -2
  10. package/src/api/exporters/markdown/markdownExporter.ts +1 -1
  11. package/src/api/parsers/acceptedMIMETypes.ts +6 -0
  12. package/src/api/parsers/fileDropExtension.ts +51 -0
  13. package/src/api/parsers/handleFileInsertion.ts +99 -0
  14. package/src/api/parsers/pasteExtension.ts +16 -16
  15. package/src/editor/Block.css +4 -3
  16. package/src/editor/BlockNoteEditor.ts +6 -7
  17. package/src/editor/BlockNoteExtensions.ts +5 -1
  18. package/src/extensions/FilePanel/FilePanelPlugin.ts +4 -4
  19. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +2 -2
  20. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +12 -4
  21. package/src/extensions/Placeholder/PlaceholderPlugin.ts +11 -2
  22. package/src/extensions/SideMenu/SideMenuPlugin.ts +59 -17
  23. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +7 -5
  24. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +1 -1
  25. package/src/extensions/TableHandles/TableHandlesPlugin.ts +46 -24
  26. package/src/i18n/locales/ar.ts +288 -0
  27. package/src/i18n/locales/index.ts +1 -0
  28. package/types/src/api/parsers/acceptedMIMETypes.d.ts +1 -0
  29. package/types/src/api/parsers/fileDropExtension.d.ts +6 -0
  30. package/types/src/api/parsers/handleFileInsertion.d.ts +3 -0
  31. package/types/src/editor/BlockNoteEditor.d.ts +1 -1
  32. package/types/src/editor/BlockNoteExtensions.d.ts +2 -2
  33. package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +1 -1
  34. package/types/src/i18n/locales/ar.d.ts +2 -0
  35. package/types/src/i18n/locales/index.d.ts +1 -0
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .bn-block-outer{line-height:1.5;transition:margin .2s}.bn-block{display:flex;flex-direction:column}.bn-block-content{display:flex;padding:3px 0;transition:font-size .2s;width:100%}.bn-block-content:before{transition:all .2s}.bn-block-content.ProseMirror-selectednode>*,.ProseMirror-selectednode>.bn-block-content>*{border-radius:4px;outline:4px solid rgb(100,160,255)}.bn-block-group .bn-block-group{margin-left:1.5em}.bn-block-group .bn-block-group>.bn-block-outer{position:relative}.bn-block-group .bn-block-group>.bn-block-outer:not([data-prev-depth-changed]):before{content:" ";display:inline;position:absolute;left:-20px;height:100%;transition:all .2s .1s}.bn-block-group .bn-block-group>.bn-block-outer[data-prev-depth-change="-2"]:before{height:0}.bn-inline-content code{font-family:monospace}[data-prev-depth-change="1"]{--x: 1}[data-prev-depth-change="2"]{--x: 2}[data-prev-depth-change="3"]{--x: 3}[data-prev-depth-change="4"]{--x: 4}[data-prev-depth-change="5"]{--x: 5}[data-prev-depth-change="-1"]{--x: -1}[data-prev-depth-change="-2"]{--x: -2}[data-prev-depth-change="-3"]{--x: -3}[data-prev-depth-change="-4"]{--x: -4}[data-prev-depth-change="-5"]{--x: -5}.bn-block-outer[data-prev-depth-change]{margin-left:calc(10px * var(--x))}.bn-block-outer[data-prev-depth-change] .bn-block-outer[data-prev-depth-change]{margin-left:0}[data-level="1"]{--level: 3em}[data-level="2"]{--level: 2em}[data-level="3"]{--level: 1.3em}[data-prev-level="1"]{--prev-level: 3em}[data-prev-level="2"]{--prev-level: 2em}[data-prev-level="3"]{--prev-level: 1.3em}.bn-block-outer[data-prev-type=heading]>.bn-block>.bn-block-content{font-size:var(--prev-level);font-weight:700}.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=heading]{font-size:var(--level);font-weight:700}.bn-block-content:before{margin-right:0;content:""}.bn-block-content[data-content-type=numberedListItem]{display:flex;gap:1.2em}[data-content-type=numberedListItem]{--index: attr(data-index)}[data-prev-type=numberedListItem]{--prev-index: attr(data-prev-index)}.bn-block-outer[data-prev-type=numberedListItem]:not([data-prev-index=none])>.bn-block>.bn-block-content:before{content:var(--prev-index) "."}.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=numberedListItem]:before{content:var(--index) "."}.bn-block-content[data-content-type=bulletListItem]{display:flex;gap:1.2em}.bn-block-content[data-content-type=checkListItem]>div{display:flex}.bn-block-content[data-content-type=checkListItem]>div>div>input{margin:0 1.2em 0 0;cursor:pointer}.bn-block-content[data-content-type=checkListItem][data-checked=true] .bn-inline-content{text-decoration:line-through}.bn-block-content[data-text-alignment=center]{justify-content:center}.bn-block-content[data-text-alignment=right]{justify-content:flex-end}.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before{content:"•"}.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before{content:"•"}[data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before{content:"◦"}[data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before{content:"◦"}[data-content-type=bulletListItem]~.bn-block-group [data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before{content:"▪"}[data-content-type=bulletListItem]~.bn-block-group [data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before{content:"▪"}[data-file-block] .bn-file-block-content-wrapper:has(.bn-add-file-button),[data-file-block] .bn-file-block-content-wrapper:has(.bn-file-default-preview){width:100%}[data-file-block] .bn-file-block-content-wrapper{cursor:pointer;display:flex;flex-direction:column;justify-content:stretch;-webkit-user-select:none;user-select:none}[data-file-block] .bn-add-file-button{align-items:center;background-color:#f2f1ee;border-radius:4px;color:#7d797a;display:flex;flex-direction:row;gap:10px;padding:12px;width:100%}.bn-editor[contenteditable=true] [data-file-block] .bn-add-file-button:hover{background-color:#e1e1e1}[data-file-block] .bn-add-file-button-icon{width:24px;height:24px}[data-file-block] .bn-add-file-button .bn-add-file-button-text{font-size:.9rem}[data-file-block] .bn-file-and-caption-wrapper{display:flex;flex-direction:column;border-radius:4px}[data-file-block] .bn-file-default-preview{align-items:center;border-radius:4px;display:flex;flex-direction:row;gap:4px;padding:4px;width:100%}[data-file-block] .bn-file-default-preview:hover,.ProseMirror-selectednode .bn-file-default-preview{background-color:#e1e1e1}[data-file-block] .bn-file-default-preview-icon{width:24px;height:24px}[data-file-block] .bn-visual-media-wrapper{display:flex;flex-direction:row;align-items:center;position:relative;width:fit-content}[data-file-block] .bn-visual-media{border-radius:4px;max-width:100%}[data-file-block] .bn-visual-media-resize-handle{position:absolute;width:8px;height:30px;background-color:#000;border:1px solid white;border-radius:4px;cursor:ew-resize}[data-content-type=audio]>.bn-file-block-content-wrapper,.bn-audio{width:100%}[data-file-block] .bn-file-caption{font-size:.8em;padding-block:4px}[data-file-block] .bn-file-caption:empty{padding-block:0}.bn-inline-content:has(>.ProseMirror-trailingBreak:only-child):before{pointer-events:none;height:0;position:absolute;font-style:italic}[data-text-color=gray]{color:#9b9a97}[data-text-color=brown]{color:#64473a}[data-text-color=red]{color:#e03e3e}[data-text-color=orange]{color:#d9730d}[data-text-color=yellow]{color:#dfab01}[data-text-color=green]{color:#4d6461}[data-text-color=blue]{color:#0b6e99}[data-text-color=purple]{color:#6940a5}[data-text-color=pink]{color:#ad1a72}[data-background-color=gray]{background-color:#ebeced}[data-background-color=brown]{background-color:#e9e5e3}[data-background-color=red]{background-color:#fbe4e4}[data-background-color=orange]{background-color:#faebdd}[data-background-color=yellow]{background-color:#fbf3db}[data-background-color=green]{background-color:#ddedea}[data-background-color=blue]{background-color:#ddebf1}[data-background-color=purple]{background-color:#eae4f2}[data-background-color=pink]{background-color:#f4dfeb}[data-text-alignment=left]{justify-content:flex-start;text-align:left}[data-text-alignment=center]{justify-content:center;text-align:center}[data-text-alignment=right]{justify-content:flex-end;text-align:right}[data-text-alignment=justify]{justify-content:flex-start;text-align:justify}.ProseMirror .tableWrapper{overflow-x:auto}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;overflow:hidden}.ProseMirror td,.ProseMirror th{vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror .column-resize-handle{position:absolute;right:-2px;top:0;bottom:0;width:4px;z-index:20;background-color:#adf;pointer-events:none}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell:after{z-index:2;position:absolute;content:"";left:0;right:0;top:0;bottom:0;background:rgba(200,200,255,.4);pointer-events:none}.bn-editor{outline:none;padding-inline:54px;--N800: #172b4d;--N40: #dfe1e6}.bn-root{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bn-root *,.bn-root *:before,.bn-root *:after{-webkit-box-sizing:inherit;-moz-box-sizing:inherit;box-sizing:inherit}.bn-default-styles p,.bn-default-styles h1,.bn-default-styles h2,.bn-default-styles h3,.bn-default-styles li{margin:0;padding:0;font-size:inherit;min-width:2px!important}.bn-default-styles{font-size:16px;font-weight:400;font-family:Inter,SF Pro Display,-apple-system,BlinkMacSystemFont,Open Sans,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.bn-table-drop-cursor{position:absolute;z-index:20;background-color:#adf;pointer-events:none}.bn-drag-preview{position:absolute;left:-100000px}.collaboration-cursor__caret{border-left:1px solid #0d0d0d;border-right:1px solid #0d0d0d;margin-left:-1px;margin-right:-1px;pointer-events:none;position:relative;word-break:normal}.collaboration-cursor__label{border-radius:3px 3px 3px 0;color:#0d0d0d;font-size:12px;font-style:normal;font-weight:600;left:-1px;line-height:normal;padding:.1rem .3rem;position:absolute;top:-1.4em;-webkit-user-select:none;user-select:none;white-space:nowrap}.bn-editor table{width:auto!important}.bn-editor th,.bn-editor td{min-width:1em;border:1px solid #ddd;padding:3px 5px}.bn-editor .tableWrapper{margin:1em 0}.bn-editor th{font-weight:700;text-align:left}
1
+ .bn-block-outer{line-height:1.5;transition:margin .2s}.bn-block{display:flex;flex-direction:column}.bn-block-content{display:flex;padding:3px 0;transition:font-size .2s;width:100%}.bn-block-content:before{transition:all .2s}.bn-block-content.ProseMirror-selectednode>*,.ProseMirror-selectednode>.bn-block-content>*{border-radius:4px;outline:4px solid rgb(100,160,255)}.bn-block-group .bn-block-group{margin-left:1.5em}.bn-block-group .bn-block-group>.bn-block-outer{position:relative}.bn-block-group .bn-block-group>.bn-block-outer:not([data-prev-depth-changed]):before{content:" ";display:inline;position:absolute;left:-20px;height:100%;transition:all .2s .1s}.bn-block-group .bn-block-group>.bn-block-outer[data-prev-depth-change="-2"]:before{height:0}.bn-inline-content code{font-family:monospace}[data-prev-depth-change="1"]{--x: 1}[data-prev-depth-change="2"]{--x: 2}[data-prev-depth-change="3"]{--x: 3}[data-prev-depth-change="4"]{--x: 4}[data-prev-depth-change="5"]{--x: 5}[data-prev-depth-change="-1"]{--x: -1}[data-prev-depth-change="-2"]{--x: -2}[data-prev-depth-change="-3"]{--x: -3}[data-prev-depth-change="-4"]{--x: -4}[data-prev-depth-change="-5"]{--x: -5}.bn-block-outer[data-prev-depth-change]{margin-left:calc(10px * var(--x))}.bn-block-outer[data-prev-depth-change] .bn-block-outer[data-prev-depth-change]{margin-left:0}[data-level="1"]{--level: 3em}[data-level="2"]{--level: 2em}[data-level="3"]{--level: 1.3em}[data-prev-level="1"]{--prev-level: 3em}[data-prev-level="2"]{--prev-level: 2em}[data-prev-level="3"]{--prev-level: 1.3em}.bn-block-outer[data-prev-type=heading]>.bn-block>.bn-block-content{font-size:var(--prev-level);font-weight:700}.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=heading]{font-size:var(--level);font-weight:700}.bn-block-content:before{margin-right:0;content:""}.bn-block-content[data-content-type=numberedListItem]{display:flex;gap:.5em}[data-content-type=numberedListItem]{--index: attr(data-index)}[data-prev-type=numberedListItem]{--prev-index: attr(data-prev-index)}.bn-block-outer[data-prev-type=numberedListItem]:not([data-prev-index=none])>.bn-block>.bn-block-content:before{content:var(--prev-index) "."}.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=numberedListItem]:before{content:var(--index) "."}.bn-block-content[data-content-type=bulletListItem]{display:flex;gap:.5em}.bn-block-content[data-content-type=checkListItem]>div{display:flex}.bn-block-content[data-content-type=checkListItem]>div>div>input{margin:0;margin-inline-end:.5em;cursor:pointer}.bn-block-content[data-content-type=checkListItem][data-checked=true] .bn-inline-content{text-decoration:line-through}.bn-block-content[data-text-alignment=center]{justify-content:center}.bn-block-content[data-text-alignment=right]{justify-content:flex-end}.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before{content:"•"}.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before{content:"•"}[data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before{content:"◦"}[data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before{content:"◦"}[data-content-type=bulletListItem]~.bn-block-group [data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer[data-prev-type=bulletListItem]>.bn-block>.bn-block-content:before{content:"▪"}[data-content-type=bulletListItem]~.bn-block-group [data-content-type=bulletListItem]~.bn-block-group>.bn-block-outer:not([data-prev-type])>.bn-block>.bn-block-content[data-content-type=bulletListItem]:before{content:"▪"}[data-file-block] .bn-file-block-content-wrapper:has(.bn-add-file-button),[data-file-block] .bn-file-block-content-wrapper:has(.bn-file-default-preview){width:100%}[data-file-block] .bn-file-block-content-wrapper{cursor:pointer;display:flex;flex-direction:column;justify-content:stretch;-webkit-user-select:none;user-select:none}[data-file-block] .bn-add-file-button{align-items:center;background-color:#f2f1ee;border-radius:4px;color:#7d797a;display:flex;flex-direction:row;gap:10px;padding:12px;width:100%}.bn-editor[contenteditable=true] [data-file-block] .bn-add-file-button:hover{background-color:#e1e1e1}[data-file-block] .bn-add-file-button-icon{width:24px;height:24px}[data-file-block] .bn-add-file-button .bn-add-file-button-text{font-size:.9rem}[data-file-block] .bn-file-and-caption-wrapper{display:flex;flex-direction:column;border-radius:4px}[data-file-block] .bn-file-default-preview{align-items:center;border-radius:4px;display:flex;flex-direction:row;gap:4px;padding:4px;width:100%}[data-file-block] .bn-file-default-preview:hover,.ProseMirror-selectednode .bn-file-default-preview{background-color:#e1e1e1}[data-file-block] .bn-file-default-preview-icon{width:24px;height:24px}[data-file-block] .bn-visual-media-wrapper{display:flex;flex-direction:row;align-items:center;position:relative;width:fit-content}[data-file-block] .bn-visual-media{border-radius:4px;max-width:100%}[data-file-block] .bn-visual-media-resize-handle{position:absolute;width:8px;height:30px;background-color:#000;border:1px solid white;border-radius:4px;cursor:ew-resize}[data-content-type=audio]>.bn-file-block-content-wrapper,.bn-audio{width:100%}[data-file-block] .bn-file-caption{font-size:.8em;padding-block:4px}[data-file-block] .bn-file-caption:empty{padding-block:0}.bn-inline-content:has(>.ProseMirror-trailingBreak:only-child):before{pointer-events:none;height:0;position:absolute;font-style:italic}[data-text-color=gray]{color:#9b9a97}[data-text-color=brown]{color:#64473a}[data-text-color=red]{color:#e03e3e}[data-text-color=orange]{color:#d9730d}[data-text-color=yellow]{color:#dfab01}[data-text-color=green]{color:#4d6461}[data-text-color=blue]{color:#0b6e99}[data-text-color=purple]{color:#6940a5}[data-text-color=pink]{color:#ad1a72}[data-background-color=gray]{background-color:#ebeced}[data-background-color=brown]{background-color:#e9e5e3}[data-background-color=red]{background-color:#fbe4e4}[data-background-color=orange]{background-color:#faebdd}[data-background-color=yellow]{background-color:#fbf3db}[data-background-color=green]{background-color:#ddedea}[data-background-color=blue]{background-color:#ddebf1}[data-background-color=purple]{background-color:#eae4f2}[data-background-color=pink]{background-color:#f4dfeb}[data-text-alignment=left]{justify-content:flex-start;text-align:left}[data-text-alignment=center]{justify-content:center;text-align:center}[data-text-alignment=right]{justify-content:flex-end;text-align:right}[data-text-alignment=justify]{justify-content:flex-start;text-align:justify}.ProseMirror .tableWrapper{overflow-x:auto}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;overflow:hidden}.ProseMirror td,.ProseMirror th{vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror .column-resize-handle{position:absolute;right:-2px;top:0;bottom:0;width:4px;z-index:20;background-color:#adf;pointer-events:none}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell:after{z-index:2;position:absolute;content:"";left:0;right:0;top:0;bottom:0;background:rgba(200,200,255,.4);pointer-events:none}.bn-editor{outline:none;padding-inline:54px;--N800: #172b4d;--N40: #dfe1e6}.bn-root{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.bn-root *,.bn-root *:before,.bn-root *:after{-webkit-box-sizing:inherit;-moz-box-sizing:inherit;box-sizing:inherit}.bn-default-styles p,.bn-default-styles h1,.bn-default-styles h2,.bn-default-styles h3,.bn-default-styles li{margin:0;padding:0;font-size:inherit;min-width:2px!important}.bn-default-styles{font-size:16px;font-weight:400;font-family:Inter,SF Pro Display,-apple-system,BlinkMacSystemFont,Open Sans,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.bn-table-drop-cursor{position:absolute;z-index:20;background-color:#adf;pointer-events:none}.bn-drag-preview{position:absolute;left:-100000px}.collaboration-cursor__caret{border-left:1px solid #0d0d0d;border-right:1px solid #0d0d0d;margin-left:-1px;margin-right:-1px;pointer-events:none;position:relative;word-break:normal}.collaboration-cursor__label{border-radius:3px 3px 3px 0;color:#0d0d0d;font-size:12px;font-style:normal;font-weight:600;left:-1px;line-height:normal;padding:.1rem .3rem;position:absolute;top:-1.4em;-webkit-user-select:none;user-select:none;white-space:nowrap}.bn-editor table{width:auto!important}.bn-editor th,.bn-editor td{min-width:1em;border:1px solid #ddd;padding:3px 5px}.bn-editor .tableWrapper{margin:1em 0}.bn-editor th{font-weight:700;text-align:left}
@@ -1 +1 @@
1
- {"builtAt":1717710248883,"assets":[{"name":"blocknote.umd.cjs","size":166801},{"name":"blocknote.umd.cjs.map","size":630937}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote.umd.cjs"],"names":["index"]}],"modules":[{"name":"./src/i18n/locales/en.ts","size":6512,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/fr.ts","size":7122,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/is.ts","size":6695,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ja.ts","size":6185,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ko.ts","size":5879,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/nl.ts","size":6834,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pl.ts","size":6595,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pt.ts","size":6785,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/vi.ts","size":6643,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/zh.ts","size":5872,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/extensions/UniqueID/UniqueID.ts","size":8518,"chunks":["a1ee98a"]},{"name":"./src/api/getBlockInfoFromPos.ts","size":1691,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/types.ts","size":302,"chunks":["a1ee98a"]},{"name":"./src/util/typescript.ts","size":331,"chunks":["a1ee98a"]},{"name":"./src/api/nodeConversions/nodeConversions.ts","size":11998,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/sharedHTMLConversion.ts","size":2293,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts","size":2687,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/externalHTMLExporter.ts","size":1107,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/internalHTMLSerializer.ts","size":704,"chunks":["a1ee98a"]},{"name":"./src/util/browser.ts","size":536,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockHelpers.ts","size":1731,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultProps.ts","size":269,"chunks":["a1ee98a"]},{"name":"./src/util/string.ts","size":299,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/internal.ts","size":3877,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/createSpec.ts","size":2814,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/internal.ts","size":1357,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/createSpec.ts","size":1627,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/internal.ts","size":1162,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/createSpec.ts","size":1263,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/fileBlockHelpers.ts","size":8593,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/FileBlockContent.ts","size":1939,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/imageBlockHelpers.ts","size":175,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/ImageBlockContent.ts","size":3959,"chunks":["a1ee98a"]},{"name":"./src/blocks/VideoBlockContent/videoBlockHelpers.ts","size":175,"chunks":["a1ee98a"]},{"name":"./src/blocks/VideoBlockContent/VideoBlockContent.ts","size":3763,"chunks":["a1ee98a"]},{"name":"./src/blocks/AudioBlockContent/audioBlockHelpers.ts","size":108,"chunks":["a1ee98a"]},{"name":"./src/blocks/AudioBlockContent/AudioBlockContent.ts","size":3741,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts","size":316,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorMark.ts","size":946,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorMark.ts","size":866,"chunks":["a1ee98a"]},{"name":"./src/api/getCurrentBlockContentType.ts","size":192,"chunks":["a1ee98a"]},{"name":"./src/blocks/HeadingBlockContent/HeadingBlockContent.ts","size":3439,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts","size":1201,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts","size":3122,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts","size":1862,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts","size":3437,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts","size":6423,"chunks":["a1ee98a"]},{"name":"./src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts","size":1307,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableExtension.ts","size":1462,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableBlockContent.ts","size":1624,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlocks.ts","size":1123,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockTypeGuards.ts","size":1331,"chunks":["a1ee98a"]},{"name":"./src/api/nodeUtil.ts","size":548,"chunks":["a1ee98a"]},{"name":"./src/api/blockManipulation/blockManipulation.ts","size":5738,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/removeUnderlinesRehypePlugin.ts","size":752,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts","size":775,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/markdownExporter.ts","size":576,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/util/nestedLists.ts","size":2174,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/parseHTML.ts","size":503,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/markdown/parseMarkdown.ts","size":1054,"chunks":["a1ee98a"]},{"name":"./src/util/EventEmitter.ts","size":744,"chunks":["a1ee98a"]},{"name":"./src/extensions/FilePanel/FilePanelPlugin.ts","size":3453,"chunks":["a1ee98a"]},{"name":"./src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts","size":4344,"chunks":["a1ee98a"]},{"name":"./src/extensions/LinkToolbar/LinkToolbarPlugin.ts","size":7285,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/SuggestionPlugin.ts","size":7658,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/MultipleNodeSelection.ts","size":1616,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/SideMenuPlugin.ts","size":16427,"chunks":["a1ee98a"]},{"name":"./src/extensions/TableHandles/TableHandlesPlugin.ts","size":14834,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/copyExtension.ts","size":2883,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/pasteExtension.ts","size":1211,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorExtension.ts","size":688,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextAlignment/TextAlignmentExtension.ts","size":825,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorExtension.ts","size":622,"chunks":["a1ee98a"]},{"name":"./src/extensions/TrailingNode/TrailingNodeExtension.ts","size":1594,"chunks":["a1ee98a"]},{"name":"./src/extensions/NonEditableBlocks/NonEditableBlockPlugin.ts","size":1014,"chunks":["a1ee98a"]},{"name":"./src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts","size":4578,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockContainer.ts","size":18112,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockGroup.ts","size":1097,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/Doc.ts","size":90,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteExtensions.ts","size":4090,"chunks":["a1ee98a"]},{"name":"./src/editor/transformPasted.ts","size":1062,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteSchema.ts","size":1044,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteTipTapEditor.ts","size":2655,"chunks":["a1ee98a"]},{"name":"./src/extensions/Placeholder/PlaceholderPlugin.ts","size":2399,"chunks":["a1ee98a"]},{"name":"./src/editor/Block.css","size":17,"chunks":["a1ee98a"]},{"name":"./src/editor/editor.css","size":18,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteEditor.ts","size":23040,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts","size":6248,"chunks":["a1ee98a"]},{"name":"./src/api/testUtil/partialBlockTestUtil.ts","size":2166,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]}]}
1
+ {"builtAt":1719257221461,"assets":[{"name":"blocknote.umd.cjs","size":174820},{"name":"blocknote.umd.cjs.map","size":652657}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote.umd.cjs"],"names":["index"]}],"modules":[{"name":"./src/i18n/locales/ar.ts","size":6398,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/en.ts","size":6512,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/fr.ts","size":7122,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/is.ts","size":6695,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ja.ts","size":6185,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ko.ts","size":5879,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/nl.ts","size":6834,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pl.ts","size":6595,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/pt.ts","size":6785,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/vi.ts","size":6643,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/zh.ts","size":5872,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/extensions/UniqueID/UniqueID.ts","size":8518,"chunks":["a1ee98a"]},{"name":"./src/api/getBlockInfoFromPos.ts","size":1691,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/types.ts","size":302,"chunks":["a1ee98a"]},{"name":"./src/util/typescript.ts","size":331,"chunks":["a1ee98a"]},{"name":"./src/api/nodeConversions/nodeConversions.ts","size":11998,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/sharedHTMLConversion.ts","size":2293,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts","size":2687,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/externalHTMLExporter.ts","size":1107,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/internalHTMLSerializer.ts","size":704,"chunks":["a1ee98a"]},{"name":"./src/util/browser.ts","size":536,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockHelpers.ts","size":1731,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultProps.ts","size":269,"chunks":["a1ee98a"]},{"name":"./src/util/string.ts","size":299,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/internal.ts","size":3877,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/createSpec.ts","size":2814,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/internal.ts","size":1357,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/createSpec.ts","size":1627,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/internal.ts","size":1162,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/createSpec.ts","size":1263,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/fileBlockHelpers.ts","size":8593,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/FileBlockContent.ts","size":1939,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/imageBlockHelpers.ts","size":175,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/ImageBlockContent.ts","size":3959,"chunks":["a1ee98a"]},{"name":"./src/blocks/VideoBlockContent/videoBlockHelpers.ts","size":175,"chunks":["a1ee98a"]},{"name":"./src/blocks/VideoBlockContent/VideoBlockContent.ts","size":3763,"chunks":["a1ee98a"]},{"name":"./src/blocks/AudioBlockContent/audioBlockHelpers.ts","size":108,"chunks":["a1ee98a"]},{"name":"./src/blocks/AudioBlockContent/AudioBlockContent.ts","size":3741,"chunks":["a1ee98a"]},{"name":"./src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts","size":316,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorMark.ts","size":946,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorMark.ts","size":866,"chunks":["a1ee98a"]},{"name":"./src/api/getCurrentBlockContentType.ts","size":192,"chunks":["a1ee98a"]},{"name":"./src/blocks/HeadingBlockContent/HeadingBlockContent.ts","size":3439,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts","size":1201,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts","size":3122,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts","size":1862,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts","size":3437,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts","size":6423,"chunks":["a1ee98a"]},{"name":"./src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts","size":1307,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableExtension.ts","size":1462,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableBlockContent.ts","size":1624,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlocks.ts","size":1123,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockTypeGuards.ts","size":1331,"chunks":["a1ee98a"]},{"name":"./src/api/nodeUtil.ts","size":548,"chunks":["a1ee98a"]},{"name":"./src/api/blockManipulation/blockManipulation.ts","size":5738,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/removeUnderlinesRehypePlugin.ts","size":752,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts","size":775,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/markdownExporter.ts","size":622,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/util/nestedLists.ts","size":2174,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/parseHTML.ts","size":503,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/markdown/parseMarkdown.ts","size":1054,"chunks":["a1ee98a"]},{"name":"./src/util/EventEmitter.ts","size":744,"chunks":["a1ee98a"]},{"name":"./src/extensions/FilePanel/FilePanelPlugin.ts","size":3480,"chunks":["a1ee98a"]},{"name":"./src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts","size":4355,"chunks":["a1ee98a"]},{"name":"./src/extensions/LinkToolbar/LinkToolbarPlugin.ts","size":7365,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/SuggestionPlugin.ts","size":7738,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/MultipleNodeSelection.ts","size":1616,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/SideMenuPlugin.ts","size":16932,"chunks":["a1ee98a"]},{"name":"./src/extensions/TableHandles/TableHandlesPlugin.ts","size":15292,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/copyExtension.ts","size":2883,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts","size":6248,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/acceptedMIMETypes.ts","size":91,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/handleFileInsertion.ts","size":1983,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/pasteExtension.ts","size":1244,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/fileDropExtension.ts","size":884,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorExtension.ts","size":688,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextAlignment/TextAlignmentExtension.ts","size":825,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorExtension.ts","size":622,"chunks":["a1ee98a"]},{"name":"./src/extensions/TrailingNode/TrailingNodeExtension.ts","size":1594,"chunks":["a1ee98a"]},{"name":"./src/extensions/NonEditableBlocks/NonEditableBlockPlugin.ts","size":1014,"chunks":["a1ee98a"]},{"name":"./src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts","size":4578,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockContainer.ts","size":18112,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockGroup.ts","size":1097,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/Doc.ts","size":90,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteExtensions.ts","size":4243,"chunks":["a1ee98a"]},{"name":"./src/editor/transformPasted.ts","size":1062,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteSchema.ts","size":1044,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteTipTapEditor.ts","size":2655,"chunks":["a1ee98a"]},{"name":"./src/extensions/Placeholder/PlaceholderPlugin.ts","size":2758,"chunks":["a1ee98a"]},{"name":"./src/editor/Block.css","size":17,"chunks":["a1ee98a"]},{"name":"./src/editor/editor.css","size":18,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteEditor.ts","size":23024,"chunks":["a1ee98a"]},{"name":"./src/api/testUtil/partialBlockTestUtil.ts","size":2166,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]}]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "homepage": "https://github.com/TypeCellOS/BlockNote",
4
4
  "private": false,
5
5
  "license": "MPL-2.0",
6
- "version": "0.14.0",
6
+ "version": "0.14.2",
7
7
  "files": [
8
8
  "dist",
9
9
  "types",
@@ -116,5 +116,5 @@
116
116
  "access": "public",
117
117
  "registry": "https://registry.npmjs.org/"
118
118
  },
119
- "gitHead": "51cf600ac354d1fe76c207ec5726c9cd365f06a3"
119
+ "gitHead": "edfb6e84dbcefc26feb5045bd9a6351b05aefdd8"
120
120
  }
@@ -4,5 +4,5 @@
4
4
  1. Numbered List Item 1
5
5
  2. Numbered List Item 2
6
6
 
7
- * \[ ] Check List Item 1
8
- * \[x] Check List Item 2
7
+ * [ ] Check List Item 1
8
+ * [x] Check List Item 2
@@ -6,5 +6,5 @@
6
6
 
7
7
  2. Numbered List Item 2
8
8
 
9
- * \[ ] Check List Item 1
10
- * \[x] Check List Item 2
9
+ * [ ] Check List Item 1
10
+ * [x] Check List Item 2
@@ -18,7 +18,7 @@ export function cleanHTMLToMarkdown(cleanHTMLString: string) {
18
18
  .use(addSpacesToCheckboxes)
19
19
  .use(rehypeRemark)
20
20
  .use(remarkGfm)
21
- .use(remarkStringify)
21
+ .use(remarkStringify, { handlers: { text: (node) => node.value } })
22
22
  .processSync(cleanHTMLString);
23
23
 
24
24
  return markdownString.value as string;
@@ -0,0 +1,6 @@
1
+ export const acceptedMIMETypes = [
2
+ "blocknote/html",
3
+ "Files",
4
+ "text/html",
5
+ "text/plain",
6
+ ] as const;
@@ -0,0 +1,51 @@
1
+ import { Extension } from "@tiptap/core";
2
+ import { Plugin } from "prosemirror-state";
3
+
4
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
5
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
6
+ import { handleFileInsertion } from "./handleFileInsertion";
7
+ import { acceptedMIMETypes } from "./acceptedMIMETypes";
8
+
9
+ export const createDropFileExtension = <
10
+ BSchema extends BlockSchema,
11
+ I extends InlineContentSchema,
12
+ S extends StyleSchema
13
+ >(
14
+ editor: BlockNoteEditor<BSchema, I, S>
15
+ ) =>
16
+ Extension.create<{ editor: BlockNoteEditor<BSchema, I, S> }, undefined>({
17
+ name: "dropFile",
18
+ addProseMirrorPlugins() {
19
+ return [
20
+ new Plugin({
21
+ props: {
22
+ handleDOMEvents: {
23
+ drop(_view, event) {
24
+ if (!editor.isEditable) {
25
+ return;
26
+ }
27
+
28
+ let format: (typeof acceptedMIMETypes)[number] | null = null;
29
+ for (const mimeType of acceptedMIMETypes) {
30
+ if (event.dataTransfer!.types.includes(mimeType)) {
31
+ format = mimeType;
32
+ break;
33
+ }
34
+ }
35
+ if (format === null) {
36
+ return true;
37
+ }
38
+
39
+ if (format === "Files") {
40
+ handleFileInsertion(event, editor);
41
+ return true;
42
+ }
43
+
44
+ return false;
45
+ },
46
+ },
47
+ },
48
+ }),
49
+ ];
50
+ },
51
+ });
@@ -0,0 +1,99 @@
1
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
2
+ import { PartialBlock } from "../../blocks/defaultBlocks";
3
+ import { insertOrUpdateBlock } from "../../extensions/SuggestionMenu/getDefaultSlashMenuItems";
4
+ import {
5
+ BlockSchema,
6
+ FileBlockConfig,
7
+ InlineContentSchema,
8
+ StyleSchema,
9
+ } from "../../schema";
10
+ import { acceptedMIMETypes } from "./acceptedMIMETypes";
11
+
12
+ function checkMIMETypesMatch(mimeType1: string, mimeType2: string) {
13
+ const types1 = mimeType1.split("/");
14
+ const types2 = mimeType2.split("/");
15
+
16
+ if (types1.length !== 2) {
17
+ throw new Error(`The string ${mimeType1} is not a valid MIME type.`);
18
+ }
19
+ if (types2.length !== 2) {
20
+ throw new Error(`The string ${mimeType2} is not a valid MIME type.`);
21
+ }
22
+
23
+ if (types1[1] === "*" || types2[1] === "*") {
24
+ return types1[0] === types2[0];
25
+ }
26
+ if (types1[0] === "*" || types2[0] === "*") {
27
+ return types1[1] === types2[1];
28
+ }
29
+
30
+ return types1[0] === types2[0] && types1[1] === types2[1];
31
+ }
32
+
33
+ export async function handleFileInsertion<
34
+ BSchema extends BlockSchema,
35
+ I extends InlineContentSchema,
36
+ S extends StyleSchema
37
+ >(event: DragEvent | ClipboardEvent, editor: BlockNoteEditor<BSchema, I, S>) {
38
+ if (!editor.uploadFile) {
39
+ return;
40
+ }
41
+
42
+ const dataTransfer =
43
+ "dataTransfer" in event ? event.dataTransfer : event.clipboardData;
44
+ if (dataTransfer === null) {
45
+ return;
46
+ }
47
+
48
+ let format: (typeof acceptedMIMETypes)[number] | null = null;
49
+ for (const mimeType of acceptedMIMETypes) {
50
+ if (dataTransfer.types.includes(mimeType)) {
51
+ format = mimeType;
52
+ break;
53
+ }
54
+ }
55
+ if (format !== "Files") {
56
+ return;
57
+ }
58
+
59
+ const items = dataTransfer.items;
60
+ if (!items) {
61
+ return;
62
+ }
63
+
64
+ event.preventDefault();
65
+
66
+ const fileBlockConfigs = Object.values(editor.schema.blockSchema).filter(
67
+ (blockConfig) => blockConfig.isFileBlock
68
+ ) as FileBlockConfig[];
69
+
70
+ for (let i = 0; i < items.length; i++) {
71
+ // Gets file block corresponding to MIME type.
72
+ let fileBlockType = "file";
73
+ for (const fileBlockConfig of fileBlockConfigs) {
74
+ for (const mimeType of fileBlockConfig.fileBlockAcceptMimeTypes || []) {
75
+ if (checkMIMETypesMatch(items[i].type, mimeType)) {
76
+ fileBlockType = fileBlockConfig.type;
77
+ break;
78
+ }
79
+ }
80
+ }
81
+
82
+ const file = items[i].getAsFile();
83
+ if (file) {
84
+ const updateData = await editor.uploadFile(file);
85
+
86
+ if (typeof updateData === "string") {
87
+ const fileBlock = {
88
+ type: fileBlockType,
89
+ props: {
90
+ name: file.name,
91
+ url: updateData,
92
+ },
93
+ } as PartialBlock<BSchema, I, S>;
94
+
95
+ insertOrUpdateBlock(editor, fileBlock);
96
+ }
97
+ }
98
+ }
99
+ }
@@ -3,13 +3,9 @@ import { Plugin } from "prosemirror-state";
3
3
 
4
4
  import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
5
5
  import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
6
+ import { handleFileInsertion } from "./handleFileInsertion";
6
7
  import { nestedListsToBlockNoteStructure } from "./html/util/nestedLists";
7
-
8
- const acceptedMIMETypes = [
9
- "blocknote/html",
10
- "text/html",
11
- "text/plain",
12
- ] as const;
8
+ import { acceptedMIMETypes } from "./acceptedMIMETypes";
13
9
 
14
10
  export const createPasteFromClipboardExtension = <
15
11
  BSchema extends BlockSchema,
@@ -33,26 +29,30 @@ export const createPasteFromClipboardExtension = <
33
29
  }
34
30
 
35
31
  let format: (typeof acceptedMIMETypes)[number] | null = null;
36
-
37
32
  for (const mimeType of acceptedMIMETypes) {
38
33
  if (event.clipboardData!.types.includes(mimeType)) {
39
34
  format = mimeType;
40
35
  break;
41
36
  }
42
37
  }
38
+ if (format === null) {
39
+ return true;
40
+ }
43
41
 
44
- if (format !== null) {
45
- let data = event.clipboardData!.getData(format);
46
- if (format === "text/html") {
47
- const htmlNode = nestedListsToBlockNoteStructure(
48
- data.trim()
49
- );
42
+ if (format === "Files") {
43
+ handleFileInsertion(event, editor);
44
+ return true;
45
+ }
50
46
 
51
- data = htmlNode.innerHTML;
52
- }
53
- editor._tiptapEditor.view.pasteHTML(data);
47
+ let data = event.clipboardData!.getData(format);
48
+
49
+ if (format === "text/html") {
50
+ const htmlNode = nestedListsToBlockNoteStructure(data.trim());
51
+ data = htmlNode.innerHTML;
54
52
  }
55
53
 
54
+ editor._tiptapEditor.view.pasteHTML(data);
55
+
56
56
  return true;
57
57
  },
58
58
  },
@@ -156,7 +156,7 @@ NESTED BLOCKS
156
156
  /* Ordered */
157
157
  .bn-block-content[data-content-type="numberedListItem"] {
158
158
  display: flex;
159
- gap: 1.2em;
159
+ gap: 0.5em;
160
160
  }
161
161
 
162
162
  [data-content-type="numberedListItem"] {
@@ -182,7 +182,7 @@ NESTED BLOCKS
182
182
  /* Unordered */
183
183
  .bn-block-content[data-content-type="bulletListItem"] {
184
184
  display: flex;
185
- gap: 1.2em;
185
+ gap: 0.5em;
186
186
  }
187
187
 
188
188
  /* Checked */
@@ -191,7 +191,8 @@ NESTED BLOCKS
191
191
  }
192
192
 
193
193
  .bn-block-content[data-content-type="checkListItem"] > div > div > input {
194
- margin: 0 1.2em 0 0;
194
+ margin: 0;
195
+ margin-inline-end: 0.5em;
195
196
  cursor: pointer;
196
197
  }
197
198
 
@@ -73,9 +73,7 @@ export type BlockNoteEditorOptions<
73
73
  ISchema extends InlineContentSchema,
74
74
  SSchema extends StyleSchema
75
75
  > = {
76
- // TODO: Figure out if enableBlockNoteExtensions/disableHistoryExtension are needed and document them.
77
- enableBlockNoteExtensions: boolean;
78
-
76
+ disableExtensions: string[];
79
77
  /**
80
78
  * A dictionary object containing translations for the editor.
81
79
  */
@@ -280,6 +278,7 @@ export class BlockNoteEditor<
280
278
  inlineContentSpecs: this.schema.inlineContentSpecs,
281
279
  collaboration: newOptions.collaboration,
282
280
  trailingBlock: newOptions.trailingBlock,
281
+ disableExtensions: newOptions.disableExtensions,
283
282
  });
284
283
 
285
284
  const blockNoteUIExtension = Extension.create({
@@ -336,10 +335,10 @@ export class BlockNoteEditor<
336
335
  ...blockNoteTipTapOptions,
337
336
  ...newOptions._tiptapOptions,
338
337
  content: initialContent,
339
- extensions:
340
- newOptions.enableBlockNoteExtensions === false
341
- ? newOptions._tiptapOptions?.extensions || []
342
- : [...(newOptions._tiptapOptions?.extensions || []), ...extensions],
338
+ extensions: [
339
+ ...(newOptions._tiptapOptions?.extensions || []),
340
+ ...extensions,
341
+ ],
343
342
  editorProps: {
344
343
  ...newOptions._tiptapOptions?.editorProps,
345
344
  attributes: {
@@ -13,6 +13,7 @@ import { Text } from "@tiptap/extension-text";
13
13
  import * as Y from "yjs";
14
14
  import { createCopyToClipboardExtension } from "../api/exporters/copyExtension";
15
15
  import { createPasteFromClipboardExtension } from "../api/parsers/pasteExtension";
16
+ import { createDropFileExtension } from "../api/parsers/fileDropExtension";
16
17
  import { BackgroundColorExtension } from "../extensions/BackgroundColor/BackgroundColorExtension";
17
18
  import { TextAlignmentExtension } from "../extensions/TextAlignment/TextAlignmentExtension";
18
19
  import { TextColorExtension } from "../extensions/TextColor/TextColorExtension";
@@ -53,6 +54,7 @@ export const getBlockNoteExtensions = <
53
54
  provider: any;
54
55
  renderCursor?: (user: any) => HTMLElement;
55
56
  };
57
+ disableExtensions: string[] | undefined;
56
58
  }) => {
57
59
  const ret: Extensions = [
58
60
  extensions.ClipboardTextSerializer,
@@ -145,6 +147,7 @@ export const getBlockNoteExtensions = <
145
147
  }),
146
148
  createCopyToClipboardExtension(opts.editor),
147
149
  createPasteFromClipboardExtension(opts.editor),
150
+ createDropFileExtension(opts.editor),
148
151
 
149
152
  Dropcursor.configure({ width: 5, color: "#ddeeff" }),
150
153
  // This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
@@ -193,5 +196,6 @@ export const getBlockNoteExtensions = <
193
196
  ret.push(History);
194
197
  }
195
198
 
196
- return ret;
199
+ const disableExtensions: string[] = opts.disableExtensions || [];
200
+ return ret.filter(ex => !disableExtensions.includes(ex.name));
197
201
  };
@@ -49,7 +49,7 @@ export class FilePanelView<I extends InlineContentSchema, S extends StyleSchema>
49
49
  // Setting capture=true ensures that any parent container of the editor that
50
50
  // gets scrolled will trigger the scroll event. Scroll events do not bubble
51
51
  // and so won't propagate to the document by default.
52
- document.addEventListener("scroll", this.scrollHandler, true);
52
+ pmView.root.addEventListener("scroll", this.scrollHandler, true);
53
53
  }
54
54
 
55
55
  mouseDownHandler = () => {
@@ -69,7 +69,7 @@ export class FilePanelView<I extends InlineContentSchema, S extends StyleSchema>
69
69
 
70
70
  scrollHandler = () => {
71
71
  if (this.state?.show) {
72
- const blockElement = document.querySelector(
72
+ const blockElement = this.pmView.root.querySelector(
73
73
  `[data-node-type="blockContainer"][data-id="${this.state.block.id}"]`
74
74
  )!;
75
75
 
@@ -84,7 +84,7 @@ export class FilePanelView<I extends InlineContentSchema, S extends StyleSchema>
84
84
  } = this.pluginKey.getState(view.state);
85
85
 
86
86
  if (!this.state?.show && pluginState.block && this.editor.isEditable) {
87
- const blockElement = document.querySelector(
87
+ const blockElement = this.pmView.root.querySelector(
88
88
  `[data-node-type="blockContainer"][data-id="${pluginState.block.id}"]`
89
89
  )!;
90
90
 
@@ -124,7 +124,7 @@ export class FilePanelView<I extends InlineContentSchema, S extends StyleSchema>
124
124
 
125
125
  this.pmView.dom.removeEventListener("dragstart", this.dragstartHandler);
126
126
 
127
- document.removeEventListener("scroll", this.scrollHandler, true);
127
+ this.pmView.root.removeEventListener("scroll", this.scrollHandler, true);
128
128
  }
129
129
  }
130
130
 
@@ -62,7 +62,7 @@ export class FormattingToolbarView implements PluginView {
62
62
  // Setting capture=true ensures that any parent container of the editor that
63
63
  // gets scrolled will trigger the scroll event. Scroll events do not bubble
64
64
  // and so won't propagate to the document by default.
65
- document.addEventListener("scroll", this.scrollHandler, true);
65
+ pmView.root.addEventListener("scroll", this.scrollHandler, true);
66
66
  }
67
67
 
68
68
  viewMousedownHandler = () => {
@@ -147,7 +147,7 @@ export class FormattingToolbarView implements PluginView {
147
147
  this.pmView.dom.removeEventListener("dragstart", this.dragHandler);
148
148
  this.pmView.dom.removeEventListener("dragover", this.dragHandler);
149
149
 
150
- document.removeEventListener("scroll", this.scrollHandler, true);
150
+ this.pmView.root.removeEventListener("scroll", this.scrollHandler, true);
151
151
  }
152
152
 
153
153
  closeMenu = () => {
@@ -61,12 +61,16 @@ class LinkToolbarView implements PluginView {
61
61
  };
62
62
 
63
63
  this.pmView.dom.addEventListener("mouseover", this.mouseOverHandler);
64
- document.addEventListener("click", this.clickHandler, true);
64
+ this.pmView.root.addEventListener(
65
+ "click",
66
+ this.clickHandler as EventListener,
67
+ true
68
+ );
65
69
 
66
70
  // Setting capture=true ensures that any parent container of the editor that
67
71
  // gets scrolled will trigger the scroll event. Scroll events do not bubble
68
72
  // and so won't propagate to the document by default.
69
- document.addEventListener("scroll", this.scrollHandler, true);
73
+ this.pmView.root.addEventListener("scroll", this.scrollHandler, true);
70
74
  }
71
75
 
72
76
  mouseOverHandler = (event: MouseEvent) => {
@@ -271,8 +275,12 @@ class LinkToolbarView implements PluginView {
271
275
 
272
276
  destroy() {
273
277
  this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler);
274
- document.removeEventListener("scroll", this.scrollHandler, true);
275
- document.removeEventListener("click", this.clickHandler, true);
278
+ this.pmView.root.removeEventListener("scroll", this.scrollHandler, true);
279
+ this.pmView.root.removeEventListener(
280
+ "click",
281
+ this.clickHandler as EventListener,
282
+ true
283
+ );
276
284
  }
277
285
  }
278
286
 
@@ -16,7 +16,12 @@ export const PlaceholderPlugin = (
16
16
  if (nonce) {
17
17
  styleEl.setAttribute("nonce", nonce);
18
18
  }
19
- document.head.appendChild(styleEl);
19
+ if (editor._tiptapEditor.view.root instanceof ShadowRoot) {
20
+ editor._tiptapEditor.view.root.append(styleEl);
21
+ } else {
22
+ editor._tiptapEditor.view.root.head.appendChild(styleEl);
23
+ }
24
+
20
25
  const styleSheet = styleEl.sheet!;
21
26
 
22
27
  const getBaseSelector = (additionalSelectors = "") =>
@@ -62,7 +67,11 @@ export const PlaceholderPlugin = (
62
67
 
63
68
  return {
64
69
  destroy: () => {
65
- document.head.removeChild(styleEl);
70
+ if (editor._tiptapEditor.view.root instanceof ShadowRoot) {
71
+ editor._tiptapEditor.view.root.removeChild(styleEl);
72
+ } else {
73
+ editor._tiptapEditor.view.root.head.removeChild(styleEl);
74
+ }
66
75
  },
67
76
  };
68
77
  },