From aed1dd811c1e8b9366749edec39d331a9f0fbc2c Mon Sep 17 00:00:00 2001 From: Jacob Peterson Date: Thu, 21 Oct 2021 11:46:00 -0400 Subject: [PATCH 1/4] =?UTF-8?q?prevents=20styling=20in=20HTML=20nodes=20fr?= =?UTF-8?q?om=20being=20displayed=20=F0=9F=92=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__snapshots__/basic-marks.test.js.snap | 77 --------- .../__snapshots__/script-marks.test.js.snap | 32 ---- .../components/marks/basic-marks.test.js | 148 ++++++++++++++++-- .../components/marks/color-marks.test.js | 46 +++++- .../components/marks/script-marks.test.js | 83 +++++++++- .../oboeditor/components/marks/basic-marks.js | 7 + .../oboeditor/components/marks/color-marks.js | 7 + .../components/marks/script-marks.js | 7 + .../components/toolbars/content-toolbar.js | 7 +- 9 files changed, 277 insertions(+), 137 deletions(-) delete mode 100644 packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/basic-marks.test.js.snap delete mode 100644 packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/script-marks.test.js.snap diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/basic-marks.test.js.snap b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/basic-marks.test.js.snap deleted file mode 100644 index 565ff6da08..0000000000 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/basic-marks.test.js.snap +++ /dev/null @@ -1,77 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`BasicMarks renderLeaf diplays expected style 1`] = ` -Object { - "children": - mockChild - , - "leaf": Object { - "b": true, - }, -} -`; - -exports[`BasicMarks renderLeaf diplays expected style 2`] = ` -Object { - "children": - mockChild - , - "leaf": Object { - "i": true, - }, -} -`; - -exports[`BasicMarks renderLeaf diplays expected style 3`] = ` -Object { - "children": - mockChild - , - "leaf": Object { - "del": true, - }, -} -`; - -exports[`BasicMarks renderLeaf diplays expected style 4`] = ` -Object { - "children": - mockChild - , - "leaf": Object { - "q": true, - }, -} -`; - -exports[`BasicMarks renderLeaf diplays expected style 5`] = ` -Object { - "children": - mockChild - , - "leaf": Object { - "monospace": true, - }, -} -`; - -exports[`BasicMarks renderLeaf diplays expected style 6`] = ` -Object { - "children":
- mockChild -
, - "leaf": Object { - "_latex": true, - }, -} -`; - -exports[`BasicMarks renderLeaf does nothing 1`] = ` -Object { - "children": "mockChild", - "leaf": Object {}, -} -`; diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/script-marks.test.js.snap b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/script-marks.test.js.snap deleted file mode 100644 index 25f0acbf2a..0000000000 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/script-marks.test.js.snap +++ /dev/null @@ -1,32 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ScriptMarks renderLeaf diplays expected style 1`] = ` -Object { - "children": - mockChild - , - "leaf": Object { - "num": 1, - "sup": true, - }, -} -`; - -exports[`ScriptMarks renderLeaf diplays expected style 2`] = ` -Object { - "children": - mockChild - , - "leaf": Object { - "num": -1, - "sup": true, - }, -} -`; - -exports[`ScriptMarks renderLeaf does nothing 1`] = ` -Object { - "children": "mockChild", - "leaf": Object {}, -} -`; diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/basic-marks.test.js b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/basic-marks.test.js index c8425b5b3a..99b9a14fdb 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/basic-marks.test.js +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/basic-marks.test.js @@ -75,57 +75,175 @@ describe('BasicMarks', () => { expect(editor.toggleMark).toHaveBeenCalledWith(LATEX_MARK) }) - test('renderLeaf diplays expected style', () => { + test('renderLeaf displays expected style', () => { expect( BasicMarks.plugins.renderLeaf({ leaf: { b: true }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": + Object { + "props": "mockChildProps", + } + , + "leaf": Object { + "b": true, + }, + } + `) expect( BasicMarks.plugins.renderLeaf({ leaf: { i: true }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": + Object { + "props": "mockChildProps", + } + , + "leaf": Object { + "i": true, + }, + } + `) expect( BasicMarks.plugins.renderLeaf({ leaf: { del: true }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": + Object { + "props": "mockChildProps", + } + , + "leaf": Object { + "del": true, + }, + } + `) expect( BasicMarks.plugins.renderLeaf({ leaf: { q: true }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": + Object { + "props": "mockChildProps", + } + , + "leaf": Object { + "q": true, + }, + } + `) expect( BasicMarks.plugins.renderLeaf({ leaf: { monospace: true }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": + Object { + "props": "mockChildProps", + } + , + "leaf": Object { + "monospace": true, + }, + } + `) expect( BasicMarks.plugins.renderLeaf({ leaf: { _latex: true }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children":
+ Object { + "props": "mockChildProps", + } +
, + "leaf": Object { + "_latex": true, + }, + } + `) }) test('renderLeaf does nothing', () => { expect( BasicMarks.plugins.renderLeaf({ leaf: {}, - children: 'mockChild' + children: { + props: 'mockChildProps' + } + }) + ).toMatchInlineSnapshot(` + Object { + "children": Object { + "props": "mockChildProps", + }, + "leaf": Object {}, + } + `) + }) + + test('renderLeaf does not style HTML nodes', () => { + expect( + BasicMarks.plugins.renderLeaf({ + leaf: { b: true }, + children: { + props: { + parent: { + type: 'ObojoboDraft.Chunks.HTML' + } + } + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": Object { + "props": Object { + "parent": Object { + "type": "ObojoboDraft.Chunks.HTML", + }, + }, + }, + "leaf": Object { + "b": true, + }, + } + `) }) test('toggleMarks removes links', () => { diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/color-marks.test.js b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/color-marks.test.js index 5b9ed1e81e..a5a9b1a99c 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/color-marks.test.js +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/color-marks.test.js @@ -8,11 +8,13 @@ describe('ColorMark', () => { Dispatcher.trigger.mockRestore() }) - test('renderLeaf diplays expected style', () => { + test('renderLeaf displays expected style', () => { expect( ColorMark.plugins.renderLeaf({ leaf: { color: '#000000' }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) ).toMatchInlineSnapshot(` Object { @@ -23,7 +25,9 @@ describe('ColorMark', () => { } } > - mockChild + Object { + "props": "mockChildProps", + } , "leaf": Object { "color": "#000000", @@ -36,16 +40,48 @@ describe('ColorMark', () => { expect( ColorMark.plugins.renderLeaf({ leaf: {}, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) ).toMatchInlineSnapshot(` Object { - "children": "mockChild", + "children": Object { + "props": "mockChildProps", + }, "leaf": Object {}, } `) }) + test('renderLeaf does not style HTML nodes', () => { + expect( + ColorMark.plugins.renderLeaf({ + leaf: { color: '#000000' }, + children: { + props: { + parent: { + type: 'ObojoboDraft.Chunks.HTML' + } + } + } + }) + ).toMatchInlineSnapshot(` + Object { + "children": Object { + "props": Object { + "parent": Object { + "type": "ObojoboDraft.Chunks.HTML", + }, + }, + }, + "leaf": Object { + "color": "#000000", + }, + } + `) + }) + test('color action', () => { ColorMark.marks[0].action() expect(Dispatcher.trigger).toHaveBeenCalled() diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/script-marks.test.js b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/script-marks.test.js index 7000de2a64..f9f484161d 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/script-marks.test.js +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/script-marks.test.js @@ -52,16 +52,30 @@ describe('ScriptMarks', () => { expect(editor.toggleScript).toHaveBeenCalledWith(1) }) - test('renderLeaf diplays expected style', () => { + test('renderLeaf displays expected style', () => { expect( ScriptMarks.plugins.renderLeaf({ leaf: { sup: true, num: 1 }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": + Object { + "props": "mockChildProps", + } + , + "leaf": Object { + "num": 1, + "sup": true, + }, + } + `) expect( ScriptMarks.plugins.renderLeaf({ @@ -69,18 +83,73 @@ describe('ScriptMarks', () => { sup: true, num: -1 }, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": + Object { + "props": "mockChildProps", + } + , + "leaf": Object { + "num": -1, + "sup": true, + }, + } + `) }) test('renderLeaf does nothing', () => { expect( ScriptMarks.plugins.renderLeaf({ leaf: {}, - children: 'mockChild' + children: { + props: 'mockChildProps' + } }) - ).toMatchSnapshot() + ).toMatchInlineSnapshot(` + Object { + "children": Object { + "props": "mockChildProps", + }, + "leaf": Object {}, + } + `) + }) + + test('renderLeaf does not style HTML nodes', () => { + expect( + ScriptMarks.plugins.renderLeaf({ + leaf: { + sup: true, + num: 1 + }, + children: { + props: { + parent: { + type: 'ObojoboDraft.Chunks.HTML' + } + } + } + }) + ).toMatchInlineSnapshot(` + Object { + "children": Object { + "props": Object { + "parent": Object { + "type": "ObojoboDraft.Chunks.HTML", + }, + }, + }, + "leaf": Object { + "num": 1, + "sup": true, + }, + } + `) }) test('toggleScript removes marks', () => { diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/basic-marks.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/basic-marks.js index 05a0135b50..3fe3afde8e 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/basic-marks.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/basic-marks.js @@ -16,6 +16,8 @@ const QUOTE_MARK = 'q' const MONOSPACE_MARK = 'monospace' const LATEX_MARK = '_latex' +const HTML_NODE = 'ObojoboDraft.Chunks.HTML' + const BasicMarks = { plugins: { onKeyDown(event, editor, next) { @@ -46,6 +48,11 @@ const BasicMarks = { renderLeaf(props) { let { children } = props const { leaf } = props + const { parent } = children.props + + if (parent && parent.type === HTML_NODE) { + return props + } if (leaf[LATEX_MARK]) { children = ( diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/color-marks.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/color-marks.js index eba96fc12c..dffe4da395 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/color-marks.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/color-marks.js @@ -5,6 +5,8 @@ import Dispatcher from '../../../common/flux/dispatcher' const COLOR_MARK = 'color' +const HTML_NODE = 'ObojoboDraft.Chunks.HTML' + const ColorMark = { plugins: { onKeyDown(event) { @@ -16,6 +18,11 @@ const ColorMark = { renderLeaf(props) { let { children } = props const { leaf } = props + const { parent } = children.props + + if (parent && parent.type === HTML_NODE) { + return props + } if (leaf[COLOR_MARK]) children = {children} diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/script-marks.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/script-marks.js index 3be21bdae5..6d394e2656 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/script-marks.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/script-marks.js @@ -7,6 +7,8 @@ import SubIcon from '../../assets/sub-icon' const SCRIPT_MARK = 'sup' +const HTML_NODE = 'ObojoboDraft.Chunks.HTML' + const ScriptMark = { plugins: { onKeyDown(event, editor, next) { @@ -25,6 +27,11 @@ const ScriptMark = { renderLeaf(props) { let { children } = props const { leaf } = props + const { parent } = children.props + + if (parent && parent.type === HTML_NODE) { + return props + } if (leaf[SCRIPT_MARK] && leaf.num > 0) children = {props.children} if (leaf[SCRIPT_MARK] && leaf.num < 0) children = {props.children} diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/toolbars/content-toolbar.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/toolbars/content-toolbar.js index a4c7679aa6..8f6351e88a 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/toolbars/content-toolbar.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/toolbars/content-toolbar.js @@ -35,6 +35,8 @@ const orderedList = [ { bulletStyle: 'upper-roman', display: 'I.' } ] +const HTML_NODE = 'ObojoboDraft.Chunks.HTML' + const getIsSelected = (marks, mark) => { if (!mark || !marks || mark.type === 'color' || !marks[mark.type]) { return false @@ -55,6 +57,9 @@ const getIsSelected = (marks, mark) => { const ContentToolbar = props => { const marks = Editor.marks(props.editor) const isMac = navigator.platform.indexOf('Mac') !== -1 + const nodeType = props.editor.selection + ? Editor.parent(props.editor, props.editor.selection.anchor)[0].type + : '' return (
@@ -66,7 +71,7 @@ const ContentToolbar = props => { // for keyboard shortcuts const hotKey = isMac ? '⌘+' : 'Ctrl+' const shortcut = mark.shortcut ? '\n' + hotKey + mark.shortcut : '' - const isSelected = getIsSelected(marks, mark) + const isSelected = getIsSelected(marks, mark) && nodeType !== HTML_NODE const Icon = mark.icon return ( From 678efb93b261a030ac9afab897d1922730f15dfa Mon Sep 17 00:00:00 2001 From: Deundre Williams Date: Mon, 29 Aug 2022 10:32:05 -0400 Subject: [PATCH 2/4] disable buttons --- .../__snapshots__/visual-editor.test.js.snap | 80 ++++++++++ .../__snapshots__/basic-marks.test.js.snap | 77 +++++++++ .../__snapshots__/script-marks.test.js.snap | 32 ++++ .../components/marks/basic-marks.test.js | 148 ++---------------- .../components/marks/color-marks.test.js | 46 +----- .../components/marks/script-marks.test.js | 83 +--------- .../toolbars/content-toolbar.test.js | 25 +++ .../oboeditor/components/marks/basic-marks.js | 7 - .../oboeditor/components/marks/color-marks.js | 7 - .../components/marks/script-marks.js | 7 - .../components/toolbars/content-toolbar.js | 4 +- 11 files changed, 244 insertions(+), 272 deletions(-) create mode 100644 packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/basic-marks.test.js.snap create mode 100644 packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/script-marks.test.js.snap diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/__snapshots__/visual-editor.test.js.snap b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/__snapshots__/visual-editor.test.js.snap index 8d774d8e8b..b31f2bd440 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/__snapshots__/visual-editor.test.js.snap +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/__snapshots__/visual-editor.test.js.snap @@ -550,6 +550,7 @@ exports[`VisualEditor VisualEditor component 1`] = ` aria-label="Bold Ctrl+B" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Bold Ctrl+B" @@ -568,6 +569,7 @@ Ctrl+B" aria-label="Italic Ctrl+I" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Italic Ctrl+I" @@ -586,6 +588,7 @@ Ctrl+I" aria-label="Strikethrough Ctrl+D" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Strikethrough Ctrl+D" @@ -616,6 +619,7 @@ Ctrl+D" aria-label="Quote Ctrl+\\"" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Quote Ctrl+\\"" @@ -640,6 +644,7 @@ Ctrl+\\"" aria-label="Monospace Ctrl+M" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Monospace Ctrl+M" @@ -667,6 +672,7 @@ Ctrl+M" aria-label="Equation Ctrl+/" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Equation Ctrl+/" @@ -697,6 +703,7 @@ Ctrl+/" aria-label="Color Ctrl+Shift+P" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Color Ctrl+Shift+P" @@ -720,6 +727,7 @@ Ctrl+Shift+P" aria-label="Link Ctrl+K" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Link Ctrl+K" @@ -742,6 +750,7 @@ Ctrl+K" aria-label="Superscript Ctrl+." className=" is-not-selected" + disabled={false} onClick={[Function]} title="Superscript Ctrl+." @@ -764,6 +773,7 @@ Ctrl+." aria-label="Subscript Ctrl+," className=" is-not-selected" + disabled={false} onClick={[Function]} title="Subscript Ctrl+," @@ -786,6 +796,7 @@ Ctrl+," aria-label="Left Align Ctrl+Shift+L" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Left Align Ctrl+Shift+L" @@ -804,6 +815,7 @@ Ctrl+Shift+L" aria-label="Center Align Ctrl+Shift+E" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Center Align Ctrl+Shift+E" @@ -822,6 +834,7 @@ Ctrl+Shift+E" aria-label="Right Align Ctrl+Shift+R" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Right Align Ctrl+Shift+R" @@ -857,6 +870,7 @@ Ctrl+Shift+J" aria-label="Indent Ctrl+Alt+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Indent Ctrl+Alt+Tab" @@ -879,6 +893,7 @@ Ctrl+Alt+Tab" aria-label="Unindent Ctrl+Shift+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Unindent Ctrl+Shift+Tab" @@ -901,6 +916,7 @@ Ctrl+Shift+Tab" aria-label="Hanging Indent Ctrl+H" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Hanging Indent Ctrl+H" @@ -1193,6 +1209,7 @@ exports[`VisualEditor VisualEditor component changes pages 1`] = ` aria-label="Bold Ctrl+B" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Bold Ctrl+B" @@ -1211,6 +1228,7 @@ Ctrl+B" aria-label="Italic Ctrl+I" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Italic Ctrl+I" @@ -1229,6 +1247,7 @@ Ctrl+I" aria-label="Strikethrough Ctrl+D" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Strikethrough Ctrl+D" @@ -1259,6 +1278,7 @@ Ctrl+D" aria-label="Quote Ctrl+\\"" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Quote Ctrl+\\"" @@ -1283,6 +1303,7 @@ Ctrl+\\"" aria-label="Monospace Ctrl+M" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Monospace Ctrl+M" @@ -1310,6 +1331,7 @@ Ctrl+M" aria-label="Equation Ctrl+/" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Equation Ctrl+/" @@ -1340,6 +1362,7 @@ Ctrl+/" aria-label="Color Ctrl+Shift+P" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Color Ctrl+Shift+P" @@ -1363,6 +1386,7 @@ Ctrl+Shift+P" aria-label="Link Ctrl+K" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Link Ctrl+K" @@ -1385,6 +1409,7 @@ Ctrl+K" aria-label="Superscript Ctrl+." className=" is-not-selected" + disabled={false} onClick={[Function]} title="Superscript Ctrl+." @@ -1407,6 +1432,7 @@ Ctrl+." aria-label="Subscript Ctrl+," className=" is-not-selected" + disabled={false} onClick={[Function]} title="Subscript Ctrl+," @@ -1429,6 +1455,7 @@ Ctrl+," aria-label="Left Align Ctrl+Shift+L" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Left Align Ctrl+Shift+L" @@ -1447,6 +1474,7 @@ Ctrl+Shift+L" aria-label="Center Align Ctrl+Shift+E" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Center Align Ctrl+Shift+E" @@ -1465,6 +1493,7 @@ Ctrl+Shift+E" aria-label="Right Align Ctrl+Shift+R" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Right Align Ctrl+Shift+R" @@ -1500,6 +1529,7 @@ Ctrl+Shift+J" aria-label="Indent Ctrl+Alt+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Indent Ctrl+Alt+Tab" @@ -1522,6 +1552,7 @@ Ctrl+Alt+Tab" aria-label="Unindent Ctrl+Shift+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Unindent Ctrl+Shift+Tab" @@ -1544,6 +1575,7 @@ Ctrl+Shift+Tab" aria-label="Hanging Indent Ctrl+H" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Hanging Indent Ctrl+H" @@ -1836,6 +1868,7 @@ exports[`VisualEditor VisualEditor component changes pages 2`] = ` aria-label="Bold Ctrl+B" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Bold Ctrl+B" @@ -1854,6 +1887,7 @@ Ctrl+B" aria-label="Italic Ctrl+I" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Italic Ctrl+I" @@ -1872,6 +1906,7 @@ Ctrl+I" aria-label="Strikethrough Ctrl+D" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Strikethrough Ctrl+D" @@ -1902,6 +1937,7 @@ Ctrl+D" aria-label="Quote Ctrl+\\"" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Quote Ctrl+\\"" @@ -1926,6 +1962,7 @@ Ctrl+\\"" aria-label="Monospace Ctrl+M" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Monospace Ctrl+M" @@ -1953,6 +1990,7 @@ Ctrl+M" aria-label="Equation Ctrl+/" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Equation Ctrl+/" @@ -1983,6 +2021,7 @@ Ctrl+/" aria-label="Color Ctrl+Shift+P" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Color Ctrl+Shift+P" @@ -2006,6 +2045,7 @@ Ctrl+Shift+P" aria-label="Link Ctrl+K" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Link Ctrl+K" @@ -2028,6 +2068,7 @@ Ctrl+K" aria-label="Superscript Ctrl+." className=" is-not-selected" + disabled={false} onClick={[Function]} title="Superscript Ctrl+." @@ -2050,6 +2091,7 @@ Ctrl+." aria-label="Subscript Ctrl+," className=" is-not-selected" + disabled={false} onClick={[Function]} title="Subscript Ctrl+," @@ -2072,6 +2114,7 @@ Ctrl+," aria-label="Left Align Ctrl+Shift+L" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Left Align Ctrl+Shift+L" @@ -2090,6 +2133,7 @@ Ctrl+Shift+L" aria-label="Center Align Ctrl+Shift+E" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Center Align Ctrl+Shift+E" @@ -2108,6 +2152,7 @@ Ctrl+Shift+E" aria-label="Right Align Ctrl+Shift+R" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Right Align Ctrl+Shift+R" @@ -2143,6 +2188,7 @@ Ctrl+Shift+J" aria-label="Indent Ctrl+Alt+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Indent Ctrl+Alt+Tab" @@ -2165,6 +2211,7 @@ Ctrl+Alt+Tab" aria-label="Unindent Ctrl+Shift+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Unindent Ctrl+Shift+Tab" @@ -2187,6 +2234,7 @@ Ctrl+Shift+Tab" aria-label="Hanging Indent Ctrl+H" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Hanging Indent Ctrl+H" @@ -2525,6 +2573,7 @@ exports[`VisualEditor VisualEditor component with no page 1`] = ` aria-label="Bold Ctrl+B" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Bold Ctrl+B" @@ -2543,6 +2592,7 @@ Ctrl+B" aria-label="Italic Ctrl+I" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Italic Ctrl+I" @@ -2561,6 +2611,7 @@ Ctrl+I" aria-label="Strikethrough Ctrl+D" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Strikethrough Ctrl+D" @@ -2591,6 +2642,7 @@ Ctrl+D" aria-label="Quote Ctrl+\\"" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Quote Ctrl+\\"" @@ -2615,6 +2667,7 @@ Ctrl+\\"" aria-label="Monospace Ctrl+M" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Monospace Ctrl+M" @@ -2642,6 +2695,7 @@ Ctrl+M" aria-label="Equation Ctrl+/" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Equation Ctrl+/" @@ -2672,6 +2726,7 @@ Ctrl+/" aria-label="Color Ctrl+Shift+P" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Color Ctrl+Shift+P" @@ -2695,6 +2750,7 @@ Ctrl+Shift+P" aria-label="Link Ctrl+K" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Link Ctrl+K" @@ -2717,6 +2773,7 @@ Ctrl+K" aria-label="Superscript Ctrl+." className=" is-not-selected" + disabled={false} onClick={[Function]} title="Superscript Ctrl+." @@ -2739,6 +2796,7 @@ Ctrl+." aria-label="Subscript Ctrl+," className=" is-not-selected" + disabled={false} onClick={[Function]} title="Subscript Ctrl+," @@ -2761,6 +2819,7 @@ Ctrl+," aria-label="Left Align Ctrl+Shift+L" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Left Align Ctrl+Shift+L" @@ -2779,6 +2838,7 @@ Ctrl+Shift+L" aria-label="Center Align Ctrl+Shift+E" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Center Align Ctrl+Shift+E" @@ -2797,6 +2857,7 @@ Ctrl+Shift+E" aria-label="Right Align Ctrl+Shift+R" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Right Align Ctrl+Shift+R" @@ -2832,6 +2893,7 @@ Ctrl+Shift+J" aria-label="Indent Ctrl+Alt+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Indent Ctrl+Alt+Tab" @@ -2854,6 +2916,7 @@ Ctrl+Alt+Tab" aria-label="Unindent Ctrl+Shift+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Unindent Ctrl+Shift+Tab" @@ -2876,6 +2939,7 @@ Ctrl+Shift+Tab" aria-label="Hanging Indent Ctrl+H" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Hanging Indent Ctrl+H" @@ -3164,6 +3228,7 @@ exports[`VisualEditor reload disables event listener and calls location.reload 1 aria-label="Bold Ctrl+B" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Bold Ctrl+B" @@ -3182,6 +3247,7 @@ Ctrl+B" aria-label="Italic Ctrl+I" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Italic Ctrl+I" @@ -3200,6 +3266,7 @@ Ctrl+I" aria-label="Strikethrough Ctrl+D" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Strikethrough Ctrl+D" @@ -3230,6 +3297,7 @@ Ctrl+D" aria-label="Quote Ctrl+\\"" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Quote Ctrl+\\"" @@ -3254,6 +3322,7 @@ Ctrl+\\"" aria-label="Monospace Ctrl+M" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Monospace Ctrl+M" @@ -3281,6 +3350,7 @@ Ctrl+M" aria-label="Equation Ctrl+/" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Equation Ctrl+/" @@ -3311,6 +3381,7 @@ Ctrl+/" aria-label="Color Ctrl+Shift+P" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Color Ctrl+Shift+P" @@ -3334,6 +3405,7 @@ Ctrl+Shift+P" aria-label="Link Ctrl+K" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Link Ctrl+K" @@ -3356,6 +3428,7 @@ Ctrl+K" aria-label="Superscript Ctrl+." className=" is-not-selected" + disabled={false} onClick={[Function]} title="Superscript Ctrl+." @@ -3378,6 +3451,7 @@ Ctrl+." aria-label="Subscript Ctrl+," className=" is-not-selected" + disabled={false} onClick={[Function]} title="Subscript Ctrl+," @@ -3400,6 +3474,7 @@ Ctrl+," aria-label="Left Align Ctrl+Shift+L" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Left Align Ctrl+Shift+L" @@ -3418,6 +3493,7 @@ Ctrl+Shift+L" aria-label="Center Align Ctrl+Shift+E" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Center Align Ctrl+Shift+E" @@ -3436,6 +3512,7 @@ Ctrl+Shift+E" aria-label="Right Align Ctrl+Shift+R" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Right Align Ctrl+Shift+R" @@ -3471,6 +3548,7 @@ Ctrl+Shift+J" aria-label="Indent Ctrl+Alt+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Indent Ctrl+Alt+Tab" @@ -3493,6 +3571,7 @@ Ctrl+Alt+Tab" aria-label="Unindent Ctrl+Shift+Tab" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Unindent Ctrl+Shift+Tab" @@ -3515,6 +3594,7 @@ Ctrl+Shift+Tab" aria-label="Hanging Indent Ctrl+H" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Hanging Indent Ctrl+H" diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/basic-marks.test.js.snap b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/basic-marks.test.js.snap new file mode 100644 index 0000000000..565ff6da08 --- /dev/null +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/basic-marks.test.js.snap @@ -0,0 +1,77 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`BasicMarks renderLeaf diplays expected style 1`] = ` +Object { + "children": + mockChild + , + "leaf": Object { + "b": true, + }, +} +`; + +exports[`BasicMarks renderLeaf diplays expected style 2`] = ` +Object { + "children": + mockChild + , + "leaf": Object { + "i": true, + }, +} +`; + +exports[`BasicMarks renderLeaf diplays expected style 3`] = ` +Object { + "children": + mockChild + , + "leaf": Object { + "del": true, + }, +} +`; + +exports[`BasicMarks renderLeaf diplays expected style 4`] = ` +Object { + "children": + mockChild + , + "leaf": Object { + "q": true, + }, +} +`; + +exports[`BasicMarks renderLeaf diplays expected style 5`] = ` +Object { + "children": + mockChild + , + "leaf": Object { + "monospace": true, + }, +} +`; + +exports[`BasicMarks renderLeaf diplays expected style 6`] = ` +Object { + "children":
+ mockChild +
, + "leaf": Object { + "_latex": true, + }, +} +`; + +exports[`BasicMarks renderLeaf does nothing 1`] = ` +Object { + "children": "mockChild", + "leaf": Object {}, +} +`; diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/script-marks.test.js.snap b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/script-marks.test.js.snap new file mode 100644 index 0000000000..25f0acbf2a --- /dev/null +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/__snapshots__/script-marks.test.js.snap @@ -0,0 +1,32 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ScriptMarks renderLeaf diplays expected style 1`] = ` +Object { + "children": + mockChild + , + "leaf": Object { + "num": 1, + "sup": true, + }, +} +`; + +exports[`ScriptMarks renderLeaf diplays expected style 2`] = ` +Object { + "children": + mockChild + , + "leaf": Object { + "num": -1, + "sup": true, + }, +} +`; + +exports[`ScriptMarks renderLeaf does nothing 1`] = ` +Object { + "children": "mockChild", + "leaf": Object {}, +} +`; diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/basic-marks.test.js b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/basic-marks.test.js index 99b9a14fdb..c8425b5b3a 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/basic-marks.test.js +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/basic-marks.test.js @@ -75,175 +75,57 @@ describe('BasicMarks', () => { expect(editor.toggleMark).toHaveBeenCalledWith(LATEX_MARK) }) - test('renderLeaf displays expected style', () => { + test('renderLeaf diplays expected style', () => { expect( BasicMarks.plugins.renderLeaf({ leaf: { b: true }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": - Object { - "props": "mockChildProps", - } - , - "leaf": Object { - "b": true, - }, - } - `) + ).toMatchSnapshot() expect( BasicMarks.plugins.renderLeaf({ leaf: { i: true }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": - Object { - "props": "mockChildProps", - } - , - "leaf": Object { - "i": true, - }, - } - `) + ).toMatchSnapshot() expect( BasicMarks.plugins.renderLeaf({ leaf: { del: true }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": - Object { - "props": "mockChildProps", - } - , - "leaf": Object { - "del": true, - }, - } - `) + ).toMatchSnapshot() expect( BasicMarks.plugins.renderLeaf({ leaf: { q: true }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": - Object { - "props": "mockChildProps", - } - , - "leaf": Object { - "q": true, - }, - } - `) + ).toMatchSnapshot() expect( BasicMarks.plugins.renderLeaf({ leaf: { monospace: true }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": - Object { - "props": "mockChildProps", - } - , - "leaf": Object { - "monospace": true, - }, - } - `) + ).toMatchSnapshot() expect( BasicMarks.plugins.renderLeaf({ leaf: { _latex: true }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children":
- Object { - "props": "mockChildProps", - } -
, - "leaf": Object { - "_latex": true, - }, - } - `) + ).toMatchSnapshot() }) test('renderLeaf does nothing', () => { expect( BasicMarks.plugins.renderLeaf({ leaf: {}, - children: { - props: 'mockChildProps' - } - }) - ).toMatchInlineSnapshot(` - Object { - "children": Object { - "props": "mockChildProps", - }, - "leaf": Object {}, - } - `) - }) - - test('renderLeaf does not style HTML nodes', () => { - expect( - BasicMarks.plugins.renderLeaf({ - leaf: { b: true }, - children: { - props: { - parent: { - type: 'ObojoboDraft.Chunks.HTML' - } - } - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": Object { - "props": Object { - "parent": Object { - "type": "ObojoboDraft.Chunks.HTML", - }, - }, - }, - "leaf": Object { - "b": true, - }, - } - `) + ).toMatchSnapshot() }) test('toggleMarks removes links', () => { diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/color-marks.test.js b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/color-marks.test.js index a5a9b1a99c..5b9ed1e81e 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/color-marks.test.js +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/color-marks.test.js @@ -8,13 +8,11 @@ describe('ColorMark', () => { Dispatcher.trigger.mockRestore() }) - test('renderLeaf displays expected style', () => { + test('renderLeaf diplays expected style', () => { expect( ColorMark.plugins.renderLeaf({ leaf: { color: '#000000' }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) ).toMatchInlineSnapshot(` Object { @@ -25,9 +23,7 @@ describe('ColorMark', () => { } } > - Object { - "props": "mockChildProps", - } + mockChild , "leaf": Object { "color": "#000000", @@ -40,48 +36,16 @@ describe('ColorMark', () => { expect( ColorMark.plugins.renderLeaf({ leaf: {}, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) ).toMatchInlineSnapshot(` Object { - "children": Object { - "props": "mockChildProps", - }, + "children": "mockChild", "leaf": Object {}, } `) }) - test('renderLeaf does not style HTML nodes', () => { - expect( - ColorMark.plugins.renderLeaf({ - leaf: { color: '#000000' }, - children: { - props: { - parent: { - type: 'ObojoboDraft.Chunks.HTML' - } - } - } - }) - ).toMatchInlineSnapshot(` - Object { - "children": Object { - "props": Object { - "parent": Object { - "type": "ObojoboDraft.Chunks.HTML", - }, - }, - }, - "leaf": Object { - "color": "#000000", - }, - } - `) - }) - test('color action', () => { ColorMark.marks[0].action() expect(Dispatcher.trigger).toHaveBeenCalled() diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/script-marks.test.js b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/script-marks.test.js index f9f484161d..7000de2a64 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/script-marks.test.js +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/marks/script-marks.test.js @@ -52,30 +52,16 @@ describe('ScriptMarks', () => { expect(editor.toggleScript).toHaveBeenCalledWith(1) }) - test('renderLeaf displays expected style', () => { + test('renderLeaf diplays expected style', () => { expect( ScriptMarks.plugins.renderLeaf({ leaf: { sup: true, num: 1 }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": - Object { - "props": "mockChildProps", - } - , - "leaf": Object { - "num": 1, - "sup": true, - }, - } - `) + ).toMatchSnapshot() expect( ScriptMarks.plugins.renderLeaf({ @@ -83,73 +69,18 @@ describe('ScriptMarks', () => { sup: true, num: -1 }, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": - Object { - "props": "mockChildProps", - } - , - "leaf": Object { - "num": -1, - "sup": true, - }, - } - `) + ).toMatchSnapshot() }) test('renderLeaf does nothing', () => { expect( ScriptMarks.plugins.renderLeaf({ leaf: {}, - children: { - props: 'mockChildProps' - } + children: 'mockChild' }) - ).toMatchInlineSnapshot(` - Object { - "children": Object { - "props": "mockChildProps", - }, - "leaf": Object {}, - } - `) - }) - - test('renderLeaf does not style HTML nodes', () => { - expect( - ScriptMarks.plugins.renderLeaf({ - leaf: { - sup: true, - num: 1 - }, - children: { - props: { - parent: { - type: 'ObojoboDraft.Chunks.HTML' - } - } - } - }) - ).toMatchInlineSnapshot(` - Object { - "children": Object { - "props": Object { - "parent": Object { - "type": "ObojoboDraft.Chunks.HTML", - }, - }, - }, - "leaf": Object { - "num": 1, - "sup": true, - }, - } - `) + ).toMatchSnapshot() }) test('toggleScript removes marks', () => { diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/toolbars/content-toolbar.test.js b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/toolbars/content-toolbar.test.js index 1ca462a6fa..ba190c2430 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/toolbars/content-toolbar.test.js +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/toolbars/content-toolbar.test.js @@ -5,6 +5,7 @@ import React from 'react' import ContentToolbar from '../../../../src/scripts/oboeditor/components/toolbars/content-toolbar' const TEXT_NODE = 'ObojoboDraft.Chunks.Text' +const HTML_NODE = 'ObojoboDraft.Chunks.HTML' // In order to test the case where no shortcut exists we remove the shortcut from one of the marks // in order to hit that line of code @@ -56,6 +57,30 @@ describe('Content Toolbar', () => { expect(tree).toMatchSnapshot() }) + test('Toolbar node buttons are disabled if HTML chunk is selected', () => { + const editor = { + children: [ + { + type: HTML_NODE, + children: [{ text: 'mockText' }] + } + ], + selection: { + anchor: { path: [0, 0], offset: 1 }, + focus: { path: [0, 0], offset: 1 } + }, + isInline: () => false, + isVoid: () => false + } + + const component = shallow() + + const buttons = component.find('button') + + // Check that every button is disabled + buttons.forEach(e => expect(e.props().disabled === false)) + }) + test('Toolbar node calls the action for a button', () => { const editor = { children: [ diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/basic-marks.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/basic-marks.js index 3fe3afde8e..05a0135b50 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/basic-marks.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/basic-marks.js @@ -16,8 +16,6 @@ const QUOTE_MARK = 'q' const MONOSPACE_MARK = 'monospace' const LATEX_MARK = '_latex' -const HTML_NODE = 'ObojoboDraft.Chunks.HTML' - const BasicMarks = { plugins: { onKeyDown(event, editor, next) { @@ -48,11 +46,6 @@ const BasicMarks = { renderLeaf(props) { let { children } = props const { leaf } = props - const { parent } = children.props - - if (parent && parent.type === HTML_NODE) { - return props - } if (leaf[LATEX_MARK]) { children = ( diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/color-marks.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/color-marks.js index dffe4da395..eba96fc12c 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/color-marks.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/color-marks.js @@ -5,8 +5,6 @@ import Dispatcher from '../../../common/flux/dispatcher' const COLOR_MARK = 'color' -const HTML_NODE = 'ObojoboDraft.Chunks.HTML' - const ColorMark = { plugins: { onKeyDown(event) { @@ -18,11 +16,6 @@ const ColorMark = { renderLeaf(props) { let { children } = props const { leaf } = props - const { parent } = children.props - - if (parent && parent.type === HTML_NODE) { - return props - } if (leaf[COLOR_MARK]) children = {children} diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/script-marks.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/script-marks.js index 6d394e2656..3be21bdae5 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/script-marks.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/marks/script-marks.js @@ -7,8 +7,6 @@ import SubIcon from '../../assets/sub-icon' const SCRIPT_MARK = 'sup' -const HTML_NODE = 'ObojoboDraft.Chunks.HTML' - const ScriptMark = { plugins: { onKeyDown(event, editor, next) { @@ -27,11 +25,6 @@ const ScriptMark = { renderLeaf(props) { let { children } = props const { leaf } = props - const { parent } = children.props - - if (parent && parent.type === HTML_NODE) { - return props - } if (leaf[SCRIPT_MARK] && leaf.num > 0) children = {props.children} if (leaf[SCRIPT_MARK] && leaf.num < 0) children = {props.children} diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/toolbars/content-toolbar.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/toolbars/content-toolbar.js index 8f6351e88a..263fc53b1a 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/toolbars/content-toolbar.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/toolbars/content-toolbar.js @@ -71,7 +71,8 @@ const ContentToolbar = props => { // for keyboard shortcuts const hotKey = isMac ? '⌘+' : 'Ctrl+' const shortcut = mark.shortcut ? '\n' + hotKey + mark.shortcut : '' - const isSelected = getIsSelected(marks, mark) && nodeType !== HTML_NODE + const isSelected = getIsSelected(marks, mark) + const allowStyleChanges = nodeType !== HTML_NODE const Icon = mark.icon return ( @@ -81,6 +82,7 @@ const ContentToolbar = props => { onClick={() => mark.action(props.editor)} title={mark.name + shortcut} aria-label={mark.name + shortcut} + disabled={!allowStyleChanges} > From 5a87a43bf1e718a16e526625fe84e1e4d79afeea Mon Sep 17 00:00:00 2001 From: Deundre Williams Date: Tue, 30 Aug 2022 09:00:16 -0400 Subject: [PATCH 3/4] fix disabled prop test --- .../components/toolbars/content-toolbar.test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/toolbars/content-toolbar.test.js b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/toolbars/content-toolbar.test.js index ba190c2430..cc8ac01717 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/toolbars/content-toolbar.test.js +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/toolbars/content-toolbar.test.js @@ -75,10 +75,13 @@ describe('Content Toolbar', () => { const component = shallow() - const buttons = component.find('button') + const allButtons = component.find('button') - // Check that every button is disabled - buttons.forEach(e => expect(e.props().disabled === false)) + expect(allButtons.length).toBeGreaterThan(0) + + for (let i = 0; i < allButtons.length; i++) { + expect(allButtons.at(i).props()['disabled']).toBeTruthy() + } }) test('Toolbar node calls the action for a button', () => { From 5e8e3e3e60d783fd35f8e524f599f0fc0edad6fe Mon Sep 17 00:00:00 2001 From: Deundre Williams Date: Tue, 30 Aug 2022 10:39:10 -0400 Subject: [PATCH 4/4] add justify --- .../components/__snapshots__/visual-editor.test.js.snap | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/__snapshots__/visual-editor.test.js.snap b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/__snapshots__/visual-editor.test.js.snap index b31f2bd440..15ac5e8c26 100644 --- a/packages/app/obojobo-document-engine/__tests__/oboeditor/components/__snapshots__/visual-editor.test.js.snap +++ b/packages/app/obojobo-document-engine/__tests__/oboeditor/components/__snapshots__/visual-editor.test.js.snap @@ -853,6 +853,7 @@ Ctrl+Shift+R" aria-label="Justify Ctrl+Shift+J" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Justify Ctrl+Shift+J" @@ -1512,6 +1513,7 @@ Ctrl+Shift+R" aria-label="Justify Ctrl+Shift+J" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Justify Ctrl+Shift+J" @@ -2171,6 +2173,7 @@ Ctrl+Shift+R" aria-label="Justify Ctrl+Shift+J" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Justify Ctrl+Shift+J" @@ -2876,6 +2879,7 @@ Ctrl+Shift+R" aria-label="Justify Ctrl+Shift+J" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Justify Ctrl+Shift+J" @@ -3531,6 +3535,7 @@ Ctrl+Shift+R" aria-label="Justify Ctrl+Shift+J" className=" is-not-selected" + disabled={false} onClick={[Function]} title="Justify Ctrl+Shift+J"