You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
3.2 KiB

  1. <div class="narrow">
  2. <?= partial('partials/header') ?>
  3. <h2>Rich Editor</h2>
  4. <img src="/images/rich-editor-interface.png" style="max-width: 100%;">
  5. <p>The rich editor allows you to write posts with some basic formatting and embedded images.</p>
  6. <h3>Embedded Images</h3>
  7. <p>When editing, you can add images to your post in the interface. There are two ways embedded images are handled.</p>
  8. <p>If your Micropub server supports a <a href="https://www.w3.org/TR/micropub/#media-endpoint">Media Endpoint</a>, then at the time you add the image to the interface, Quill uploads the file to your Media Endpoint and embeds it in the editor as an <code>&lt;img&gt;</code> tag pointing to the file on your server. When you publish the post, the HTML will contain this img tag.</p>
  9. <pre><?= htmlspecialchars('<img src="https://media.example.com/image/10000.png">'); ?></pre>
  10. <p>If your Micropub server does not support a Media Endpoint, then when you add an image in the editor, the image is converted to a data URI, and will be sent to your Micropub endpoint when you publish the post. You don't need to do anything special to handle the image, since if you render this HTML directly, your viewers will see the image! Of course this means your HTML file will increase by the size of the image, so you may wish to implement a <a href="https://www.w3.org/TR/micropub/#media-endpoint">Media Endpoint</a> in order to handle images in your posts separately.</p>
  11. <pre><?= htmlspecialchars('<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZIAAAET...'); ?></pre>
  12. <h3>Post Properties</h3>
  13. <p>The following properties will be sent in the Micropub request. This request will be sent as a JSON request.</p>
  14. <p>The access token is sent in the Authorization HTTP header:</p>
  15. <pre>Authorization: Bearer XXXXXXXXX</pre>
  16. <ul>
  17. <li><code>name</code> - The title of your post.</li>
  18. <li><code>content.html</code> - The full HTML of your post in the editor. This may include data-uri-encoded images.</li>
  19. <li><code>category</code> - This property will be repeated for each tag you've entered in the "tags" field.</li>
  20. <li><code>mp-slug</code> - If you enter a slug, this will be sent in the request. You can customize the name of this property in settings.</li>
  21. <li><code>post-status</code> - If you choose "draft" from the status dropdown, then this property will be set to "draft". Otherwise, it will not be included in the request. This is an indication to your endpoint that this is a draft post and should not be made public. Of course it's up to your endpoint to implement draft posts in whatever way you choose.</li>
  22. </ul>
  23. <p>This will be sent as a JSON request, so the request will look something like the following.</p>
  24. <pre>POST /micropub HTTP/1.1
  25. Content-type: application/json
  26. Authorization: Bearer XXXXXXXXXXX
  27. {
  28. "type": "h-entry",
  29. "properties": {
  30. "name": [
  31. "Post Title"
  32. ],
  33. "content": [
  34. {
  35. "html": "&lt;p&gt;The HTML contents of your post from the editor&lt;/p&gt;"
  36. }
  37. ],
  38. "mp-slug": [
  39. "slug"
  40. ],
  41. "category": [
  42. "foo",
  43. "bar"
  44. ]
  45. }
  46. }
  47. </pre>
  48. <hr>
  49. <p>Back to <a href="/docs/creating-posts">Creating Posts</a></p>
  50. </div>