Skip to content

Commit

Permalink
Updating to use wysihtml instead of summernote
Browse files Browse the repository at this point in the history
  • Loading branch information
klcodanr committed Oct 22, 2018
1 parent 8847718 commit 7328849
Show file tree
Hide file tree
Showing 17 changed files with 543 additions and 62 deletions.
6 changes: 5 additions & 1 deletion ui/src/main/frontend/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ gulp.task('cms-js', function() {
'./node_modules/datatables/media/js/jquery.dataTables.js',
'./node_modules/datatables-bulma/js/dataTables.bulma.js',
'./node_modules/handlebars/dist/handlebars.js',
'./node_modules/summernote/dist/summernote-lite.js',
'./node_modules/wysihtml/dist/minified/wysihtml.min.js',
'./node_modules/wysihtml/dist/minified/wysihtml.all-commands.min.js',
'./node_modules/wysihtml/dist/minified/wysihtml.table_editing.min.js',
'./node_modules/wysihtml/dist/minified/wysihtml.toolbar.min.js',
'./node_modules/wysihtml/parser_rules/advanced_and_extended.js',
'./node_modules/js-autocomplete/auto-complete.js',
'./src/js/nomnom.js',
'./src/js/cms.js',
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"jquery": "^3.3.1",
"handlebars": "^4.0.11",
"summernote": "^0.8.9",
"wysihtml": "^0.6.0-beta1",
"jam-icons": "^2.0.0",
"js-autocomplete": "^1.0.4",
"datatables": "^1.10.18",
Expand Down
26 changes: 4 additions & 22 deletions ui/src/main/frontend/src/js/cms.fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,12 @@
}
});



nomnom.decorate('.richtext', {
nomnom.decorate('.rte', {
callbacks : {
created : function(){
$(this).summernote({
toolbar: [
['style', ['bold', 'italic', 'clear','strikethrough', 'superscript', 'subscript']],
['insert', ['picture', 'link', 'table', 'hr']],
['para', ['style','ul', 'ol', 'paragraph']],
['misc', ['codeview', 'undo','redo','help']]
],
followingToolbar: false,
dialogsInBody: true,
height: 200,
onCreateLink: function (url) {
return url;
},
callbacks: {
onDialogShown: function(){
Sling.CMS.ui.suggest($('.note-link-url')[0], 'content', '/content');
Sling.CMS.ui.suggest($('.note-image-url')[0], 'content', '/content');
}
}
new wysihtml.Editor(this.querySelector('.rte-editor'), {
toolbar: this.querySelector('.rte-toolbar'),
parserRules: wysihtmlParserRules
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/frontend/src/js/cms.form.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
w * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
Expand Down
27 changes: 0 additions & 27 deletions ui/src/main/frontend/src/js/cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,33 +110,6 @@ nomnom.decorate('.suffix-form', {
}
});

nomnom.decorate('.richtext', {
callbacks : {
created : function(){
$(this).summernote({
toolbar: [
['style', ['bold', 'italic', 'clear','strikethrough', 'superscript', 'subscript']],
['insert', ['picture', 'link', 'table', 'hr']],
['para', ['style','ul', 'ol', 'paragraph']],
['misc', ['codeview', 'undo','redo','help']]
],
followingToolbar: false,
dialogsInBody: true,
height: 200,
onCreateLink: function (url) {
return url;
},
callbacks: {
onDialogShown: function(){
Sling.CMS.ui.suggest($('.note-link-url')[0], 'content', '/content');
Sling.CMS.ui.suggest($('.note-image-url')[0], 'content', '/content');
}
}
});
}
}
});

nomnom.decorate('.page-properties-container', {
callbacks : {
created : function(){
Expand Down
26 changes: 26 additions & 0 deletions ui/src/main/frontend/src/scss/cms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ h5 {
font-size: 120%;
}

.has-padding-1 {
padding: .5em;
}

.editor-page {
overflow-y: auto;
}
Expand Down Expand Up @@ -120,6 +124,22 @@ h5 {
padding: 1em;
}

.rte-form {
margin: .5em 0;
}

.rte-form .buttons {
margin: .5em 0;
}

.rte-toolbar .jam:before {
font-size: x-large;
}

.rte-toolbar .level {
margin-bottom: .5em;
}

#search-results .tile {
flex-wrap: wrap;
padding: .5em;
Expand Down Expand Up @@ -148,4 +168,10 @@ table.dataTable thead .sorting_desc:after {
.table tr.is-selected {
background-color: lighten($gray, 50%);
color: $grey-darker;
}

.wysihtml-sandbox {
width: 100% !important;
max-height: 600px !important;
min-height: 300px !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/ --%>
<%@include file="/libs/sling-cms/global.jsp"%>
<textarea class="richtext" name="${properties.name}" ${required} ${disabled}>${editProperties[properties.name]}</textarea>
<c:choose>
<c:when test="${slingRequest.requestPathInfo.suffixResource != null}">
<c:set var="path" value="${sling:getAbsoluteParent(slingRequest.requestPathInfo.suffixResource,2).path}" />
</c:when>
<c:otherwise>
<c:set var="path" value="/content" />
</c:otherwise>
</c:choose>
<%@include file="/libs/sling-cms/global.jsp"%>
<div class="rte">
<c:choose>
<c:when test="${not empty properties.toolbar}">
<c:set var="toolbar" value="${sling:getResource(resourceResolver,properties.toolbar)}" />
</c:when>
<c:otherwise>
<c:set var="toolbar" value="${sling:getResource(resourceResolver,'/libs/sling-cms/components/editor/fields/richtext/toolbar/default')}" />
</c:otherwise>
</c:choose>
<sling:include resource="${toolbar}" />
<textarea class="rte-editor textarea" name="${properties.name}" ${required} ${disabled}>${editProperties[properties.name]}</textarea>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<%-- /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ --%>
<%@include file="/libs/sling-cms/global.jsp"%>
<c:choose>
<c:when test="${not empty properties.value}">
<a class="button is-small" data-wysihtml-command="${properties.command}" data-wysihtml-command-value="${properties.value}">
<c:choose>
<c:when test="${not empty properties.icon}">
<em class="jam jam-${properties.icon} icon"></em>
</c:when>
<c:otherwise>
<strong class="icon">${properties.text}</strong>
</c:otherwise>
</c:choose>
</a>
</c:when>
<c:otherwise>
<a class="button is-small" data-wysihtml-command="${properties.command}">
<c:choose>
<c:when test="${not empty properties.icon}">
<em class="jam jam-${properties.icon} icon"></em>
</c:when>
<c:otherwise>
<strong class="icon">${properties.text}</strong>
</c:otherwise>
</c:choose>
</a>
</c:otherwise>
</c:choose>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<%-- /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ --%>
<%@include file="/libs/sling-cms/global.jsp"%>
<div class="level is-mobile">
<div class="level-left">
<c:forEach var="child" items="${sling:listChildren(resource)}">
<div class="level-item">
<sling:include resource="${child}" />
</div>
</c:forEach>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<%-- /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ --%>
<%@include file="/libs/sling-cms/global.jsp"%>
<div class="buttons has-addons">
<c:forEach var="child" items="${sling:listChildren(resource)}">
<sling:include resource="${child}" />
</c:forEach>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<%-- /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/ --%>
<%@include file="/libs/sling-cms/global.jsp"%>
<div data-wysihtml-dialog="createLink" style="display: none;">
<div class="has-padding-1 has-background-white-ter rte-form">
<p>Link</p>
<div class="field has-addons">
<div class="control is-expanded">
<input class="input pathfield is-small" data-wysihtml-dialog-field="href" data-type="nt:hierarchyNode" data-base="/content" autocomplete="off" />
</div>
<div class="control">
<a href="/cms/shared/search.html" class="button is-small Fetch-Modal search-button" data-title="Search" data-path=".Main-Content > *">
<span class="jam jam-search"></span>
</a>
</div>
</div>
<div class="field">
<select class="select is-small" data-wysihtml-dialog-field="target">
<option value="">Same Window</option>
<option value="_blank">New Window</option>
</select>
</div>
<div class="buttons">
<a data-wysihtml-dialog-action="save" class="button is-small is-success">
<em class="jam jam-check icon"></em>
</a>
<a data-wysihtml-dialog-action="cancel" class="button is-small">
<em class="jam jam-close icon"></em>
</a>
</div>
</div>
</div>
Loading

0 comments on commit 7328849

Please sign in to comment.