Parcourir la source

feat: CommandLinker Support in Markdown cells

0.618 il y a 4 ans
Parent
commit
4b77ddffdf

+ 9 - 1
packages/apputils/src/sanitizer.ts

@@ -592,7 +592,15 @@ export class Sanitizer implements ISanitizer {
       bdo: ['dir'],
       blockquote: ['cite'],
       br: ['clear'],
-      button: ['accesskey', 'disabled', 'name', 'tabindex', 'type', 'value'],
+      button: [
+        'accesskey',
+        'data-commandlinker-command',
+        'disabled',
+        'name',
+        'tabindex',
+        'type',
+        'value'
+      ],
       canvas: ['height', 'width'],
       caption: ['align'],
       col: ['align', 'char', 'charoff', 'span', 'valign', 'width'],

+ 8 - 0
packages/apputils/test/sanitizer.spec.ts

@@ -37,6 +37,14 @@ describe('defaultSanitizer', () => {
       expect(defaultSanitizer.sanitize(a)).toBe(expected);
     });
 
+    it('should allow the `data-commandlinker-command` attribute for button tags', () => {
+      const button =
+        '<button data-commandlinker-command="terminal:create-new" onClick={some evil code}>Create Terminal</button>';
+      const expectedButton =
+        '<button data-commandlinker-command="terminal:create-new">Create Terminal</button>';
+      expect(defaultSanitizer.sanitize(button)).toBe(expectedButton);
+    });
+
     it('should allow the class attribute for code tags', () => {
       const code = '<code class="foo">bar</code>';
       expect(defaultSanitizer.sanitize(code)).toBe(code);