Permalink
Browse files

Merge pull request #619 from Orckestra/feature-visual-editor-search-r…

…eplace

Feature: visual editor + code editor search/replace by @peterpde
  • Loading branch information...
mawtex committed Sep 3, 2018
2 parents ed1a0d9 + c32918e commit 719e3b73cafb29d082f35b2da3f5aeeb148776d2
Showing with 1,015 additions and 9 deletions.
  1. +119 −0 .../content/misc/editors/codemirroreditor/bindings/SourceEditorFindAndReplaceToolBarButtonBinding.js
  2. +96 −0 .../content/misc/editors/codemirroreditor/bindings/SourceEditorToggleWordWrapToolbarButtonBinding.js
  3. +1 −0 Website/Composite/content/misc/editors/codemirroreditor/codemirror.aspx
  4. +10 −3 Website/Composite/content/misc/editors/codemirroreditor/codemirror.js
  5. +8 −0 Website/Composite/content/misc/editors/codemirroreditor/codemirroreditor.aspx
  6. +90 −0 Website/Composite/content/misc/editors/codemirroreditor/codemirrorfindandreplace.aspx
  7. +218 −0 Website/Composite/content/misc/editors/codemirroreditor/codemirrorfindandreplace.js
  8. +2 −1 Website/Composite/content/misc/editors/visualeditor/includes/toolbarsimple.inc
  9. +241 −0 ...ent/misc/editors/visualeditor/tinymce/plugins/compositesearchandreplace/VisualSearchAndReplace.js
  10. +88 −0 ...mposite/content/misc/editors/visualeditor/tinymce/plugins/compositesearchandreplace/plugin.min.js
  11. +107 −0 ...t/misc/editors/visualeditor/tinymce/plugins/compositesearchandreplace/visualsearchandreplace.aspx
  12. +1 −0 Website/Composite/content/misc/editors/visualeditor/tinymce/plugins/searchreplace/plugin.min.js
  13. +1 −1 Website/Composite/content/misc/editors/visualeditor/visualeditor.js
  14. +14 −0 Website/Composite/localization/Composite.Web.SourceEditor.en-us.xml
  15. +15 −1 Website/Composite/localization/Composite.Web.VisualEditor.en-us.xml
  16. +4 −3 Website/gruntfile.js
