-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add markdown to notebook entries #7084
Conversation
Current Playwright Test Results Summary✅ 14 Passing - Run may still be in progress, this comment will be updated as current testing workflow or job completes... (Last updated on 10/02/2023 10:27:46pm UTC) Run DetailsRunning Workflow e2e-couchdb on Github Actions Commit: 9ed1ce9 Started: 10/02/2023 10:22:00pm UTC
|
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Display Layout When multiple plots are contained in a layout, we only ask for annotations once @couchdb
Retry 1 • Initial Attempt |
2.50% (1)1 / 40 runfailed over last 7 days |
20% (8)8 / 40 runsflaked over last 7 days |
Current Playwright Test Results Summary
✅ 141 Passing -
Run may still be in progress, this comment will be updated as current testing workflow or job completes...
(Last updated on 10/02/2023 10:27:46pm UTC)
⚠️ Flakes
📄 functional/plugins/notebook/notebookSnapshots.e2e.spec.js • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Snapshot image tests Can drop an image onto a notebook and create a new entry
Retry 1 • Initial Attempt |
15.73% (14)14 / 89 runsfailed over last 7 days |
61.80% (55)55 / 89 runsflaked over last 7 days |
Codecov Report
@@ Coverage Diff @@
## master #7084 +/- ##
===========================================
- Coverage 55.60% 41.92% -13.68%
===========================================
Files 650 412 -238
Lines 26063 12792 -13271
Branches 2547 0 -2547
===========================================
- Hits 14492 5363 -9129
+ Misses 10871 7429 -3442
+ Partials 700 0 -700
see 519 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
@jvigliotta Here's what I've got so far. Screen.Recording.2023-09-25.at.4.53.44.PM.movThere are few issues with it:
|
At this point, I'll probably need some CSS help from @rukmini-bose or @charlesh88. We're rendering this sample input: which renders the HTML: <div id="entry-37de3c3f-72e8-4603-a3d2-4bb69f0c1c73" class="c-ne__text c-ne__input" aria-label="Notebook Entry Input" tabindex="-1" contenteditable="true"><h1>h1 Heading</h1>
<h2>h2 Heading</h2>
<h3>h3 Heading</h3>
<h4>h4 Heading</h4>
<h5>h5 Heading</h5>
<h6>h6 Heading</h6>
<h2>Emphasis</h2>
<p><strong>This is bold text</strong></p>
<p><strong>This is bold text</strong></p>
<p><em>This is italic text</em></p>
<p><em>This is italic text</em></p>
<p><del>Strikethrough</del></p>
<h2>Blockquotes</h2>
<blockquote>
<p>Blockquote </p>
<blockquote>
<p>nested quote</p>
<blockquote>
<p>very nested</p>
</blockquote>
</blockquote>
</blockquote>
<h2>Lists</h2>
<p>Unordered</p>
<ul>
<li>apple</li>
<li>orange</li>
</ul>
<p>Ordered</p>
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
<h2>Code Blocks</h2>
<p>Block code "fences"</p>
<pre><code>Sample text here...
</code></pre>
<h2>Tables</h2>
<table>
<thead>
<tr>
<th>Option</th>
<th>Description</th>
<th>Notes</th>
</tr>
</thead>
<tbody><tr>
<td>data</td>
<td>path to data files to supply the data that will be passed into templates.</td>
<td>first item</td>
</tr>
<tr>
<td>engine</td>
<td>engine to be used for processing templates. Handlebars is the default.</td>
<td>second item</td>
</tr>
<tr>
<td>ext</td>
<td>extension to be used for dest files.</td>
<td>third item</td>
</tr>
</tbody></table>
<h2>Links</h2>
<p>These need to be whitelisted:</p>
<p>link text</p>
<p>link with title</p>
</div> with the exception of:
|
This looks awesome Scott! |
Have pushed up CSS changes that fix most of the problems you were seeing. An important note: we were using I may still do some sanding and shimming tomorrow, minor stuff like table widths and text contrast. Also ran into a couple issues and a question, in order of priority:
Exported JSON of my test Notebook used for screenshots below |
I think I've got that figured per your suggestion by adding <p>Here's a line with a double-return before it. <br>Here's a line with a single return before it. It doesn't add a <code><br></code> before it, but should.</p> |
Dragging from a webpage will only work if CORS is enabled for the website for the server hosting Open MCT. You should have at least gotten a nice notification saying "Failed to fetch image" and a more specific error in the console. |
This is a tough one to fix as Marked has already tokenized the extra space as separate from the list item, so we'd have to remove it either before being fed to Marked, or after. We could do this by either using regular expressions on the input text or resultant HTML, or parsing the output HTML into DOMs, manipulating it there, and then serializing the HTML back out again. Would it be OK to file this as a follow on issue? |
I say that and the Marked demo isn't doing this. Let me dig into this further. |
@charlesh88 and thank you very much for the CSS assistance - it look way better! |
…/openmct into 6060-notebooks-formatted-entries-v2
@charlesh88 For the trailing space and nested lists, I think they're both caused by having div with out a Setting &__input {
// Appended to __text element when Notebook is not in readOnly mode
@include inlineInput;
padding-left: $p;
padding-right: $p;
overflow: unset;
margin-bottom: $interiorMargin;
text-overflow: unset;
white-space: pre-wrap;
} Here's the resultant trailing space HTML: <ul>
<li>Leaving a space at the end of a list item before a double-return encodes a non-breaking space in a paragraph container. The only way to fix it is to delete the trailing space at the end of list item, which is really unintuitive. This sucks, can we do anything about this?
</li>
</ul>
<p>See?</p> and the nested lists: <ul>
<li>List item<ul>
<li>This nested list item isn't recognized but should be.</li>
</ul>
</li>
<li>Another list item
<ol>
<li>Numbered item under an unordered list item isn't recognized but should be.</li>
<li>Numbered item under an unordered list item isn't recognized but should be.</li>
</ol>
</li>
</ul> Here are screenshots of the rendering, which still have a lot of space that we can probably compact: Another alternative we could pursue is swapping out the |
Just pushed up changes that stub in a |
Before this is merged, I want to make sure we are not allowing any unsanitized HTML or JavaScript from the user? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments about sanitization
@akhenry We're sanitizing output from the Markdown here. We're doing the same thing before we render for annotation search results. |
@akhenry Added a further input sanitization, to prevent it from being saved in the first place. Screen.Recording.2023-10-02.at.10.56.42.PM.mov |
@scottbell Beautiful, thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really awesome work! I tested all the usual Markdown syntax, including hyperlinks (which still respected the URL sanitization properly!) Looks solid.
@@ -482,4 +482,42 @@ test.describe('Notebook entry tests', () => { | |||
expect.soft(await sanitizedLink.count()).toBe(1); | |||
expect(await unsanitizedLink.count()).toBe(0); | |||
}); | |||
test('Can add markdown to a notebook entry', async ({ page }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to block this PR, but we should remember to add a visual test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll put in a ticket for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -119,6 +105,9 @@ export default { | |||
return this.result.fullTagModels[0].foregroundColor; | |||
} | |||
}, | |||
beforeMount() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what difference it makes, but this could be in created()
as well
@scottbell Fantastic work, was truly a pleasure working on this with you. Just ran the merged code locally and it's working great! |
Closes #6060
Describe your changes:
Add the Marked library, and consolidate the URL whitelisting/anchor tag generation.
All Submissions:
Author Checklist
Reviewer Checklist