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
Storybook #952
Conversation
Codecov Report
@@ Coverage Diff @@
## master #952 +/- ##
==========================================
- Coverage 37.37% 36.85% -0.53%
==========================================
Files 213 225 +12
Lines 3061 3156 +95
Branches 161 160 -1
==========================================
+ Hits 1144 1163 +19
- Misses 1879 1955 +76
Partials 38 38
Continue to review full report at Codecov.
|
@Kachulio1 the build is broken cause of a webpack config issue... might you have a moment to have a look? |
To workaround ``` Module build failed (from ./node_modules/css-loader/dist/cjs.js): ValidationError: CSS Loader Invalid Options options should NOT have additional properties ``` Some silly package of us is not up-to-date and still sends `exportOnlyLocals` to `css-loader` thus raising this error. I don't know which, so I'll downgrade css-loader to `2.x.x` which has the old API.
Some important commit messages: ``` Fix youtu.be not being embedded And also try to maintain the old behaviour matching `provider.provider_url`. ``` ``` Remove confusing code comments and obsolete code I discovered that the behaviour of no duplicate notifications being send out is caused by the frontend: When the editor reads html from the backend, it will parse hashtags and mentions as ordinary links, not as their respective nodes during editing. Also, we don't have to worry about duplicate ids being found: The cypher statement will implicitly suppress duplicate notification nodes for the same user. So let's remove the code to avoid confusing the next developer. ``` ``` Test editor.getHTML() I do this because I'm not able to test the content of `this.editor` from a wrapper of `vue-test-utils`. If I call `this.editor.getHTML` directly and use it as a computed property `renderedContent` to populate a `<div v-html="renderedContent" />` this will not work for the embeds. So, my current best bet is to test the editor object isolated from a real component. ;( ``` ``` Add core-js as explicit dependency Because of build errors on Travis. See: https://stackoverflow.com/a/55313456 Remove as soon as this issue is resolved: storybookjs/storybook#7591 ``` ``` Refactor: Keep Runtime-only builds See: https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only ```
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.
Hey, this is really great @roschaefer... I had some questions/doubts below, and I'm trying to manually test it and noticed that peertube videos don't embed, I also couldn't find any gifs that embed.... maybe there is nothing we can do about that(?)
Maybe, we could have a pairing session yesterday when @Tirokk is available?
}) | ||
}) | ||
it('ignores links without .mention class', () => { | ||
expect(extractMentionedUsers(contentWithLinks)).toEqual([]) |
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.
contentWithLinks
does contain the mention
class, Oder?
I think what it is missing is the data-mention-id
(?)
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 renamed the variable to contentWithPlainLinks
, it should ignore the links if they don't have data-mention-id
. This is unambiguous, oder?
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.
sorry, what I was questioning is the description ignores links without .mention class
, cause the contentWithPlainLinks
does include a mention class, but it is ignored for the reason you stated ☝️
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'm stupid, I meant the data-mention-id
}) | ||
return $('body').html() | ||
} | ||
|
||
function clean(dirty) { | ||
if (!dirty) { | ||
return dirty | ||
} | ||
|
||
// Convert embeds to a-tags |
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.
unnecessary comment now?
expect(findProvider(`https://youtu.be/qkdXAtO40Fo`)).toEqual('https://www.youtube.com/oembed') | ||
}) | ||
|
||
it('matches `https://youtu.be/qkdXAtO40Fo?t=41`', () => { |
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.
was this test just to give the edge case of non-alphanumeric characters in the URL?
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.
No, I wanted to see if youtube shareable links with a time position ?t=41
cause troubles or not.
] | ||
helpers.init({ plugins }) | ||
|
||
const users = [{ id: 1, slug: 'peter' }, { id: 1, slug: 'sandra' }, { id: 1, slug: 'jane' }] |
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.
it's weird they all have the same id, no? 😛
content: ` | ||
<p> | ||
Here you can mention people like | ||
<a class="mention" href="/profile/1" target="_blank" contenteditable="false">@sandra</a> and others. |
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.
missing data-mention-id
, right?
@@ -183,30 +183,16 @@ | |||
</template> | |||
|
|||
<script> | |||
import defaultExtensions from './defaultExtensions.js' |
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.
Like this change
describe('`content` contains a mentioning', () => { | ||
beforeEach(() => { | ||
content = | ||
'<p>This is a post content mentioning <a class="mention" href="/profile/f0628376-e692-4167-bdb4-d521de5a014f" target="_blank">@alicia-luettgen</a>.</p>' |
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.
data-mention-id
?
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.
is it added in toDom
?
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.
Since parseDOM
is returning empty array, Mention
and Hashtag
never get parsed from html. It's a one-way, let's say "write-only".
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.
By the way: I was worried I could break the hashtag implementation if hashtags are not parsed:
- Tag a post with 3 hashtags
- Edit the post without touching the hashtags
- Are the hashtags gone now? - No, because the backend implementation searches for
a[href]
with ahref
starting with/search/hashtag/
.
It's sometimes really, really confusing because all the implementations are interconnected. We have to be very careful about refactoring it.
expect(editor.getJSON()).toEqual(expected) | ||
}) | ||
}) | ||
}) |
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 great that you added more tests for the Editor
!!
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 testing the Editor.vue
component. Only tiptap
's editor
. Nevertheless, I hope this tests gives us some assurance about how HTML get parsed for Editor.vue
and ContentViewer.vue
.
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.
Moin @roschaefer ,
I have tried out the embeds.
Really cool job you did!!! 🚀💫 Yuhuuhh !!!
In general it functions very well, but I have found some problems and missfunctionings. And I have additional suggestions.
General functional problems or questions
- If I paste a link -> embed, the link should have target „_blank“. Otherwise I leave the editor page by a click on it.
- On creation a mention and a hashtag appears as a block. If I edit the post later, it’s not a block anymore. Otherwise an embed appears always as block, and a keyboard written link always appears not as a block.
- After I paste a link getting an embed the cursor is before it and not afterwards, as I would await.
- If you paste a link in the line under an embed, the new link slips into the embed:
URLs which don’t work
Because of underscores I think:
http://backreaction.blogspot.com/2019/07/the-forgotten-solution-superdeterminism.html?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+blogspot%2Fermku+%28Backreaction%29
https://de.wikipedia.org/wiki/Yin_und_Yang
Suggestions:
3b93fbe
to
b797ce4
Compare
* Add target="_blank" (on embeds only!) * When pasting a link, the cursor position is moved after the paste * Can't reproduce a link slipping into the embed in front of it @Tirokk it is an unpleasant side efffect that mentions + hastags appear differently on Edit+View. That's because they don't get parsed from HTML, it's a one way, they are write only. So, when viewing content, hashtags and mentions appear as plain links. I don't think I can do anything about it. Regarding some links not being embedded: Only those links that have an oembed provider in this file: https://github.com/Human-Connection/Human-Connection/blob/f44d0f1f96f97a1001b5edcc32426b5da7ff6074/backend/src/schema/resolvers/embeds/providers.json ...will be embedded. Your example `http://backreaction.blogspot.com` and `https://de.wikipedia.org/wiki/Yin_und_Yang` have no embed provider and won't be embedded. We would have to add oembed providers to this list if we wanted to embed those links, too.
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.
Moin @roschaefer !
Can't reproduce a link slipping into the embed in front of it
: This error vanished now, probably because of the corrected curser position after pasting an link->embed!?
You misunderstood. Pasting in the links:
http://backreaction.blogspot.com/2019/07/the-forgotten-solution-superdeterminism.html?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+blogspot%2Fermku+%28Backreaction%29
https://de.wikipedia.org/wiki/Yin_und_Yang
… just don’t work correct, because of a problem with underscores I think. Has nothing todo with embeds.
My suggestion to use the image url from the metadata as the posts teaser image, if there is none, was just in general. No matter if you turn the link into an embed or not. @mattwr18 thinks that this would be a great idea as well.
If one pastes just a link->embed in a post, the save button is disabled. That comes because of the content sanitisation on HTML, before testing the content length. The sanitisation I find very smart and important. Can we just check additionally in file webapp/components/ContributionForm/ContributionForm.vue
in function manageContent
for setting disabledByContent
, if theres an embed in the content?
@roschaefer your new regex seems not to work correctly!? |
Apparently the default pasteRules of tiptap interfere with the pasteRules of a Link (in our case an Embed node). Consider this example: https://de.wikipedia.org/wiki/Yin_und_Yang Depending on some random conditions, tiptap might parse the `_und_` to be italic because it's wrapped with underscores (markdown syntax). The result is: https://de.wikipedia.org/wiki/Yin # link _und_ # italic Yang # plain text So let's remove the default pasteRules of `Bold`, `Strike` and `Italic` marks respectively to prefer our Embeds. Who is copy+pasting from one tiptap editor to another tiptap editor anyways?
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.
Yeah @roschaefer , now you got it running correctly.
Astonishing coding again my dear, a big chunk of code and huge step forward to our release !!! 🚀🚀💫
Thank you for all your effort you put again into our project.
You are one of our heroes … 😍
🍰 Pullrequest
@appinteractive I put in a
PR
for this cause it is nice to play around with theEmbeds
here, and it would be nice to talk about merging in storybookEDIT: fix #256
ToDos:
provider.endpoint.schemes
here: https://github.com/Human-Connection/Human-Connection/blob/master/backend/src/schema/resolvers/embeds/scraper.js#L43 usingprovider_url
is just silly. This will fix the problem withyoutu.be
links