Commit 43b2889e authored by Robert Kasza's avatar Robert Kasza Committed by Róbert Kasza
Browse files

Issue #3280625 by kaszarobert: Add proper hook_help() and README

parent 05ccafbd
Loading
Loading
Loading
Loading
+49 −46
Original line number Diff line number Diff line
<strong>First Level Header</strong><br />
    Making Scrambled Eggs: A Primer<br />
    ===============================<br />
    <br />
    <strong>Second Level Header</strong><br />
    1.1: Preparation<br />
    ----------------<br />
    <br />
    <strong>Paragraphs</strong><br />
    Add two new lines to start a new paragraph. Crack two eggs into the bowl and whisk.<br />
    <br />
    <strong>Bold</strong><br />
    **Carefully** crack the eggs.<br />
    <br />
    <strong>Emphasis</strong><br />
    Whisk the eggs *vigorously*.<br />
    <br />
    <strong>Lists</strong><br />
    Ingredients:<br />
    <br />
    - Eggs<br />
    - Oil<br />
    - *Optional:* milk<br />
    <br />
    <strong>Numbered lists</strong> <br />
    Items: <br />
    <br />
    1. Item 1<br />
    2. Item 2<br />
    3. Item 3<br />
    <br />
    <strong>Links</strong><br />
    To download a PDF version of the recipe, [click here](https://example.com/scrambled-eggs.pdf).<br />
    or<br />
    To download a PDF version of the recipe, [click here](Media-Entity-ID).<br />
    <br />
    <strong>Images</strong><br />
    ![Image Alt-Text](https://example.com/eggs.png)<br />
    or <br />
    ![Image Alt-Text](Media-Entity-ID, Image Style)<br />
    <br />
    <strong>Alignment</strong><br />
    ^c center<br />
    ^r right<br />
    ^l left<br />
    Hint: it is important to add an empty space after formatting string e.g. '^r '!
 No newline at end of file
# Blizz Table Field

## Description

Provides an easy to use table field just to display static tables.

This Module makes use from the JS-library "handsontable" to have an editable tables in the backend.
It provides formatting options left/right-align, table headers and more.
Inside the table you can not use HTML but you can use MarkDown what will be rendered as HTML.

## Install

There are two JS-libraries required by this module: Handsontable and PapaParse.
Both will be required by composer with following configuration in your composer.json.

```
  "repositories": [
    ... ,
    {
      "type": "composer",
      "url": "https://asset-packagist.org"
    }
  ],
  "require": {
    ...
    "oomphinc/composer-installers-extender": "^1.1",
    "drupal/blizz_table_field": "~1.0"
  }
  "extra": {
    "installer-types": [
      "bower-asset"
    ],
    "installer-paths": {
      "docroot/libraries/{$name}": [
        "type:drupal-library",
        "type:bower-asset"
      ],
      ...
    }
```

After install, check the Drupal-status-page if you can find the libraries in the libraries folder in your web folder.

## Set up module
1. Create a field to whatever content type, taxonomy term, media, paragraph, etc.
2. When creating field, set type as Table.
3. You can set that if the table value should be saved to the database as JSON or CSV format. Choose whatever format.
4. Optionally you can use MarkDown in the table cell texts, at page `/admin/config/content/blizz_table_field/settings`
  you can set help text for using MarkDown syntax.
+12 −4
Original line number Diff line number Diff line
@@ -17,10 +17,18 @@ function blizz_table_field_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the blizz_table_field module.
    case 'help.page.blizz_table_field':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Provides a table field.') . '</p>';
      return $output;
      $text = file_get_contents(dirname(__FILE__) . '/README.md');
      if (!\Drupal::moduleHandler()->moduleExists('markdown')) {
        return '<pre>' . $text . '</pre>';
      }
      else {
        // Use the Markdown filter to render the README.
        $filter_manager = \Drupal::service('plugin.manager.filter');
        $settings = \Drupal::configFactory()->get('markdown.settings')->getRawData();
        $config = ['settings' => $settings];
        $filter = $filter_manager->createInstance('markdown', $config);
        return $filter->process($text, 'en');
      }

    default:
  }