Skip to content
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

update CKEditor config to use our resource-link fork #589

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

alicewriteswrongs
Copy link
Contributor

@alicewriteswrongs alicewriteswrongs commented Sep 20, 2021

Pre-Flight checklist

  • Screenshots and design review for any changes that affect layout or styling
    • Desktop screenshots
    • Mobile width screenshots
  • Testing
    • Code is tested
    • Changes have been manually tested

What are the relevant tickets?

closes #607
closes #612
part of #536

What's this PR do?

This PR changes how we support linking to resources. Instead of a block-level element (which is sort of like a paragraph in terms of how it fits in to the document) we now support inline linking. Basically, this means that the resource link is actually an attribute on a span of text, instead of a block element, and so the text inside of it can be edited and so on.

The user experience is not the greatest at present, but here's how it works:

  • the user highlights some text in the editor
  • the user clicks 'Link resource'
  • the user uses the resource picker dialog to pick a resource, and clicks the 'Link resource' confirmation button
  • a resource link is added to the editor state, serializing to the {{< resource_link >}} shortcode

To get this all working I had to make a few other changes. Some things of note:

  • we now have a fork of ckeditor here: https://github.com/mitodl/ckeditor. this is being used just to fork the Link plugin, but since ckeditor is developed as a monorepo we need to fork the whole thing. The changes I've made to the plugin to support our weird use-case are here: convert ckeditor5-link to work for resource links ckeditor5#1 Once this PR is approved I will merge that PR as well and publish a non-beta version of our custom package to npm.
  • I changed how the resource picker works a little bit. Instead of having one 'Add resource' button we now have 'Embed resource' and 'Link resource' buttons. Together these make it a little less ambiguous for the user (at least, that is the hope!)

How should this be manually tested?

follow the steps I outlined above. Keep in mind that the UX is still basic now. We do not yet support editing which resource a resource link points to once it is created, for instance. For now the user should just delete and recreate to do that. But generally play around with it and make sure it at least does what it's supposed to.

Screenshots (if appropriate)

Screen Shot 2021-09-28 at 12 38 23 PM

@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2021

Codecov Report

Merging #589 (874c024) into master (9b152a0) will decrease coverage by 0.07%.
The diff coverage is 83.60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #589      +/-   ##
==========================================
- Coverage   90.95%   90.87%   -0.08%     
==========================================
  Files         175      174       -1     
  Lines        6335     6281      -54     
  Branches      947      942       -5     
==========================================
- Hits         5762     5708      -54     
  Misses        499      499              
  Partials       74       74              
Impacted Files Coverage Δ
static/js/lib/ckeditor/plugins/ResourceEmbed.ts 92.06% <0.00%> (ø)
static/js/lib/ckeditor/plugins/ResourcePicker.ts 25.00% <20.00%> (-5.77%) ⬇️
static/js/components/widgets/MarkdownEditor.tsx 86.95% <91.66%> (-0.28%) ⬇️
...tic/js/components/widgets/ResourcePickerDialog.tsx 100.00% <100.00%> (+2.12%) ⬆️
static/js/lib/ckeditor/CKEditor.ts 100.00% <100.00%> (ø)
...lib/ckeditor/plugins/ResourceLinkMarkdownSyntax.ts 100.00% <100.00%> (ø)
static/js/lib/ckeditor/plugins/constants.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9b152a0...874c024. Read the comment docs.

@alicewriteswrongs alicewriteswrongs force-pushed the ap/resource-link-fork branch 4 times, most recently from 92b39e1 to 03cfc3d Compare September 28, 2021 15:42
@noisecapella noisecapella self-assigned this Sep 28, 2021
@noisecapella
Copy link

Functionality looks good other than the editing issue you mentioned in the description

label: "Embed resource",
withText: true
})
// TODO: icon? how to right-justify?

Choose a reason for hiding this comment

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

Can we remove this comment and the same above?

@noisecapella
Copy link

Looks great, just noticed a stray comment

alicewriteswrongs added a commit to mitodl/ckeditor5 that referenced this pull request Sep 29, 2021
This uses the ckeditor Link plugin as the basis for a new resource link
plugin which allows resource links to be inline, meaning that the UUID
for the resource is stored as an attribute of a span of text instead of
as a block element.

This is being introduced to ocw-studio in this PR:
mitodl/ocw-studio#589

pr #1
This introduces a new dependency on our custom resource link plugin,
which is based on the code for CKEditor's standard link plugin. This
allows resource links to be inlined in the text rather than being block
nodes, by storing the UUID for the link as an attribute on a range of
text.

Resource links are translated to the `resource_link` shortcode, like
this:

```
{{< resource_link uuidforaresource "text inside the link" >}}
```

This change also required some changes to how we open the resource
picker and some related things. Now instead of having one 'Add resource'
button we now have 'Embed resource' and 'Link resource' buttons.
Together these make it a little less ambiguous for the user (at least,
that is the hope!)

closes #607
closes #612
part of #536
@alicewriteswrongs alicewriteswrongs merged commit b786ed0 into master Sep 29, 2021
@alicewriteswrongs alicewriteswrongs deleted the ap/resource-link-fork branch September 29, 2021 13:25
@odlbot odlbot temporarily deployed to ocw-studio-ci September 29, 2021 13:33 Inactive
alicewriteswrongs added a commit that referenced this pull request Sep 29, 2021
for #589 when I was iterating on the code I was copying the CKEditor
over directly for a bit, and I had to make a bunch of changes to the
webpack config to get that working. Once I started publishing the forked
resource link package as its own npm package those changes were no
longer necessary, and they didn't cause problems in local development,
but they led to some issues on RC.

pr #618
alicewriteswrongs added a commit to mitodl/ckeditor5 that referenced this pull request Nov 29, 2021
This uses the ckeditor Link plugin as the basis for a new resource link
plugin which allows resource links to be inline, meaning that the UUID
for the resource is stored as an attribute of a span of text instead of
as a block element.

This is being introduced to ocw-studio in this PR:
mitodl/ocw-studio#589

pr #1
ChristopherChudzicki pushed a commit to mitodl/ckeditor5 that referenced this pull request Dec 13, 2022
This uses the ckeditor Link plugin as the basis for a new resource link
plugin which allows resource links to be inline, meaning that the UUID
for the resource is stored as an attribute of a span of text instead of
as a block element.

This is being introduced to ocw-studio in this PR:
mitodl/ocw-studio#589

pr #1
ChristopherChudzicki pushed a commit to mitodl/ckeditor5 that referenced this pull request Dec 14, 2022
This uses the ckeditor Link plugin as the basis for a new resource link
plugin which allows resource links to be inline, meaning that the UUID
for the resource is stored as an attribute of a span of text instead of
as a block element.

This is being introduced to ocw-studio in this PR:
mitodl/ocw-studio#589

pr #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants