wagtail / wagtail

A Django content management system focused on flexibility and user experience
https://wagtail.org
BSD 3-Clause "New" or "Revised" License
17.96k stars 3.79k forks source link

Can't edit wagtail fields with Ghosttext and vim #5307

Closed danihodovic closed 5 years ago

danihodovic commented 5 years ago

Found a bug? Please fill out the sections below. 👍

Issue Summary

I'm unable to edit Wagtail text fields with Ghosttext. It works with any other text field on any site I've tried so far, except for the Wagtail text fields.

image

I'm using

Steps to Reproduce

  1. Start a wagtail project and open the editor interface.
  2. Try to edit any field with Ghosttext and your favourite text editor.
  3. See errors pop up in the JS browser console.

Technical details

thibaudcolas commented 5 years ago

Hey @danihodovic, thanks for reporting this.

I hadn’t heard of Ghosttext before, from what I can see on https://github.com/GhostText/GhostText/issues it has issues with various sites / types of editors / browsers. The README also states:

Notice: GhostText generally works but it has some bugs across the various implementations. If you use it regularly please consider contributing/bugfixing your editor's GhostText plugin.

I’d suggest you first open an issue with GhostText so they can help you figure out whether in your case this is a problem with your editor, browser, or Wagtail’s fields. I think maintainers of this project will be in a better position to understand how GhostText is meant to work and what might be breaking in this one instance. Then we can consider making adjustments to Wagtail’s fields to better support extensions like this.

danihodovic commented 5 years ago

I've used Ghosttext for Stackoverflow, Github and Hacker News fields and the only site I have problems with right now is Wagtail.

thibaudcolas commented 5 years ago

Sorry to hear that @danihodovic – if you can figure out what the problems are we’d be happy to consider fixes. Again, I think people involved with GhostText will be more likely to figure out what might be causing issues than maintainers of Wagtail.

danihodovic commented 5 years ago

I found a workaround in case someone stumbles on the same issue.

The problem seems to be in the Simple Markdown Editor that wagtailmarkdown uses. It blocks ghost from meddling with the text field.

The workaround I've found is to render normal TextFields in the editor interface which works with Ghost. Using the markdown template tag from wagtailmarkdown still works with vanilla fields.

e.g

instead of

from wagtailmarkdown.fields import MarkdownField

class BlogPage(Page):
    body = MarkdownField()

use

from django.db import models

class BlogPage(Page):
    body = models.TextField()

and when rendering the markdown

{% load wagtailmarkdown %}
<div class="post-text">{{ page.body|markdown }}</div>