Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions resources/js/components/fieldtypes/bard/Set.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export const Set = Node.create({
addProseMirrorPlugins() {
const bard = this.options.bard;
const type = this.type;
const sliceHasSetNodes = (slice) => {
let found = false;
slice.content.forEach((node) => {
if (node.type === type) found = true;
});
return found;
};
return [
new Plugin({
key: new PluginKey('setSelectionDecorator'),
Expand Down Expand Up @@ -106,13 +113,13 @@ export const Set = Node.create({
new Plugin({
key: new PluginKey('setPastedTransformer'),
props: {
handlePaste: (view, event, slice) => {
let hasSetNodes = false;
slice.content.forEach((node) => {
if (node.type === type) hasSetNodes = true;
});
handleDrop: (view, event, slice, moved) => {
if (moved || !slice) return false;

if (!hasSetNodes) return false;
return sliceHasSetNodes(slice);
},
handlePaste: (view, event, slice) => {
if (!sliceHasSetNodes(slice)) return false;

(async () => {
const content = [];
Expand Down