Home

Awesome

TinyVision

A visual file selector for TinyMCE v4.

Out of the box, selecting files in TinyMCE is a rudimentary experience. You can either enter a URL into a free-form text field or select the name of a file from a drop-down list. On the other end of the spectrum, plugins like MoxieManager provide everything and the kitchen sink to be your one-and-only file manager, requiring access to a file system and being server-side language-specific. TinyVision is different. It's purposely crafted to provide the best experience selecting files visually. Not uploading or editing, removing red eye or adding borders. Just selecting. TinyVision works purely with JSON, and files can be stored anywhere that's URL accessible. We think you'll find it delightful.

Developed by Monk Development for the Ekklesia 360 CMS.

Download

Head over to the releases and download a production-ready tinyvision.zip package. Unzip to your TinyMCE plugins directory (or wherever you store TinyMCE plugins).

Usage

After downloading TinyVision, add it to your TinyMCE config and setup a source endpoint that returns the files to display.

TinyMCE config

Configuring TinyMCE to use TinyVision is simple: add tinyvision to the list of plugins (or external_plugins if stored outside of the TinyMCE directory) and a tinyvision object with TinyVision-specific options:

tinymce.init({
  plugins: 'tinyvision',
  tinyvision: {
    source: '/path/to/your/source.php'
  }
});

See below for the complete list of options.

source endpoint

The source option you see above points to an endpoint that TinyVision requests for the list of files to display. You need to build out this endpoint to return JSON in the following format:

[
  {
    "imageUrl": "/assets/images/breaking_bad_thumb.png",
    "name": "Breaking Bad",
    "value": "/assets/images/breaking_bad.png"
  },
  {
    "imageUrl": "/assets/images/the_newsroom_thumb.png",
    "name": "The Newsroom",
    "value": "/assets/images/the_newsroom.png"
  },
  {
    "imageUrl": "http://external-cdn.com/a1b2c3/homeland_thumb.png",
    "name": "Homeland",
    "value": "http://external-cdn.com/a1b2c3/homeland.png"
  }
]

Alternatively, the array of objects can be embedded in a data field:

{
  "data": [...]
}

Each object represents a file and should contain three values:

Options

Command

While TinyVision registers itself as the default file browser through TinyMCE's file_browser_callback option, it can also be opened programmatically. This is particularly useful for custom TinyMCE plugins to use TinyVision. For example:

editor.execCommand('tinyvision', {
  fieldId: 'imageUrl',
  fieldValue: document.getElementById('imageUrl').value,
  type: 'image',
  win: myPluginWindow
});

This opens TinyVision and configures it to populate the imageUrl field in myPluginWindow with the selected value. There are four required config options:

Development

TinyVision requires Node.js and npm for development. Grunt is used for the build system, and Bower for front-end package management.

Install development dependencies using npm:

npm install

To build, run Grunt:

grunt

During development, keep Grunt watching to automatically build on changes:

grunt watch

It's also helpful, during development, to symlink the build directory into your project's TinyMCE plugins directory to see your work in real-time.

Feedback

Please open an issue to request a feature, submit a bug report, or provide feedback. We'd love to hear from you!

Contributing

  1. Fork it.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Added some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create a new Pull Request.