rasteiner / oh-hi-mark

此软件包已被弃用,不再维护。没有建议的替代软件包。

启用自定义Writer字段标记的包含

安装: 27

依赖: 0

建议者: 0

安全: 0

星星: 11

关注者: 3

分支: 1

公开问题: 1

语言:JavaScript

类型: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

存档

请使用Johann Schopplich的插件

Kirby oh-hi-mark 插件

启用自定义Writer字段标记的包含。这是Johann Schopplich的插件的替代方案,无需修改Kirby的panel dist文件。

安装

下载

下载并将此存储库复制到/site/plugins/oh-hi-mark

Git子模块

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

Composer

composer require rasteiner/oh-hi-mark

设置

此插件本身不执行任何操作。它仅提供在您自己的插件中使用自定义Writer字段标记的能力。

示例插件

从Johann Schopplich的"footnote"示例中窃取

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;
}

许可证

MIT

致谢