@@ -0,0 +1,119 @@
SourceEditorFindAndReplaceToolBarButtonBinding.prototype = new EditorToolBarButtonBinding;
SourceEditorFindAndReplaceToolBarButtonBinding.prototype.constructor = SourceEditorFindAndReplaceToolBarButtonBinding;
SourceEditorFindAndReplaceToolBarButtonBinding.superclass = EditorToolBarButtonBinding.prototype;
/**
* @class
*/
function SourceEditorFindAndReplaceToolBarButtonBinding() {
/**
* @type {SystemLogger}
*/
this.logger = SystemLogger.getLogger("SourceEditorFindAndReplaceToolBarButtonBinding");
/**
* The containing editor.
* @type {SourceEditorBinding}
*/
this._editorBinding = null;
/**
* The codemirror editor.
* @type {Codemirror}
*/
this._codemirrorEditor = null;
/*
* Returnable.
*/
return this;
}
/**
* Identifies binding.
*/
SourceEditorFindAndReplaceToolBarButtonBinding.prototype.toString = function() {
return "[SourceEditorFindAndReplaceToolBarButtonBinding]";
};
/**
* @overloads {EditorToolBarBinding#onBindingAttach}
*/
SourceEditorFindAndReplaceToolBarButtonBinding.prototype.onBindingAttach = function() {
SourceEditorFindAndReplaceToolBarButtonBinding.superclass.onBindingAttach.call(this);
var codemirrorwindow = this.bindingWindow.bindingMap.codemirrorwindow;
EditorBinding.registerComponent(this, codemirrorwindow);
};
/**
* @implements {IWysiwygEditorComponent}
* @param {CodemirrorEditorBinding} binding
* @param {Codemirror} editor
*/
SourceEditorFindAndReplaceToolBarButtonBinding.prototype.initializeSourceEditorComponent = function(binding, editor) {
this._editorBinding = binding;
this._codemirrorEditor = editor;
var self = this;
this._codemirrorEditor.addKeyMap({
"Ctrl-F": function () {
self.openDialog(self);
}
});
this._codemirrorEditor.addKeyMap({
"Cmd-F": function () {
self.openDialog(self);
}
});
};
/**
* Open find and replace dialog and wait for input.
* @overwrites {ToolBarButtonBinding#onCommand}
*/
SourceEditorFindAndReplaceToolBarButtonBinding.prototype.oncommand = function() {
this.openDialog(this);
};
SourceEditorFindAndReplaceToolBarButtonBinding.prototype.openDialog = function (self) {
var handler = {
handleDialogResponse: function (response, result) {
}
};
var args = { editor: this._codemirrorEditor };
Dialog.invokeModal("${root}/content/misc/editors/codemirroreditor/codemirrorfindandreplace.aspx", handler, args);
}
/**
* This has been isolated so that the contextmenu can invoke it.
* @param {string} cmd
* @param {string} gui
* @param {string} val
*/
SourceEditorFindAndReplaceToolBarButtonBinding.prototype.handleCommand = function(cmd, gui, val) {
this.oncommand();
};
/**
* @param {string} string
* @param {string} token
* @return {string}
*/
SourceEditorFindAndReplaceToolBarButtonBinding.prototype._getStartString = function(string, token) {
var result = null;
if (string.indexOf(token) > -1) {
result = string.substring(0, string.indexOf(token));
}
return result;
};
@@ -0,0 +1,96 @@
SourceEditorToggleWordWrapToolbarButtonBinding.prototype = new EditorToolBarButtonBinding;
SourceEditorToggleWordWrapToolbarButtonBinding.prototype.constructor = SourceEditorToggleWordWrapToolbarButtonBinding;
SourceEditorToggleWordWrapToolbarButtonBinding.superclass = EditorToolBarButtonBinding.prototype;
/**
* @class
*/
function SourceEditorToggleWordWrapToolbarButtonBinding () {
/**
* @type {SystemLogger}
*/
this.logger = SystemLogger.getLogger ( "SourceEditorToggleWordWrapToolbarButtonBinding" );
/**
* The containing editor.
* @type {SourceEditorBinding}
*/
this._editorBinding = null;
/**
* The codemirror editor.
* @type {Codemirror}
*/
this._codemirrorEditor = null;
/*
* Returnable.
*/
return this;
}
/**
* Identifies binding.
*/
SourceEditorToggleWordWrapToolbarButtonBinding.prototype.toString = function () {
return "[SourceEditorToggleWordWrapToolbarButtonBinding]";
}
/**
* @overloads {EditorToolBarBinding#onBindingAttach}
*/
SourceEditorToggleWordWrapToolbarButtonBinding.prototype.onBindingAttach = function () {
SourceEditorToggleWordWrapToolbarButtonBinding.superclass.onBindingAttach.call ( this );
var codemirrorwindow = this.bindingWindow.bindingMap.codemirrorwindow;
EditorBinding.registerComponent ( this, codemirrorwindow );
}
/**
* @implements {IWysiwygEditorComponent}
* @param {CodemirrorEditorBinding} binding
* @param {Codemirror} editor
*/
SourceEditorToggleWordWrapToolbarButtonBinding.prototype.initializeSourceEditorComponent = function ( binding, editor ) {
this._editorBinding = binding;
this._codemirrorEditor = editor;
}
/**
*
* @overwrites {ToolBarButtonBinding#onCommand}
*/
SourceEditorToggleWordWrapToolbarButtonBinding.prototype.oncommand = function () {
var self = this;
this._codemirrorEditor.setOption("lineWrapping", !this._codemirrorEditor.getOption("lineWrapping"));
localStorage.setItem("lineWrapping", this._codemirrorEditor.getOption("lineWrapping"));
}
/**
* This has been isolated so that the contextmenu can invoke it.
* @param {string} cmd
* @param {string} gui
* @param {string} val
*/
SourceEditorToggleWordWrapToolbarButtonBinding.prototype.handleCommand = function ( cmd, gui, val ) {
this.oncommand ();
}
/**
* @param {string} string
* @param {string} token
* @return {string}
*/
SourceEditorToggleWordWrapToolbarButtonBinding.prototype._getStartString = function ( string, token ) {
var result = null;
if ( string.indexOf ( token ) > -1 ) {
result = string.substring ( 0, string.indexOf ( token ));
}
return result;
}
@@ -9,6 +9,7 @@
top.Application.declareTopLocal(window);
</script>
<script type="text/javascript" src="../../../../lib/codemirror/lib/codemirror.js"></script>
<script type="text/javascript" src="../../../../lib/codemirror/addon/search/searchcursor.js"></script>
<script type="text/javascript" src="../../../../lib/codemirror/mode/xml/xml.js"></script>
<script type="text/javascript" src="../../../../lib/codemirror/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="../../../../lib/codemirror/mode/css/css.js"></script>
@@ -9,9 +9,16 @@ window.onload = function () {
indentUnit: 4,
indentWithTabs: true,
extraKeys: {"Tab": "indentMore", "Shift-Tab": "indentLess"},
lineNumbers: true,
theme: "composite"
});
lineNumbers: true,
theme: "composite",
lineWrapping: false
});
if (localStorage.getItem("lineWrapping") == null) {
editor.setOption("lineWrapping", true);
} else {
editor.setOption("lineWrapping", localStorage.getItem("lineWrapping") === 'true');
}
var broadcaster = top.EventBroadcaster;
var messages = top.BroadcastMessages;
@@ -14,6 +14,8 @@ xmlns:control="http://www.composite.net/ns/uicontrol">
<script type="text/javascript" src="bindings/SourceEditorToolBarBinding.js"></script>
<script type="text/javascript" src="bindings/SourceEditorInsertToolbarButtonBinding.js"></script>
<script type="text/javascript" src="bindings/SourceEditorFormatToolbarButtonBinding.js"></script>
<script type="text/javascript" src="bindings/SourceEditorFindAndReplaceToolBarButtonBinding.js" ></script>
<script type="text/javascript" src="bindings/SourceEditorToggleWordWrapToolbarButtonBinding.js" ></script>
</head>
<body>
<ui:broadcasterset>
@@ -53,6 +55,12 @@ xmlns:control="http://www.composite.net/ns/uicontrol">
<ui:toolbarbutton id="formatbutton" label="${string:Composite.Web.SourceEditor:Toolbar.Format.Label}" tooltip="${string:Composite.Web.SourceEditor:Toolbar.Format.ToolTip}" image="${icon:editor-formatsource}"
image-disabled="${icon:editor-formatsource-disabled}" observes="broadcasterIsActive"
binding="SourceEditorFormatToolbarButtonBinding" />
<ui:toolbarbutton id="wordwrapbutton" label="${string:Composite.Web.SourceEditor:Toolbar.ToggleWordWrap.Label}" tooltip="" image="${icon:editor-formatsource}"
image-disabled="${icon:editor-formatsource-disabled}" observes="broadcasterIsActive"
binding="SourceEditorToggleWordWrapToolbarButtonBinding" />
<ui:toolbarbutton id="findandreplacebutton" label="${string:Composite.Web.SourceEditor:Toolbar.FindAndReplace.Label}" tooltip="" image="${icon:editor-formatsource}"
image-disabled="${icon:editor-formatsource-disabled}" observes="broadcasterIsActive"
binding="SourceEditorFindAndReplaceToolBarButtonBinding" />
</ui:toolbargroup>
</ui:toolbarbody>
<ui:toolbarbody align="right">
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://www.w3.org/1999/xhtml" xmlns:control="http://www.composite.net/ns/uicontrol">
<control:httpheaders ID="Httpheaders1" runat="server"/>
<head>
<title>${string:Composite.Web.SourceEditor:FindAndReplace.LabelTitle}</title>
<control:styleloader ID="Styleloader1" runat="server"/>
<control:scriptloader ID="Scriptloader1" type="sub" runat="server"/>
<script src="codemirrorfindandreplace.js" type="text/javascript"></script>
<style>
@namespace ui url(http://www.w3.org/1999/xhtml);
.checkBoxSettings {
float: left;
}
.left-label {
float: left;
margin-right: 20px;
width: 100px;
}
.checkBoxSettings ui|datalabeltext {
color:#999 !important;
}
ui|checkbox {
}
</style>
</head>
<body>
<div>
<ui:broadcasterset>
<ui:broadcaster id="broadcasterFindNext" isdisabled="false"/>
<ui:broadcaster id="broadcasterReplace" isdisabled="false"/>
<ui:broadcaster id="broadcasterReplaceAll" isdisabled="false"/>
</ui:broadcasterset>
<ui:dialogpage label="${string:Composite.Web.SourceEditor:FindAndReplace.LabelTitle}" image="${icon:composite}" height="auto" resizable="false" binding="CodemirrorFindAndReplace">
<ui:pagebody>
<ui:flexbox>
<ui:fields>
<ui:fieldgroup>
<ui:field>
<ui:fielddesc class="left-label" label="${string:Composite.Web.SourceEditor:FindAndReplace.LabelFind}"/>
<ui:fielddata>
<ui:datainput id="searchFor" default="true">
</ui:datainput>
</ui:fielddata>
</ui:field>
<ui:field>
<ui:fielddesc class="left-label" label="${string:Composite.Web.SourceEditor:FindAndReplace.LabelReplaceWith}"/>
<ui:fielddata>
<ui:datainput id="replaceWith"></ui:datainput>
</ui:fielddata>
</ui:field>
</ui:fieldgroup>
</ui:fields>
<div>
<div class="checkBoxSettings">
<ui:field>
<ui:fielddata>
<ui:checkbox label="${string:Composite.Web.SourceEditor:FindAndReplace.LabelWholeWords}" id="matchWholeWord"></ui:checkbox>
</ui:fielddata>
</ui:field>
</div>
<div class="checkBoxSettings">
<ui:field>
<ui:fielddata>
<ui:checkbox label="${string:Composite.Web.SourceEditor:FindAndReplace.LabelMatchCase}" id="matchCase"></ui:checkbox>
</ui:fielddata>
</ui:field>
</div>
</div>
</ui:flexbox>
</ui:pagebody>
<ui:dialogtoolbar>
<ui:toolbarbody align="right" equalsize="true">
<ui:toolbargroup>
<ui:clickbutton id="buttonFindNext" label="${string:Composite.Web.SourceEditor:FindAndReplace.ButtonFind}" focusable="true" observes="broadcasterFindNext" />
<ui:clickbutton id="buttonReplace" label="${string:Composite.Web.SourceEditor:FindAndReplace.ButtonReplace}" focusable="true" observes="broadcasterReplace" />
<ui:clickbutton id="buttonReplaceAll" label="${string:Composite.Web.SourceEditor:FindAndReplace.ButtonReplaceAll}" focusable="true" observes="broadcasterReplaceAll"/>
</ui:toolbargroup>
</ui:toolbarbody>
</ui:dialogtoolbar>
</ui:dialogpage>
</div>
</body>
</html>
Oops, something went wrong.

0 comments on commit 719e3b7

Please sign in to comment.