Skip to content

Feature/ms 447/scorer highlight plugin - #101

Open
AnastasiaArcadia wants to merge 14 commits into
developfrom
feature/MS-447/scorer-highlight-plugin
Open

Feature/ms 447/scorer highlight plugin#101
AnastasiaArcadia wants to merge 14 commits into
developfrom
feature/MS-447/scorer-highlight-plugin

Conversation

@AnastasiaArcadia

Copy link
Copy Markdown
Contributor

Pull request summary

Related to MS-447.

Scorer's Highlight plugin

How to test

On MS side:

  • Login as a scorer
  • Go to the task page
  • Click on the highlighter icon button
  • Select some text, click on the color button - text should be highlighted
  • Click on the eraser button - highlights should be cleared

Comment thread views/js/previewer/plugins/content/highlighter.js Outdated
Comment thread views/js/previewer/plugins/content/highlighter.js Outdated
Comment thread views/js/previewer/plugins/content/highlighter.js Outdated
function highlight(highlighter, selection) {
highlighter.highlightRanges(getAllRanges(selection));
//Sending the highlighIndex to parent so that it can be saved on MS side
parent.postMessage({ event: 'indexUpdated', payload: highlighter.getHighlightIndex() }, '*');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing * is not a very good practice, as we know the target where we want the message to be sent we should use that, the only problem is we are not storing it in tao so IDK how and where we should store this info in tao. Failing to provide a specific target discloses the data you send to any interested malicious site.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Indeed, this might be a flaw.

suggestion: We use to have iframe by the past, and we have a legacy component to post message to a parent window: iframNotifier.
A property must be set by the parent to make the iframe elligible to communication.
However, I'm wondering if this module is not deprecated.
Even if you cannot control the parent window, couldn't you still declare a valid context from the config?

nitpick: Moreover, please always use window to namespace global context objects.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, seems like iframNotifier doesn't work with cross-origin, hasAccess doesn't pass
https://github.com/oat-sa/tao-core-libs-fe/blob/06905acf3ca51d67c54e474fc59806c4172264fc/src/iframeNotifier.js#L22

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. The iframeNotifier is meant to be used with fully controlled parents. If you use different domain names and servers it won't work. Moreover, I don't know if this module is still usable.

The overall idea is to secur the messaging, preventing the window to communicate with untrusted wrappers.

Comment thread views/js/previewer/plugins/content/highlighter.js Outdated
Comment thread views/js/previewer/plugins/content/highlighter.js Outdated
Comment thread views/js/previewer/plugins/content/highlighter.js Outdated
Comment thread views/js/previewer/plugins/content/scss/highlighterTray.scss Outdated

width: 100%;
height: 100%;
padding-top: 3rem;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to touch the scale plugin? 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Indeed, please be careful with the scale plugin, especially with its style. It might introduce regressions as it is very sensible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I have scroll bars for .devices-previewer - height: 100%; when the highlighter element is added to .content-wrapper 😔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add display: flex; flex-direction: column; to .content-wrapper or it will break something, WDYT?

@jsconan jsconan Oct 13, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this is hard to tell. AFAIR the devicesPreviewer plugin was a pain to make working on every browsers.
But the isn't .content-wrapper used in other places? If you target it, you must ensure it will only apply for the previewer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like .item-previewer-scope -> .content-wrapper is used only here

@jsconan jsconan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review only.
A few remarks, but the overall look good. GJ!

Comment thread views/js/previewer/plugins/content/tpl/highlighter-tray.tpl Outdated
Comment thread views/js/previewer/plugins/content/scss/highlighterTray.scss Outdated

width: 100%;
height: 100%;
padding-top: 3rem;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: Indeed, please be careful with the scale plugin, especially with its style. It might introduce regressions as it is very sensible.

Comment thread views/js/previewer/component/qtiItem.js Outdated
function highlight(highlighter, selection) {
highlighter.highlightRanges(getAllRanges(selection));
//Sending the highlighIndex to parent so that it can be saved on MS side
parent.postMessage({ event: 'indexUpdated', payload: highlighter.getHighlightIndex() }, '*');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Indeed, this might be a flaw.

suggestion: We use to have iframe by the past, and we have a legacy component to post message to a parent window: iframNotifier.
A property must be set by the parent to make the iframe elligible to communication.
However, I'm wondering if this module is not deprecated.
Even if you cannot control the parent window, couldn't you still declare a valid context from the config?

nitpick: Moreover, please always use window to namespace global context objects.

Comment thread views/js/previewer/plugins/content/highlighter.js Outdated
//hide highlighter menu by default
hider.hide(this.$highlighterTray);

testRunner.after('renderitem', function () {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: A namespace should be used here. So that you can unregister the handler upon destroy.

Comment thread views/js/previewer/plugins/content/scss/highlighterTray.scss Outdated
Comment thread views/js/previewer/provider/item/scss/inc/_previewer-layout.scss
Comment thread views/js/previewer/adapter/item/qtiItem.js Outdated
Comment thread views/js/previewer/plugins/content/highlighter.js Outdated
@AnastasiaArcadia
AnastasiaArcadia changed the base branch from master to develop October 19, 2020 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants