Skip to content

Commit 5475068

Browse files
committed
Implement "Use WYSIWYG" toggle functionality for Posts, to allow for raw HTML editing.
1 parent 4b51e7e commit 5475068

File tree

11 files changed

+138
-68
lines changed

11 files changed

+138
-68
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ root = true
44
indent_style = space
55
indent_size = 2
66
end_of_line = lf
7+
insert_final_newline = true
78
charset = utf-8
89
trim_trailing_whitespace = true

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,3 +701,6 @@ DEPENDENCIES
701701
uglifier (~> 2.7.1)
702702
underscore-rails (~> 1.8.2)
703703
unicorn-rails (~> 2.2.0)
704+
705+
BUNDLED WITH
706+
1.10.3

app/api/v1/entities/post.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Post < Grape::Entity
66
expose :title, documentation: {desc: "Post Title", type: "String" , required: true}
77
expose :type, documentation: {desc: "Post Type", type: "String", enum: ["ArticlePost", "VideoPost", "InfographicPost", "PromoPost"], required: true}
88
expose :draft, documentation: {desc: "Draft status", type: "Boolean"}
9+
expose :is_wysiwyg, documentation: {desc: "Post needs a WYSIWYG editor", type: "Boolean"}
910
expose :comment_count, documentation: {desc: "Number of comments", type: "Integer"}
1011
expose :short_description, documentation: {desc: "Short description of the post", type: "String", required: true}
1112
expose :job_phase, documentation: {desc: "Job Phase", type: "String", enum: ["discovery", "find_the_job", "get_the_job", "on_the_job"], required: true}

app/assets/javascripts/controllers/posts/edit.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ angular.module('cortex.controllers.posts.edit', [
5959
plugins: ['media', 'imageFit'],
6060
minHeight: 800,
6161
buttonSource: true,
62-
deniedTags: ['html', 'head', 'link', 'body', 'meta', 'applet'] // Allow script, style
62+
deniedTags: [],
63+
replaceDivs: false
6364
};
6465

6566
$scope.isAuthorUser = function(post) {

app/assets/javascripts/states.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ angular.module('cortex.states', [
268268
var post = new cortex.posts();
269269
post.body = '';
270270
post.draft = true;
271+
post.is_wysiwyg = true;
271272
post.author = currentUser.full_name;
272273
post.copyright_owner = post.copyright_owner || "CareerBuilder, LLC";
273274
post.tag_list = '';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.is-wysiwyg {
2+
@extend .form-group;
3+
4+
.is-wysiwyg-group {
5+
@extend .input-group;
6+
}
7+
}

app/assets/stylesheets/states/posts.edit.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
.editor {
1111
@extend .form-control;
12+
13+
min-height: 800px;
1214
}
1315
}
1416
}
@@ -134,4 +136,4 @@ span.has-error i::before {
134136
.form-control-feedback.select-feedback {
135137
pointer-events: none;
136138
right: 15px;
137-
}
139+
}

app/assets/templates/posts/article/info.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,21 @@
7878
required>
7979
</div>
8080
</div>
81+
82+
<div class="is-wysiwyg">
83+
<label>Use WYSIWYG Editor?</label>
84+
<div class="is-wysiwyg-group">
85+
<input
86+
bs-switch
87+
ng-model="data.post.is_wysiwyg"
88+
type="checkbox"
89+
switch-active="true"
90+
switch-on-text="Enabled"
91+
switch-off-text="Disabled"
92+
switch-on-color="default"
93+
switch-off-color="primary"
94+
switch-icon="fa fa-edit"
95+
switch-animate="true"/>
96+
</div>
97+
<p>Consider disabling the WYSIWYG editor if you'd like to input raw HTML</p>
98+
</div>

app/assets/templates/posts/article/seo.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,22 @@
2424
ng-model="data.post.seo_description"
2525
ng-maxlength="255">
2626
</div>
27-
</div>
27+
</div>
28+
29+
<div class="is-wysiwyg">
30+
<label>Use WYSIWYG Editor?</label>
31+
<div class="is-wysiwyg-group">
32+
<input
33+
bs-switch
34+
ng-model="data.post.is_wysiwyg"
35+
type="checkbox"
36+
switch-active="true"
37+
switch-on-text="Enabled"
38+
switch-off-text="Disabled"
39+
switch-on-color="default"
40+
switch-off-color="primary"
41+
switch-icon="fa fa-edit"
42+
switch-animate="true"/>
43+
</div>
44+
<p>Consider disabling the WYSIWYG editor if you'd like to input raw HTML</p>
45+
</div>

app/assets/templates/posts/edit.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
<form id="postForm" name="postForm" ng-submit="data.savePost()" novalidate>
22
<div class="composer-column">
33
<div class="composer">
4-
<textarea ng-model="data.post.body"
5-
redactor="redactorOptions"
6-
class="editor">
7-
</textarea>
4+
<div ng-switch on="data.post.is_wysiwyg">
5+
<div ng-switch-when="true">
6+
<textarea ng-model="data.post.body"
7+
redactor="redactorOptions"
8+
class="editor">
9+
</textarea>
10+
</div>
11+
<div ng-switch-default>
12+
<textarea ng-model="data.post.body" class="editor"></textarea>
13+
</div>
14+
</div>
815
</div>
916
</div>
1017

0 commit comments

Comments
 (0)