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

feat: add custom editor API #312

Merged
merged 20 commits into from
Aug 24, 2020
Merged

feat: add custom editor API #312

merged 20 commits into from
Aug 24, 2020

Conversation

mathe42
Copy link
Contributor

@mathe42 mathe42 commented Jul 30, 2020

This PR is a rebased version of #308

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

With

content: {
   editor: '~/path/to/component/editor.vue'
}

you can define your own component for editing.

Your component should implement the following:

  1. v-model for the markdown code
  2. prop isEditing (optional)
  3. when the edit is finished your component should emit endEdit

Resolves #303

Example

https://github.com/mathe42/content-editor

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

Tests

I think existing tests should be enough. I didn't touch the tests and they didn't break.

@mathe42 mathe42 changed the title feat: add custom editor API feat: add custom editor API (WIP) Jul 30, 2020
@mathe42 mathe42 changed the title feat: add custom editor API (WIP) feat: add custom editor API Aug 2, 2020
@mathe42
Copy link
Contributor Author

mathe42 commented Aug 2, 2020

Custom editor example

To test this with a custom editor (created by me :D ) follow this steps:

  1. checkout my branch
  2. run:
cd docs
yarn add nuxt-content-editor
  1. add the following to the nuxt.config.js:
  content: {
    editor: '../../../node_modules/nuxt-content-editor/editor.vue',
  },

We have to use this relative path as editor.vue has to be comp-/transpiled
4. run yarn dev
5. checkout the docs at localhost:3000

@mathe42
Copy link
Contributor Author

mathe42 commented Aug 2, 2020

@benjamincanac This is ready for review.

Copy link
Member

@atinux atinux left a comment

Choose a reason for hiding this comment

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

I think this need tests as well as using alias resolution + suggested changes

docs/content/en/configuration.md Outdated Show resolved Hide resolved
docs/content/en/configuration.md Outdated Show resolved Hide resolved
docs/content/en/configuration.md Outdated Show resolved Hide resolved
docs/content/en/configuration.md Outdated Show resolved Hide resolved
packages/content/lib/index.js Outdated Show resolved Hide resolved
mathe42 and others added 4 commits August 5, 2020 12:29
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
@mathe42
Copy link
Contributor Author

mathe42 commented Aug 5, 2020

Todos

  • Requestet changes
  • Alias resolution
  • testing

Alias resolution

As I understand you mean pathes like @/components/editor.vue or ~/components/editor.vue this should work out of the box...

Pathes like 'myNPMpackage/editor.js' are working too.

Testing

What has to be tested?

  • editor options works and replaces component
  • editor options works with alias e.g. ~/components/editor.vue
  • default editor works as expected (old tests handle this)

@mathe42
Copy link
Contributor Author

mathe42 commented Aug 5, 2020

@atinux
Added some thoughts what we can test. I will try to implement them next week. If I missed something just tell me. 👍

@mathe42 mathe42 requested a review from atinux August 7, 2020 19:26
@mathe42
Copy link
Contributor Author

mathe42 commented Aug 7, 2020

@atinux added some tests...

@mathe42
Copy link
Contributor Author

mathe42 commented Aug 15, 2020

@benjamincanac @atinux is there any progress on the review?

@atinux
Copy link
Member

atinux commented Aug 15, 2020

Hi @mathe42

We were on holidays this week.
Will review the coming week, overall looks great!

@benjamincanac benjamincanac merged commit 78fbb92 into nuxt:dev Aug 24, 2020
@mathe42 mathe42 deleted the patch-7 branch August 24, 2020 17:18
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.

Wysiwyg (rich editor) when editing mode?
3 participants