Giter Club home page Giter Club logo

moodle-atto_styles's Introduction

moodle-atto_styles

Moodle Plugin CI

Moodle Atto plugin which lets the administrator provide custom CSS classes which can afterwards be applied by users to block and inline text in Atto

Requirements

This plugin requires Moodle 4.3+

Motivation for this plugin

The purpose of this Atto plugin is to let users apply custom CSS classes to block and inline text.

Installation

Install the plugin like any other plugin to folder /lib/editor/atto/plugins/styles

See http://docs.moodle.org/en/Installing_plugins for details on installing Moodle plugins

Usage & Settings

After installing the plugin, it does not do anything to Moodle yet.

To configure the plugin and its behaviour, you will have to do three configuration steps to take advantage of this plugin:

1. Configure CSS classes

The CSS class definitions which are applied to text within Atto can't be made within this plugin. You will have to add your CSS class definitions to your theme (See https://docs.moodle.org/en/Theme_settings#Particular_theme_settings for details) or Moodle additional HTML settings (See https://docs.moodle.org/en/Header_and_footer for details).

Here's a CSS example which might help you to build basic styles with this plugin:

.attostylesbox {
    padding: 10px;
    box-sizing: border-box;
    border-radius: 5px;
    margin-bottom: 10px;
    width: 100%
}
.attostylesbox.attostylesbox-solid {
    color: white;
}
.attostylesbox.attostylesbox-outline {
    background-color: white;
    border-width: 2px;
    border-style: solid;
}
.attostylesbox.attostylesbox-callout {
    background-color: white;
    border: 1px solid #eee;
    border-left-width: 5px;
}
.attostylesbox.attostylesbox-solid-blue {
    background-color: #7d9fd3;
}
.attostylesbox.attostylesbox-solid-green {
    background-color: #98ca3e;
}
.attostylesbox.attostylesbox-solid-yellow {
    background-color: #ffcf35;
}
.attostylesbox.attostylesbox-solid-red {
    background-color: #ef4540;
}
.attostylesbox.attostylesbox-solid-black {
    background-color: #3a3a3a;
}
.attostylesbox.attostylesbox-outline-blue {
    border-color: #7d9fd3;
    color: #7d9fd3;
}
.attostylesbox.attostylesbox-outline-green {
    border-color: #98ca3e;
    color: #98ca3e;
}
.attostylesbox.attostylesbox-outline-yellow {
    border-color: #ffcf35;
    color: #ffcf35;
}
.attostylesbox.attostylesbox-outline-red {
    border-color: #ef4540;
    color: #ef4540;
}
.attostylesbox.attostylesbox-outline-black {
    border-color: #3a3a3a;
    color: #3a3a3a;
}
.attostylesbox.attostylesbox-callout-blue {
    border-left-color: #7d9fd3;
}
.attostylesbox.attostylesbox-callout-green {
    border-left-color: #98ca3e;
}
.attostylesbox.attostylesbox-callout-yellow {
    border-left-color: #ffcf35;
}
.attostylesbox.attostylesbox-callout-red {
    border-left-color: #ef4540;
}
.attostylesbox.attostylesbox-callout-black {
    border-left-color: #3a3a3a;
}
.attostylestextmarker {
    border-radius: 5px;
    padding-left: 5px;
    padding-right: 5px;
}
.attostylestextmarker.attostylestextmarker-green {
    background: #99ffcc;
}
.attostylestextmarker.attostylestextmarker-pink {
    background: #ffccff;
}
.attostylestextmarker.attostylestextmarker-yellow {
    background: #ffffcc;
}

2. Configure styles widget

atto_styles will have to know which CSS classes you want to provide in the Atto styles widget and how they should be called in the widget.

Please visit Site administration -> Plugins -> Text editors -> Atto HTML editor -> Styles settings.

There, simply follow the instructions and configure the widget according to your needs.

Here's the configuration which corresponds to the CSS example given above:

