Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.
/ oh-hi-mark Public archive

Enables the inclusion of custom Writer field marks

License

Notifications You must be signed in to change notification settings

rasteiner/oh-hi-mark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived

Please use Johann Schopplich's plugin

Kirby oh-hi-mark plugin

Enables the inclusion of custom Writer field marks. It's an alternative to Johann Schopplich's plugin that doesn't require to patch Kirby's panel dist files.

Installation

Download

Download and copy this repository to /site/plugins/oh-hi-mark.

Git submodule

git submodule add https://github.com/rasteiner/oh-hi-mark.git site/plugins/oh-hi-mark

Composer

composer require rasteiner/oh-hi-mark

Setup

This plugin alone does nothing. It serves only to provide you the ability to use custom Writer field marks in your own plugins.

Example plugin

Stolen from Johann Schopplich's "footnote" example:

index.php

<?php

use Kirby\Cms\App as Kirby;
use Kirby\Sane\Html;

/*
 * Add `article-footnote` to Kirby's Sane class allowed tags,
 * otherwise the writer field content parsed by the sanitizer would
 * strip `article-footnote` tags (Applies to Kirby 3.6+ only).
 */
Html::$allowedTags['article-footnote'] = true;

Kirby::plugin('rasteiner/footnote-mark', []);

index.js

panel.plugin('rasteiner/footnote-mark', {
  thirdParty: {
    marks: {
      // if you want this plugin to play nice with other marks plugins,
      // you should keep them with the following line:
      ...panel.plugins.thirdParty.marks || {},

      footnote: {
        get button() {
          return {
            icon: 'quote',
            label: 'Footnote'
          }
        },

        commands() {
          return () => this.toggle();
        },

        get name() {
          return "footnote";
        },

        get schema() {
          return {
            parseDOM: [{ tag: "article-footnote" }],
            toDOM: (node) => [
              "article-footnote",
              {
                ...node.attrs,
              },
              0,
            ],
          };
        }
      }

    }
  }
})

index.css:

.k-blocks {
  counter-reset: footnotes;
}

.k-writer .ProseMirror article-footnote {
  color: currentColor;
  counter-increment: footnotes;
  text-decoration: underline dotted;
}

.k-writer .ProseMirror article-footnote::after {
  content: "[" counter(footnotes) "]";
  color: #999;
  text-decoration: underline dotted white;
}

License

MIT

Credits

About

Enables the inclusion of custom Writer field marks

Resources

License

Stars

Watchers

Forks

Packages

No packages published