rasteiner/oh-hi-mark

This package is abandoned and no longer maintained. No replacement package was suggested.

Enables the inclusion of custom Writer field marks

Installs: 25

Dependents: 0

Suggesters: 0

Security: 0

Stars: 11

Watchers: 3

Forks: 1

Open Issues: 1

Language:JavaScript

Type:kirby-plugin

0.1.1 2021-11-29 12:48 UTC

This package is auto-updated.

Last update: 2023-04-20 13:08:16 UTC


README

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