[{
    "title": "Red box (solid)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-solid attostylesbox-solid-red",
    "preview": true
},
{
    "title": "Red box (outline)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-outline attostylesbox-outline-red",
    "preview": true
},
{
    "title": "Red box (highlighted)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-callout attostylesbox-callout-red",
    "preview": true
},
{
    "title": "Green box (solid)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-solid attostylesbox-solid-green",
    "preview": true
},
{
    "title": "Green box (outline)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-outline attostylesbox-outline-green",
    "preview": true
},
{
    "title": "Green box (highlighted)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-callout attostylesbox-callout-green",
    "preview": true
},
{
    "title": "Yellow box (solid)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-solid attostylesbox-solid-yellow",
    "preview": true
},
{
    "title": "Yellow box (outline)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-outline attostylesbox-outline-yellow",
    "preview": true
},
{
    "title": "Yellow box (highlighted)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-callout attostylesbox-callout-yellow",
    "preview": true
},
{
    "title": "Blue box (solid)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-solid attostylesbox-solid-blue",
    "preview": true
},
{
    "title": "Blue box (outline)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-outline attostylesbox-outline-blue",
    "preview": true
},
{
    "title": "Blue box (highlighted)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-callout attostylesbox-callout-blue",
    "preview": true
},
{
    "title": "Black box (solid)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-solid attostylesbox-solid-black",
    "preview": true
},
{
    "title": "Black box (outline)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-outline attostylesbox-outline-black",
    "preview": true
},
{
    "title": "Black box (highlighted)",
    "type": "block",
    "classes": "attostylesbox attostylesbox-callout attostylesbox-callout-black",
    "preview": true
},
{
    "title": "Yellow text marker",
    "type": "inline",
    "classes": "attostylestextmarker attostylestextmarker-yellow",
    "preview": true
},
{
    "title": "Green text marker",
    "type": "inline",
    "classes": "attostylestextmarker attostylestextmarker-green",
    "preview": true
},
{
    "title": "Pink text marker",
    "type": "inline",
    "classes": "attostylestextmarker attostylestextmarker-pink",
    "preview": true
}]

3. Add styles widget to Atto toolbar

atto_styles has to be added to the Atto toolbar before it can be used by users.

Please visit Site administration -> Plugins -> Text editors -> Atto HTML editor -> Atto toolbar settings.

There, please add the "styles" keyword to one of the lines in the "editor_atto | toolbar" setting according to your needs.

If you are using a default Atto toolbar, we propose to change "style1 = title, bold, italic" to "style1 = title, styles, bold, italic"

Capabilities

This plugin does not add any additional capabilities.

Multilanguage filter support

Within the styles configuration, a title can support the Moodle multilang filter (if enabled), but additonal double-quotes will need to be escaped with a backslash.

For example:

"title": <span class=\"multilang\" lang=\"en\">Blue box</span><span class=\"multilang\" lang=\"de\">Blaue Box</span>"

Theme support

This plugin is developed and tested on Moodle Core's Boost theme. It should also work with Boost child themes, including Moodle Core's Classic theme. However, we can't support any other theme than Boost.

Plugin repositories

This plugin is published and regularly updated in the Moodle plugins repository: http://moodle.org/plugins/view/atto_styles

The latest development version can be found on Github: https://github.com/moodle-an-hochschulen/moodle-atto_styles

Bug and problem reports / Support requests

This plugin is carefully developed and thoroughly tested, but bugs and problems can always appear.

Please report bugs and problems on Github: https://github.com/moodle-an-hochschulen/moodle-atto_styles/issues

We will do our best to solve your problems, but please note that due to limited resources we can't always provide per-case support.

Feature proposals

Due to limited resources, the functionality of this plugin is primarily implemented for our own local needs and published as-is to the community. We are aware that members of the community will have other needs and would love to see them solved by this plugin.

Please issue feature proposals on Github: https://github.com/moodle-an-hochschulen/moodle-atto_styles/issues

Please create pull requests on Github: https://github.com/moodle-an-hochschulen/moodle-atto_styles/pulls

We are always interested to read about your feature proposals or even get a pull request from you, but please accept that we can handle your issues only as feature proposals and not as feature requests.

Moodle release support

Due to limited resources, this plugin is only maintained for the most recent major release of Moodle as well as the most recent LTS release of Moodle. Bugfixes are backported to the LTS release. However, new features and improvements are not necessarily backported to the LTS release.

Apart from these maintained releases, previous versions of this plugin which work in legacy major releases of Moodle are still available as-is without any further updates in the Moodle Plugins repository.

There may be several weeks after a new major release of Moodle has been published until we can do a compatibility check and fix problems if necessary. If you encounter problems with a new major release of Moodle - or can confirm that this plugin still works with a new major release - please let us know on Github.

