Code Monkey home page Code Monkey logo

tinymce-variable's People

Contributors

mahammedzkhan avatar sitebase avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

tinymce-variable's Issues

Does this plugin work with the React wrapper and Tiny Cloud hosting?

I've configured it as an external plugin but it never shows in my toolbar

external_plugins: {
'variables': '/plugins/variables/plugin.min.js',
},
toolbar:
'variables',

I'm using the react wrapper provided by Tiny and have created a plugins directory on the public folder. I get no loading errors but never see the plugin.

Any help appreciated.

Last item variable

When the last item in the editor is a variable you can't do space to start typing behind that variable.

Variable popup

Add way so a developer can add custom popup to variables. This can be used for all sorts of functionality:

  • fallback content
  • more information about a variable

screenshot 2016-10-14 12 50 36

Variable mapper callback function

Instead of passing a mapper object it should also be possible to pass a callback function. Because that way we could do the mapping based on for example the same object that's being used to fill up the insert variable dropdown.

screenshot 2015-07-22 10 24 19

Selection styling

When selecting text that includes a variable and set it bold you get the following HTML:

<strong>This is a </strong>{community_name}<strong> test</strong>

The result should look like this:

<strong>This is a {community_name} test</strong>

[Feature request] Sidebar with available variables

I recently found Your plugin, and it does exactly what I need.
There is one thing missing. Recent version of TinyMCE support Sidebar.
Maybe Your plugin can use this API to show list of available variables that can be inserted? This can be a simple list with names, when You click on variable it would get inserted in cursor position.
This would speed thing even more.

Cursor moves to start after every variable entry.

After entering any variable, the cursor location moves to start of the editor. I am giving the function from source code where I believe the issue might stem from:
function stringToHTML()
{
var nodeList = [],
nodeValue,
node,
div;

    // find nodes that contain a string variable
    tinymce.walk(editor.getBody(), function(n) {
        if (n.nodeType == 3 && n.nodeValue && stringVariableRegex.test(n.nodeValue)) {
            nodeList.push(n);
        }
    }, 'childNodes');

    // loop over all nodes that contain a string variable
    for (var i = 0; i < nodeList.length; i++) {
        nodeValue = nodeList[i].nodeValue.replace(stringVariableRegex, createHTMLVariable);
        div = editor.dom.create('div', null, nodeValue);
        while ((node = div.lastChild)) {
            editor.dom.insertAfter(node, nodeList[i]);

            if(isVariable(node)) {
                var next = node.nextSibling;
                editor.selection.setCursorLocation(next);
            }
        }

        editor.dom.remove(nodeList[i]);
    }
}

Specifically I believe the issue arises in this part:
if(isVariable(node)) {
var next = node.nextSibling;
editor.selection.setCursorLocation(next);
}
The next is null which in turn leads to setting the cursor at the start position.

Cancel code view

When you cancel the code view the variables are not back converted to HTML elements.

Support for Array Variable

I'd like to loop through a list of items and display it in a table. Something like this:

<table>
  <thead>
    <tr>
      <th>#</th>
      <th>Name</th>
    </tr>
  </thead>
  <tbody>
   {% for item in items %}
    <tr>
      <td>{{item.id}}</td>
      <td>{{item.name}}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>

How can I implement such? It might also be good to see how one can extend the plugin.

Style is not applied to variables

I've prepared simple demo to show this issue: https://codepen.io/Misiu/pen/vxjQow

I have simple html:

<h1 style="text-align: center;">Hi {{user_name}}, have a nice day!</h1>
<h5 style="text-align: center;">Note, this is not an "enterprise/premium" demo.<br />Visit the <a href="https://www.tinymce.com/pricing/#demo-enterprise">pricing page</a> to demo our premium plugins.</h5>

that is displayed in editor like this:
snap 2017-03-23 at 14 02 24

after applying style (bold) to whole line I get this output:

<h1 style="text-align: center;"><strong>Hi </strong>{{user_name}}<strong>, have a nice day!</strong></h1>
<h5 style="text-align: center;">Note, this is not an "enterprise/premium" demo.<br />Visit the <a href="https://www.tinymce.com/pricing/#demo-enterprise">pricing page</a> to demo our premium plugins.</h5>

and in preview looks like this:
snap 2017-03-23 at 14 04 57

Here is recording showing my steps:
variables_plugin_bug1

As You can see variable in output isn't bolded. Ideally variable should be treated as normal text.

Ho to make it work with Tiny 5?

I've tryed but i find this error in the console:

Uncaught Error: Errors:
Failed path: (toolbarbutton)
Could not find valid strict value for "onAction" in {
"title": "My button",
"text": "Insert variable",
"type": "button"
}

Input object: {
"title": "My button",
"text": "Insert variable",
"type": "button"
}
at theme.min.js:4
at Object.getOrDie (theme.min.js:4)
at theme.min.js:4
at theme.min.js:4
at Object.fold (theme.min.js:4)
at theme.min.js:4
at Object.fold (theme.min.js:4)
at pD (theme.min.js:4)
at theme.min.js:4
at V (theme.min.js:4)

Someone was able to make it work with Tiny new version?

Fix eslint

Make this repo pass our eslint.

Test it with:

npm test

Insert variable

Insert a variable is only converted to HTML element when you focus on the text element.

Better variable elements

If we use a span around each variable where we attach data-content that contains the text you want to use in the WYSIWYG. We can use a content replace using just CSS. This way we don't have to remove/add nodes while switching between visual and source mode. Because once send, the email client doesn't have this special CSS replace resulting in the actual variable value being shown.

POC:
https://jsfiddle.net/sitebase/ymhv33jz/5/

This will also solve some other issues like:
#2

Super Noob question - sorry!

Sorry to be a mega noob on this but;

I think this is exactly what I need for my TinyMCE implementation. However, I can't see any docs on how to include this. This is my first TinyMCE project so I am kinda in the dark. I can see how to add it tothe list of plugins, where do I add the actual plugin source?

Copy paste break variable

When you copy and paste text that contains a variable the contentEditable attribute gets stripped.

HtmlNode Attribute 'contentEditable=false' prevents html node from being modified in editable container

I have found your plugin and have played around a little bit with it and I have found out that
$(variableSpan).attr("contentEditable", "false") does exactly what we need.

It prevents the html node in the editable node from being modified and moves the caret over the html node and deletes it on backspace and delete key.
The only thing you need to do is to add the node via range.insertNode() and not via document.execCommand() (used in the editor source), which behaved very strange in chrome, where html node attributes such as id and class disappeared.
See here: Stackoverflow issue

So it does exactly what your plugin does, except the dynamic provided variables and selection.

Worked for me for me in CLEditor.

Enjoy :)

[Safari] Type variable

In Safari if you manually type in a variable the cursor jumps to the beginning of the editor.

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.