-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from FloAppsLtd/redactor-x
Added Redactor X support
- Loading branch information
Showing
15 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
Dmitry Mukhin <[email protected]> | ||
Fabien Franzen <[email protected]> | ||
Jason Pirkey <[email protected]> | ||
Karel Vasicek <[email protected]> | ||
Tim Kleier <[email protected]> | ||
Timon van Spronsen <[email protected]> | ||
Andy Abgottspon <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import $RX from 'RedactorX' | ||
|
||
export default function addPlugin(pluginBody) { | ||
$RX.add('plugin', 'uploadcare', pluginBody) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function broadcast(eventName) { | ||
this.app.broadcast(eventName, Array.prototype.slice.call(arguments)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function getSelection() { | ||
return this.app.selection | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import $RX from 'RedactorX' | ||
|
||
export default function getVersion() { | ||
if (typeof $RX !== 'undefined') { | ||
return 'X' + $RX.version | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export {default as broadcast} from './broadcast' | ||
export {default as init} from './init' | ||
export {default as insertHtml} from './insertHtml' | ||
export {default as getSelection} from './getSelection' | ||
export {default as start} from './start' | ||
export {default as getVersion} from './getVersion' | ||
export {default as addPlugin} from './addPlugin' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import loadWidget from '../common/loadWidget' | ||
import normalizeOptions from '../common/normalizeOptions' | ||
import applyIntegrationOption from '../common/applyIntegrationOption' | ||
|
||
export default function() { | ||
this.redactorOpts = this.app.opts | ||
|
||
normalizeOptions.call(this) | ||
loadWidget.call(this) | ||
applyIntegrationOption.call(this) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import getFileUrl from '../common/getFileUrl' | ||
|
||
export default function insertHtml(plugin, fileInfo) { | ||
var fileUrl = getFileUrl(fileInfo) | ||
|
||
if (fileInfo.isImage) { | ||
var openTag = plugin.ucOpts.imageTag ? '<' + plugin.ucOpts.imageTag + '>' : '' | ||
var closeTag = plugin.ucOpts.imageTag ? '</' + plugin.ucOpts.imageTag + '>' : '' | ||
|
||
plugin.app.insertion.insertHtml( | ||
openTag + | ||
'<img src="' + | ||
fileUrl + | ||
'" alt="' + | ||
fileInfo.name + | ||
'" data-image="' + | ||
fileInfo.uuid + | ||
'" />' + | ||
closeTag | ||
) | ||
} | ||
else { | ||
plugin.app.insertion.insertHtml('<a href="' + fileUrl + '" data-file="' + fileInfo.uuid + '">' + fileInfo.name + '</a>') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export default function start() { | ||
var buttonIcon = this.ucOpts.buttonIcon ? this.ucOpts.buttonIcon : 'rx-icon-file', | ||
buttonBar = this.ucOpts.buttonBar ? this.ucOpts.buttonBar : 'toolbar', | ||
buttonData = { | ||
title: this.ucOpts.buttonLabel || 'Uploadcare', | ||
command: 'uploadcare.show', | ||
}; | ||
|
||
if (this.ucOpts.buttonBefore) { | ||
buttonData.position = { before: this.ucOpts.buttonBefore } | ||
} | ||
|
||
if (this.ucOpts.buttonIconEnabled) { | ||
buttonData.icon = (buttonIcon.indexOf('<svg') === -1) ? '<i class="' + buttonIcon + '"></i>' : buttonIcon; | ||
} | ||
|
||
this.app[buttonBar].add('uploadcare', buttonData) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import * as redactorX from './redactorX/index' | ||
import * as redactor3 from './redactor3/index' | ||
import * as redactor2 from './redactor2/index' | ||
|
||
var wrappers = redactor3.getVersion() ? redactor3 : redactor2 | ||
var wrappers = redactorX.getVersion() ? redactorX : (redactor3.getVersion() ? redactor3 : redactor2) | ||
|
||
export default wrappers |