Code Monkey home page Code Monkey logo

grav-plugin-studioeditor's Introduction

Grav Studio Editor Plugin

If you encounter any issues, please don't hesitate to report them.

Screenshot

The Studio Editor Plugin for Grav provides an advanced markdown editor with live preview and support for extended markdown features like alignment, notices, etc. StudioEditor makes Markdown more accessible and transparent closing the gap to WYSIWYG editors as the writer disposes of a preview which shows how his or her markdown translates and visualizes from text into and as html. The plugin allows to activate some nice extra features, e.g. if you use webp plugin the plugin will automatically replace calls to jpg and png files to the corresponding webp version if they exist without using redirection, another great feature is the possibility to drag'n'drop images from the upload area right into the editor instance like within the standard editor.

📌 Studio Editor is completely unobtrusive which means that you can return to use the build-in editor options at any time.

Please be advised that some of the features, like MathJax haven't been retested for this public release. This may apply to other features as well. What's definitely working out of the box is what you expect to work: editing standard and enhanced markdown. Or why not editing the summary if it uses the default separator (===) directly within the editor without activating expert mode?

Installation

Installing the Studioeditor plugin can be done in one of three ways:

  • GPM (Grav Package Manager)
  • manual method
  • admin method

GPM Installation (Preferred)

To install the plugin via the GPM, through your system's terminal (also called the command line), navigate to the root of your Grav-installation, and enter:

bin/gpm install studioeditor

This will install the Studioeditor plugin into your /user/plugins-directory within Grav. Its files can be found under /your/site/grav/user/plugins/studioeditor.

Manual Installation

To install the plugin manually, download the zip-version of this repository and unzip it under /your/site/grav/user/plugins. Then rename the folder to studioeditor. You can find these files on GitHub or via GetGrav.org.

You should now have all the plugin files under

/your/site/grav/user/plugins/studioeditor

NOTE: This plugin is a modular component for Grav which may require other plugins to operate, please see its blueprints.yaml-file on GitHub.

Admin Plugin

If you use the Admin Plugin, you can install the plugin directly by browsing the Plugins-menu and clicking on the Add button.

Requirements

Make sure that you have installed and enabled the following for studioeditor support:

  • enable GD and configure PHP to enable support for image processing

Configuration

As Studioeditor requires the Admin plugin you should use Admin to maintain the configuration for Studioeditor.

Credits

Carlos Mújica, an artist from Colombia for his artwork and my gratitude for offering me some of his works. As a gift in return I offered him a website and thought: let's do it with GRAV. Without him Studioeditor wouldn't have been released to the wild... Probably I wouldn't have thought of GRAV if I'd been aware of the trouble of updating old shit...

GRAV This plugin wouldn't exist without the great work behind, thanks a lot.

StackEdit This plugin wouldn't exist also without StackEdit, the current version (v5.x) of StackEdit uses Markdown-it, but the version used within StudioEditor is based on v4.x versions. Future versions of StudioEdit will use Markdown-it as well.

Important

Despite having been reviewed and found error free, this plugin was developed many years ago and uses javascript packages that haven't been updated for a long time. As this plugin is used in the back-end, inside of Admin, without any exposure on the front-end, the risk of possible security problems related, if they exist, is minimal to none as access to the admin is restricted to authorized users. If the plugin gains some popularity, we'll address this problem by updating and substituting javascript packages.

Collaboration

I'm looking out for collaborators even owners for this plugin. Feel free to ask if you feel comfortable with the ToDos'...

ToDo

  • Clean code base getting rid of tons of files not used
  • Update underlying code base as many of the libs are quite old
  • Enhance support of configuration options for the editor instance directly from Admin
  • Implement additional markdown features
  • Implement state of the art markdown parser like Markdown-it

grav-plugin-studioeditor's People

Contributors

leotiger avatar

Stargazers

 avatar  avatar pmoreno.rodriguez avatar Hugh Barnes avatar

grav-plugin-studioeditor's Issues

Image sizes removal from the congfig is not persisted.

There are 5 sizes defined in the yaml file. From the config page I have updated 3 of them and removed 2. It works first time I enter the page in edit mode. But next time it falls back to 5 sizes: keeping my 3 sizes values and adding back 2 removed.

Feature request: Custom image tag template

in studioeditor.js this code is managing the content of the image tag:

                        if (location.pathname.indexOf('admin/pages') != -1) {
                            filename = location.pathname.replace("/admin/pages/", '/') + '/' + encodeURI(filename) + '?sizes=80vs;
                        }

my suggestion is to replace it with just

                        filename = encodeURI(filename) + '?<configurable value>;

In current implementation images are added with the full path and it would break if the page is moved under a different parent.

Strange renames for Images with capital JPG extensions

