D14738: Add the markdown entry

Nikita Sirgienko noreply at phabricator.kde.org
Fri Aug 17 16:24:05 BST 2018


sirgienko added a comment.


  In D14738#310483 <https://phabricator.kde.org/D14738#310483>, @kqwyf wrote:
  
  > In D14738#310269 <https://phabricator.kde.org/D14738#310269>, @sirgienko wrote:
  >
  > > In D14738#310261 <https://phabricator.kde.org/D14738#310261>, @kqwyf wrote:
  > >
  > > > Here comes a problem...
  > > >
  > > > The reason I'd like to make rendered markdown entries uneditable is that, if the user edited a rendered markdown entry, then we could never convert the content (in html) back to markdown.
  > > >  To imitate the behaviors of latex entries better, I thought it's a good idea that the cursor can move on the markdown entries while they can't be edited.
  > >
  > >
  > > In this moment, if you haven't libspectre (or latex), you can't exec latex entry (well, you can, but nothing happens) and another actions allowed. If you haven't libspectre and load worksheet with 
  > >  latex formulas, we can see rendrered images (okay, in this moment, we can't see, but I working on this problem and this will be fix soon on master), but I could edit unrendered latex entries and convert renderered to unrendered entries by double click.
  >
  >
  > Actually, for now most behaviors of a markdown entry are similar to those of a latex entry. The only difference is that when rendered, you can move the cursor in a latex entry and edit the content (by treating the rendered content as a picture) of a latex entry, but you can't move the cursor nor edit the rendered content (except by double clicking) in a markdown entry.
  >  The reason that the rendered markdown entry shouldn't be edited directly is that it can't be treated as a whole. If my explanation is poor, here's an example (supposing that the markdown entry is always editable and the user has Discount library) :
  >
  > 1. The user inserted a markdown entry, inputed `## Markdown` and evaluated it. So the content was `<h2>Markdown</h2>` in html.
  > 2. The user single clicked on it (the entry remains rendered) and deleted some characters, for example, `down`. The content became `<h2>Mark</h2>` in html.
  > 3. The user double clicked on it. In this moment, the user might expect that the content becomes `## Mark`, but actually we can't do it because we can't convert html to markdown. What we have is just the original code, `## Markdown`.
  >
  >   Due to the reason above, I set `Qt::TextBrowserInteraction` when the markdown entry is rendered.
  >
  > In D14738#310269 <https://phabricator.kde.org/D14738#310269>, @sirgienko wrote:
  >
  > > As I know, LaTeX entries always set `Qt::TextEditorInteraction` (see LatexEntry constructor), so isEditable() return true, so I think, this code don't give us problems.
  > >  And as I see, Text entries do the same.
  >
  >
  > Due to the reason above, markdown entries have to be different from others...
  >
  > In D14738#310269 <https://phabricator.kde.org/D14738#310269>, @sirgienko wrote:
  >
  > > LatexEntry and TextEntry don't override `wantFacuse` function from WorksheetEntry, so I don't think, that we need override the function in MarkdownEntry.
  >
  >
  > For the problem above, one solution is to override this function to enable the cursor to move on the whole worksheet. (or the cursor will be stopped by a markdown entry)
  >
  > I just came up with another solution which enable the cursor to move onto the markdown entries (and I tested it). We can catch the `KeyPressEvent` of `m_textItem` in the event filter (see src/markdownentry.cpp, line 139) and let the cursor move correctly. But as I think, this solution will make the event processing logic messy and confusing.
  >
  > What should I do?
  
  
  Okey, I got it. Well, LatexEntry don't protect rendered content from editing (and it Cantor's architectural miscalculation), so maybe MarkdownEntry also don't need it? In this revision, I mean.
  The solution of this problem (more integrated and consistent with another code) could be added later and applied for markdown and latex entries (so, I think, @kqwyf, you don't need solve this problem)

REPOSITORY
  R55 Cantor

REVISION DETAIL
  https://phabricator.kde.org/D14738

To: kqwyf, pino, #cantor, filipesaraiva
Cc: sirgienko, filipesaraiva, pino, asemke, kde-edu, narvaez, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20180817/acc4118c/attachment-0001.html>


More information about the kde-edu mailing list