If you are running a legacy version of Moodle, but want or need to run the latest version of this plugin, you can get the latest version of the plugin, remove the line starting with $plugin->requires from version.php and use this latest plugin version then on your legacy Moodle. However, please note that you will run this setup completely at your own risk. We can't support this approach in any way and there is an undeniable risk for erratic behavior.

Translating this plugin

This Moodle plugin is shipped with an english language pack only. All translations into other languages must be managed through AMOS (https://lang.moodle.org) by what they will become part of Moodle's official language pack.

As the plugin creator, we manage the translation into german for our own local needs on AMOS. Please contribute your translation into all other languages in AMOS where they will be reviewed by the official language pack maintainers for Moodle.

Right-to-left support

This plugin has not been tested with Moodle's support for right-to-left (RTL) languages. If you want to use this plugin with a RTL language and it doesn't work as-is, you are free to send us a pull request on Github with modifications.

Maintainers

The plugin is maintained by
Moodle an Hochschulen e.V.

Copyright

The copyright of this plugin is held by
Moodle an Hochschulen e.V.

Individual copyrights of individual developers are tracked in PHPDoc comments and Git commits.

Copyright history

This plugin was initially built by
Andrew Davidson
Synergy Learning UK
www.synergy-learning.com

on behalf of
Ulm University
Communication and Information Centre (kiz)

and maintained and published by
Ulm University
Communication and Information Centre (kiz)
Alexander Bias

It was contributed to the Moodle an Hochschulen e.V. plugin catalogue in 2022.

Credits

This Atto plugin was inspired by the custom styles functionality which was present in TinyMCE.

moodle-atto_styles's People

Contributors

abias avatar danowar2k avatar davosmith avatar kathrin84 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

moodle-atto_styles's Issues

Example in the settings page has bad JSON

Example in the settings page has bad JSON:

For example:
{
    "title": "Blue box",
    "type": "block",
    "classes": "box blue"
    "preview": true
}

It also would be nice to have some kind of validation, in case the user inputs invalid JSON

Problem when using multiple classes: only added the first one

Hi, we at ULPGC used this plugin with moodle 3.9 quite happily.
Now we have moodle 4.1, what we see is that the classes defined in config are shown on preview.
But when applied to editor text only the first class in the classes definition is really added. All after the first space is lost
For instance, a definition like
"classes": "badge badge-warning",
only applies
Badge info

whereas
"classes": "badge-warning badge ",
result in text in editor with only
Badge info

The effect is that regular bootstrap classes are missed

Different behaviour in Chrome and FF - tested with Moodle 3.0

Hi,
We love this plugin but we are having issues in FF when pressing return after a style section of text. In Chrome a new block is created but in FF the cursor remains in the styled block and you cannot get out of it unless you already had content below. It makes more sense if you look at the screenshot.
atto

Plans for Grid support?

Hello.
I am curious if there are plans to include ability to build layout (columns and rows) Thank you.

[3.2] No style/undefined?

I set up my install with the CSS and styles widget examples provided in the readme (https://github.com/moodleuulm/moodle-atto_styles/blob/master/README.md) with the CSS pasted into Boost Raw initial SCSS (Site Administration-Appearance-Themes-Boost-Advanced settings) and the styles configuration pasted into the styles settings, and I've added Styles to the Atto toolbar. I have also tried pasting CSS into Boost Raw SCSS as well as the other custom CSS areas available within Themes.

However when I try to edit a page and use Styles this is the result I see:
image

Could you let me know what I may be doing wrong here? Thanks!

Button for inline code

I am using Generico atto filter with prettify bundle to insert large blobs of code.
However, for inlines this is not working. Can you please add an example for adding the code style (or tag) within your framework.
Cheers

Proposal: Option for different element tags

Instead of choosing between block and inline, it would be useful to select the specific type of tag we'd like to use, for instance "p", "small", or "blockquote". This would make it use more Bootstrap styling out of the box as well. My main interest, though, is to get people to use HTML elements properly for better screenreader support and the like, without forcing them to know HTML.

Better example of the configuration

I was thinking that something like the following might work better as the default / example configuration. As many sites are using a bootstrap-based theme, it will immediately work for them without the need to customize their theme.

{
    "title": "Hero unit box",
    "type": "block",
    "classes": "hero-unit"
},{
    "title": "Well",
    "type": "block",
    "classes": "well"
},{
    "title": "Info text",
    "type": "inline",
    "classes": "label label-info"
},{
    "title": "Warning text",
    "type": "inline",
    "classes": "label label-warning"
}

These are just standard CSS class from
http://getbootstrap.com/2.3.2/components.html that I found useful in
these cases.

Can't make it work in the Moodle mobile app

Hello!
We've been using this plugin and it works perfectly, thank you!! However, I just noticed today that the styles are not showing on Moodle mobile app. It looks plain text, with no colors or anything.
Could anybody help me on this, please?
Thank you!
Screenshot0
!

[Moodle 3.9.7] [Firefox] Selecting a block style without focussing the editor first applies the style outside the editor

It seems in Moodle 3.9.7 on Firefox (Chrome and Edge do not have this bug) the document focus isn't set inside the atto editor at the beginning.
When I then select a block style, it is applied outside the editor (e.g. make the page background yellow).

Maybe element = window.getSelection().focusNode; isn't the way to go here? Couldn't you work with the "host" or fetch the "editor"? Or you could doublecheck whether the element is one inside the current editor?

"styles" cannot be used

44dec2d38f769e02d7c579d29df81f44.mp4

Hi, the plugin "styles" cannot be used suddenly. How can I solve this issue>

Please improve documentation in README.md file

Hi,

I translated the English language strings for this plugin into Mexican Spanish in AMOS.

I intended to create a Moodle Docs page in Spanish about this plugin, but I could not get it to work in my local 3.6 server. I am a veterinary pathologist at the largest Mexican University, with no CSS knowledge, like most Moodle teachers.

I think this plugin would greatly improve its usefullness if you could add more detailed documentation, so that a non-programmer reader can actually produce (and use) the five styles illustrated in the screenshot.

Please enclose the text (or a screenshot of it) for the CSS class definitions for Boost.

Please enclose the text for the Styles configuration that will produced the styles shown in the screenshot. I think this text should be used as the actual example in the plugin code.

I think this should not be too difficult nor time consuming for you, but it would greatly help many potential users of this plugin.

Thanks in advance.

Can't get a preview of the styles in Atto

Running Moodle 3.5 and v3.5-r2 of atto styles. The drop-down menu in the Atto editor does not display a preview of the styles. Instead it displays '</> name of style'.

Has the preview function become deprecated?
I have "preview": "true" set for each style in the Styles settings page. However your example code on that page omits this line.

v4.0-r2 does not work in Moodle 4.1

I configured a number of CSS styles and passed valid JSON into the configuration textbox, strictly according to the instructions. This JSON worked under Moodle 3.x

With version 4.0-r2 I'm getting this the moment I try to set a style to a paragraph of text:

image

If is empty "atto_styles | config" crashes javascript, tested in moodle 4.1.1 and atto_styles versión v4.1-r2.

If is empty "atto_styles | config" crashes javascript, tested in moodle 4.1.1 and atto_styles versión v4.1-r2.

yui_combo.php?m/1688989846/atto_table/button/button-min.js&m/1688989846/atto_clear/button/button-min.js&m/1688989846/atto_undo/button/button-min.js&m/1688989846/atto_accessibilitychecker/button/button-min.js&m/1688989846/atto_accessibilityhelper/button/button-min.js&m/1688989846/atto_wiris/button/button-min.js&3.17.2/promise/promise-min.js&m/1688989846/atto_html/beautify/beautify-min.js&m/1688989846/atto_html/codemirror/codemirror-min.js&m/1688989846/atto_html/button/button-min.js&m/1688989846/atto_morefontcolors/button/button-min.js&m/1688989846/atto_fontfamily/button/button-min.js&m/1688989846/atto_morebackcolors/button/button-min.js&m/1688989846/atto_hr/button/button-min.js&m/1688989846/atto_styles/button/button-min.js&m/1688989846/atto_cloze/button/button-min.js&m/1688989846/atto_emojipicker/button/button-min.js:77 Uncaught TypeError: Cannot read properties of null (reading 'type')
    at YUI.<anonymous> (yui_combo.php?m/1688989846/atto_table/button/button-min.js&m/1688989846/atto_clear/button/button-min.js&m/1688989846/atto_undo/button/button-min.js&m/1688989846/atto_accessibilitychecker/button/button-min.js&m/1688989846/atto_accessibilityhelper/button/button-min.js&m/1688989846/atto_wiris/button/button-min.js&3.17.2/promise/promise-min.js&m/1688989846/atto_html/beautify/beautify-min.js&m/1688989846/atto_html/codemirror/codemirror-min.js&m/1688989846/atto_html/button/button-min.js&m/1688989846/atto_morefontcolors/button/button-min.js&m/1688989846/atto_fontfamily/button/button-min.js&m/1688989846/atto_morebackcolors/button/button-min.js&m/1688989846/atto_hr/button/button-min.js&m/1688989846/atto_styles/button/button-min.js&m/1688989846/atto_cloze/button/button-min.js&m/1688989846/atto_emojipicker/button/button-min.js:77:316)
    at Array.forEach (<anonymous>)
    at m.each.m.forEach (yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js:10:1339)
    at n.initializer (yui_combo.php?m/1688989846/atto_table/button/button-min.js&m/1688989846/atto_clear/button/button-min.js&m/1688989846/atto_undo/button/button-min.js&m/1688989846/atto_accessibilitychecker/button/button-min.js&m/1688989846/atto_accessibilityhelper/button/button-min.js&m/1688989846/atto_wiris/button/button-min.js&3.17.2/promise/promise-min.js&m/1688989846/atto_html/beautify/beautify-min.js&m/1688989846/atto_html/codemirror/codemirror-min.js&m/1688989846/atto_html/button/button-min.js&m/1688989846/atto_morefontcolors/button/button-min.js&m/1688989846/atto_fontfamily/button/button-min.js&m/1688989846/atto_morebackcolors/button/button-min.js&m/1688989846/atto_hr/button/button-min.js&m/1688989846/atto_styles/button/button-min.js&m/1688989846/atto_cloze/button/button-min.js&m/1688989846/atto_emojipicker/button/button-min.js:77:230)
    at n._initHierarchy (yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js:279:3762)
    at n._baseInit (yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js:279:1086)
    at n.init (yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js:311:694)
    at n._initBase (yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js:279:948)
    at n.v (yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js:279:95)
    at n.o (yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js:319:50)

Here is a patch to fix in lib.php
lib.php.patch

Quotes not escaping properly in 3.5

Folks, thanks for a really useful plugin. I'm attempting to create a multilang span class using this tool, with this:

{ "title": "LANG: EN", "type": "inline", "classes": "\"multilang\" lang=\"en\"" },

Then when I use the editor, highlight some text, and choose the style I get this:
<span class="&quot;multilang&quot; lang=&quot;en&quot;">TEXT IN ENGLISH</span>

This is obviously not what I wanted to achieve since it would appear the additional quotes aren't being escaped. Could someone point me in the right direction as to what I might be doing wrong?

Feedback with Moodle 3.9.3+ (Build: 20210108)

Hi,

Thank you for the style plugin that we use regularly with great success.
We discovered a bug with this week's version of Moodle 3.9. It is no longer possible to configure the style without modifying the text. We use "v3.8-r2" version of the plugin.

Case 1: added the usual style: JSON error
image

Case 2 : added style with [ and ] > OK
image

Clément

Requires Moodle 3.1

If there were no functionality changes between 6f8c11f and 9805ef0, why does the plugin now require Moodle 3.1? We are currently running 3.0 and would like to be able to use this plugin and any updates until we upgrade to 3.1.

Allow a Second Column of Styles

We love this plug in - unfortunately, we have filled it up already. The list is so long that we cannot scroll down to the bottom. Any way to get the list to appear in two columns instead of one?
list of styles

Adding 2 classes for inline styling fails on Moodle 3.0.x

Hi,

I use this plug-in with 2 Moodle and the same settings to custom CSS classes to block and inline text.

  • With Moodle 2.9.2, everything works well.
  • With Moodle 3.0.2, I discover this bug.
    In "Styles configuration", if I use "inline" with a class in two words with a blank space (example : "h4 myword"), it's impossible to apply the style with Atto.

{ "title": "Title 1", "type": "inline", "classes": "h3 myclass" } = Doesn't work

If I use "inline" with a class in one word (without blank space, example "h4-myword"), I can apply the style with Atto.
{ "title": "Title 1", "type": "inline", "classes": "h3-myclass" } = OK

Best regards.

Move away from YUI

This issue serves as a reminder that this plugin still uses YUI in its JavaScript code.
Currently, I am not aware that you can build atto_* plugins without YUI.
But as soon as Moodle core supports this, this plugin should be adapted.

Styles + Adaptable themee do not work!

When I use adapatable theme in moodle 3.3 the Slytes don`t work.
I use atto and the icons are not visible:
image

I don`t understand, because in other moodle, Styles work good, but with Adaptable no.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.