I am getting these info messages

$this->grav['admin']->setMessage("$filename and derivates renamed to $newfilename." . strtolower($info['extension']), 'info');

When I save page second time after uploading an image. And only for capital JPG extensions (that is produced natively by my photo cameras)
The problem that after rename I see duplicate images with different names and sizes that is kind of inconvenient

No editor field showing after basic installation

I thought I'd give you my experience after installing. I thought this problem may have been Firefox-only but I just reproduced it in a Chromium browser too.

So I installed base Grav (latest, latest PHP:8.3.6), git pulled this plugin, and then installed Admin using bin/gpm install admin, which required Flex Objects, Form, Email etc.

I noticed this in your README, but it references a section for more details that isn't there (my emphasis):

The plugin at it's current state has issues with the Flex Objects plugin. To access the Flex Objects plugin configuration you have to dissable the Studio Editor plugin and reactivate it after touching the Flex Objects configuration. Please have a look at the issues section below for more information.

I decided to try to guess what was required. I disabled the plugin for my environment. Refreshed an Admin page. Then to "touch" Flex Objects, I added an environment configuration for it (at user/env/dev/config/plugins/flex-objects.yaml) and just added enabled: true in it. I figured that would cause a recheck but make no difference to its configuration. Then I enabled StudioEditor again.

Here's what I see in the default 'Typography' page:

image

The JS error in the browser console:

Console error
17:17:12.439 Uncaught Error: Script error for: yaml-js
http://requirejs.org/docs/errors.html#scripterror
    makeError https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:166
    onScriptError https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1689
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1891
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1647
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:828
    fetch https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:814
    bind https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:132
    execCb https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1658
    check https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:874
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1151
    init https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:782
    localRequire https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1424
    setTimeout handler*req.nextTick< https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1763
    localRequire https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1413
    fetch https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:813
    check https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:848
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1151
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1519
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1136
    bind https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:132
    each https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:57
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1098
    init https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:782
    callGetModule https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1178
    completeLoad https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1552
    onScriptLoad https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1679
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1890
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1647
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:828
    fetch https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:818
    check https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:848
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1151
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1519
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1136
    bind https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:132
    each https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:57
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1098
    init https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:782
    callGetModule https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1178
    completeLoad https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1552
    onScriptLoad https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1679
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1890
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1647
    load https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:828
    fetch https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:818
    check https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:848
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1151
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1519
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1136
    bind https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:132
    each https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:57
    enable https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1098
    init https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:782
    localRequire https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1424
    setTimeout handler*req.nextTick< https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1763
    localRequire https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1413
    requirejs https://studioeditor.localhost/user/plugins/studioeditor/assets/res/require.js:1745
    <anonymous> https://studioeditor.localhost/user/plugins/studioeditor/assets/res/main.js:190
require.js:166:17

I also got this in the console before the error above: 17:17:12.439 The resource from “https://studioeditor.localhost/user/plugins/studioeditor/assets/res/bower-libs/yaml.js/bin/yaml.js” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). typography. Maybe you or the plugin or Grav is simply not serving the right content type for the script and my settings are more strict than yours??

Here's the markdown from inspector around where the editor field should be:

