Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion resources/js/components/fieldtypes/bard/Set.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Set = Node.create({
return [
{
tag: 'bard-set',
getAttrs: (dom) => JSON.parse(dom.innerHTML),
getAttrs: (dom) => JSON.parse(dom.textContent),
},
];
},
Expand Down
12 changes: 12 additions & 0 deletions resources/js/tests/components/fieldtypes/bard/Set.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { mount } from '@vue/test-utils';
import { afterEach, expect, test, vi } from 'vitest';
import * as Globals from '@/bootstrap/globals';
import Set from '@/components/fieldtypes/bard/Set.vue';
import { Set as SetNode } from '@/components/fieldtypes/bard/Set.js';
import { containerContextKey } from '@/components/ui/Publish/Container.vue';

Object.keys(Globals).forEach((fn) => (window[fn] = Globals[fn]));
Expand Down Expand Up @@ -108,3 +109,14 @@ test('clicking a custom select field does not bubble its mousedown to ProseMirro

expect(mousedown).not.toHaveBeenCalled();
});

test('pasting a copied set keeps html characters in its values', () => {
const attrs = { id: 'set-1', enabled: true, values: { type: 'my_set', code: '<b>bold</b> & co' } };

// A copied set is rendered with the JSON as text, so the clipboard html has it entity-encoded.
const [tag, , json] = SetNode.config.renderHTML({ HTMLAttributes: attrs });
const element = document.createElement(tag);
element.textContent = json;

expect(SetNode.config.parseHTML()[0].getAttrs(element)).toEqual(attrs);
});
Loading