editorContainer
<div id="editorContainer" class="form-field ">
	<div id="wmd-panel" class="wmd-panel grav-editor-content is-active">
		<div class="layout-wrapper-l1">
			<div class="layout-wrapper-l2">
				<div class="navbar navbar-default">
					<div class="navbar-inner">
						<div class="nav left-space"></div>
						<div class="nav right-space pull-right"></div>
						<div class="buttons-dropdown dropdown hide">
							<div class="nav">
								<button class="btn btn-success" data-toggle="dropdown" title="Show buttons">
									<i class="icon-th-large"></i>
								</button>
								<div class="dropdown-menu">
								</div>
							</div>
						</div>
						<ul class="nav left-buttons">
							<li class="wmd-button-group1 btn-group"></li>
						</ul>
						<ul class="nav left-buttons">
							<li class="wmd-button-group2 btn-group"></li>
						</ul>
						<ul class="nav left-buttons">
							<li class="wmd-button-group3 btn-group"></li>
						</ul>
						<ul class="nav left-buttons">
							<li class="wmd-button-group5 btn-group"></li>
						</ul>
						<ul class="nav left-buttons">
							<li class="studio-editor-button-help"><a class="hint--bottom-left btn btn-success" data-hint="Markdown Syntax"><i class="icon-help-circled"></i></a></li>
						</ul>
						<ul class="nav left-buttons">
						
							<li class="studio-editor-button-fullscreen"><a class="hint--bottom-left btn btn-success" data-hint="Fullscreen"><i class="icon-resize-full"></i></a></li>
							<!--
							<li class="wmd-button-group4 btn-group">
							
								<a class="btn btn-success button-open-discussion" title="Comments Ctrl/Cmd+M"><i class="icon-comment-alt"></i></a>
							</li>
							-->
						</ul>
						<ul class="nav pull-right right-buttons">
							<li class="offline-status hide">
								<div class="text-danger">
									<i class="icon-attention-circled"></i>offline
								</div>
							</li>
							<li class="extension-buttons" style="display:none"></li>
						</ul>
						<ul class="nav pull-right title-container">
							<li><a href="#" class="action-body-document hint--bottom-left" data-hint="Main document"><i class="icon-file"></i><span class="document-part-label"> Main</span></a></li>
                                                                      <!--
							<li><a href="#" class="action-intro-document hint--bottom-left" data-hint="Document introduction"><i
									class="icon-file"></i><span class="document-part-label"> Intro</span></a></li>
                                                                      -->
							<li><a href="#" class="action-summary-document hint--bottom-left" data-hint="Document summary"><i class="icon-file"></i><span class="document-part-label"> Summary</span></a></li>
						
							<li class="hide"><div class="working-indicator"></div></li>
							<li class="hide"><a class="btn btn-success file-title-navbar" href="#" title="Rename document"> </a></li>
							<li class="hide"><div class="input-file-title-container"><input type="text" class="col-sm-4 form-control hide input-file-title" placeholder="Document title"></div></li>
						</ul>
					</div>
				</div>
				<div class="layout-wrapper-l3">
					<textarea data-grav-seditor="{&quot;codemirror&quot;:{&quot;spellcheck&quot;:&quot;true&quot;,&quot;mode&quot;:&quot;gfm&quot;,&quot;ignore&quot;:[&quot;code&quot;,&quot;preview&quot;]}}" data-grav-seditor-mode="view" name="data[content]" id="wmd-input-store" class=" hide">! Details on the full capabilities of Spectre.css can be found in the [Official Spectre Documentation](https://picturepan2.github.io/spectre/elements.html)

The [Quark theme](https://github.com/getgrav/grav-theme-quark) is the new default theme for Grav built with [Spectre.css](https://picturepan2.github.io/spectre/) the lightweight, responsive and modern CSS framework. Spectre provides  basic styles for typography, elements, and a responsive layout system that utilizes best practices and consistent language design.

(... and all the other content)

                                                  </textarea>
							<textarea id="wmd-summary-store" class="hide"></textarea>
							<textarea id="wmd-intro-store" class="hide"></textarea>
							<textarea id="wmd-body-store" class="hide"></textarea>
						
							<pre id="wmd-input" class="form-control" lang=""><div class="editor-content" contenteditable="true"></div><div class="editor-margin"></div></pre>
							<div class="preview-panel">
								<div class="layout-resizer layout-resizer-preview"></div>
								<div class="layout-toggler layout-toggler-navbar btn btn-info hide" title="Toggle navigation bar"><i class="icon-th"></i></div>
								<div class="layout-toggler layout-toggler-preview btn btn-info" title="Toggle preview"><i class="icon-none"></i></div>
								<div class="preview-container">
                                                                                                                                                                                                            <div id="preview-contents" data-mediapath="">
                                                                        <div id="wmd-preview" class="preview-content"></div>
                                                                    </div>
								</div>
							</div>
						</div>
						<!--
						<div class="extension-preview-buttons">
							<div class="btn-group drag-me" title="Drag me!">
								<i class="icon-ellipsis-vert"></i>
							</div>
						</div>
						-->
					</div>
					<div id="wmd-button-bar" class="hide"></div>
					<div id="wmd-extra-buttons" class="hide">                                            
                                            <!--
                                            <ul>						
                                                <li class="wmd-buttons"><a id="wmd-table-button" class="hint--bottom btn btn-success" data-hint="Insert table"><i class="icon-table"></i></a></li>
                                            </ul>
                                            -->
                                        </div>
					<div class="menu-panel">
					</div>
					<div class="document-panel">
					</div>
                                        <div class="config-panel">
                                            <textarea class="hide" id="textarea-shortcuts-mapping"></textarea>
                                        </div>
					<div id="modalcontainer">
					</div>
					
				</div>
			</div>
		</div>
		<div id="studio-media-collector-full"></div>
                <div style="position:absolute;right:6px;width:fit-content">                    
                    <div class="extension-preview-buttons" style="position:relative">
                            <div class="btn-group drag-me" title="Drag me!">
                                    <i class="icon-ellipsis-vert"></i>
                            </div>
                    </div>
                </div>

Hope you can make sense of all that! Thanks.

Button labels

Localisation file looks correct, but in the page edit screen I still see this:
image

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.