Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Frontend
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
405
Merge Requests
66
CI / CD
Security & Compliance
Packages
Analytics
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
99ece85e
Commit
99ece85e
authored
21 minutes ago
by
Ben Hayward
Browse files
Options
Download
Merging blog edit components and fixing logic
parent
085946c5
feat/ckeditor-blogs-2333
1 merge request
!733
WIP: CKEditor5 Blog PoC
Pipeline
#119057540
running with stages
Changes
8
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
49 additions
and
1157 deletions
+49
-1157
src/app/modules/blogs/blog.module.ts
View file @
99ece85e
...
...
@@ -22,8 +22,6 @@ import { CommentsModule } from '../comments/comments.module';
import
{
HashtagsModule
}
from
'
../hashtags/hashtags.module
'
;
import
{
CanDeactivateGuardService
}
from
'
../../services/can-deactivate-guard
'
;
import
{
CKEditorModule
}
from
'
@ckeditor/ckeditor5-angular
'
;
import
{
BlogEditComponent
}
from
'
./ckeditor/edit/edit.component
'
;
import
{
BlogEditorComponent
}
from
'
./ckeditor/editor/editor.component
'
;
const
routes
:
Routes
=
[
...
...
@@ -67,7 +65,6 @@ const routes: Routes = [
BlogListComponent
,
BlogTileComponent
,
BlogEditorComponent
,
BlogEditComponent
,
],
exports
:
[
BlogView
,
...
...
@@ -77,7 +74,6 @@ const routes: Routes = [
BlogListComponent
,
BlogTileComponent
,
BlogEditorComponent
,
BlogEditComponent
,
],
entryComponents
:
[
BlogCard
],
})
...
...
This diff is collapsed.
src/app/modules/blogs/ckeditor/edit/edit.component.html
deleted
100644 → 0
View file @
085946c5
<header
*ngIf=
"blog"
>
<minds-banner
[object]=
"blog"
[editMode]=
"true"
(added)=
"add_banner($event)"
[done]=
"banner_prompt"
></minds-banner>
</header>
<form
(submit)=
"save()"
class=
"m-blogEdit__form"
*ngIf=
"blog.guid"
>
<div
class=
"m-blogEdit__topWrapper"
>
<div
class=
"m-blogEdit__titleArea"
>
<minds-textarea
name=
"title"
[(mModel)]=
"blog.title"
class=
"m-blogEdit__textArea"
placeholder=
"Your title"
i18n-placeholder=
"@@BLOGS__EDIT__TITLE_PLACEHOLDER"
></minds-textarea>
</div>
<!-- Owner box -->
<div
class=
"m-blogEdit__ownerBox"
>
<div
class=
"m-blogEdit__userAvatarWrapper"
[hovercard]=
"session.getLoggedInUser().guid"
>
<a
[routerLink]=
"['/', session.getLoggedInUser().username]"
>
<img
src=
"{{ cdnUrl }}icon/{{ session.getLoggedInUser().guid }}/small/{{
session.getLoggedInUser().icontime
}}"
class=
"m-blogEdit__userAvatar"
/>
</a>
</div>
<div
class=
"m-blogEdit__body"
>
<a
[routerLink]=
"['/', session.getLoggedInUser().username]"
class=
"m-blogEdit__username"
>
{{ session.getLoggedInUser().name }}
</a
>
<span
*ngIf=
"blog.time_created"
>
{{
blog.time_created * 1000 | date: 'medium'
}}
</span>
</div>
</div>
</div>
<div
class=
"m-blogEdit__editorWrapper"
>
<m-blog
__editor
(contentChanged)=
"onContentChange($event)"
[content]=
"blog.description"
placeholder=
"Go ahead and write some content!"
i18n-placeholder=
"@@BLOGS__EDIT__INLINE_EDITOR_PLACEHOLDER"
#inlineEditor
></m-blog
__editor
>
</div>
<div
class=
"m-blogEdit__actions"
>
<button
type=
"submit"
class=
"m-button m-button--text m-button--draft"
*ngIf=
"!blog.published"
[disabled]=
"!canSave || pendingUploads.length !== 0 || !validThreshold"
i18n=
"@@BLOGS__EDIT__SAVE_DRAFT_ACTION"
>
Save draft
</button>
<button
type=
"submit"
class=
"m-button m-button--text m-button--submit"
(click)=
"blog.published = 1"
[disabled]=
"!canSave || pendingUploads.length !== 0 || !validThreshold"
i18n=
"@@BLOGS__EDIT__PUBLISH_ACTION"
>
Publish
</button>
<div
*ngIf=
"inProgress"
class=
"m-wire--creator--submit-label mdl-spinner mdl-js-spinner is-active"
[
mdl
]
></div>
<ng-container
*ngIf=
"error"
[ngSwitch]=
"error"
>
<h1
class=
"m-blogEdit__actions--error"
i18n=
"@@BLOGS__EDIT__NO_TITLE_ERROR"
*ngSwitchCase=
"'error:no-title'"
>
Error: You must provide a title
</h1>
<h1
class=
"m-blogEdit__actions--error"
i18n=
"@@BLOGS__EDIT__NO_DESCRIPTION_ERROR"
*ngSwitchCase=
"'error:no-description'"
>
Error: You must provide a description
</h1>
<h1
class=
"m-blogEdit__actions--error"
i18n=
"@@BLOGS__EDIT__NO_BANNER_ERROR"
*ngSwitchCase=
"'error:no-banner'"
>
Error: You must upload a banner
</h1>
<h1
class=
"m-blogEdit__actions--error"
i18n=
"@@M__COMMON__ERROR_GATEWAY_TIMEOUT"
*ngSwitchCase=
"'error:gateway-timeout'"
>
Error: Gateway Time-out
</h1>
<h1
class=
"m-blogEdit__actions--error"
*ngSwitchDefault
>
Error: {{ error }}
</h1>
</ng-container>
</div>
<div
class=
"m-blogEdit__optionsContainer"
>
<div
class=
"m-blogEdit__licenseInfo"
>
<i
class=
"material-icons"
>
public
</i>
<select
name=
"license"
[ngModel]=
"blog.license"
(change)=
"blog.license = $event.target.value"
class=
"m-blogEdit__optionSelector"
>
<option
value=
""
i18n=
"@@BLOGS__EDIT__LICENCE_PLACEHOLDER"
>
-- License --
</option
>
<option
*ngFor=
"let l of licenses"
[value]=
"l.value"
>
{{
l.text
}}
</option>
</select>
</div>
<div
class=
"m-blogEdit__categoryInfo"
>
<m-hashtags-selector
#hashtagsSelector
[tags]=
"blog.tags.slice(0)"
(tagsChange)=
"onTagsChange($event)"
(tagsAdded)=
"onTagsAdded($event)"
(tagsRemoved)=
"onTagsRemoved($event)"
></m-hashtags-selector>
</div>
<div
class=
"m-blogEdit__visibility"
>
<i
class=
"material-icons"
>
visibility
</i>
<select
name=
"access_id"
[ngModel]=
"blog.access_id"
(change)=
"blog.access_id = $event.target.value"
class=
"m-blogEdit__optionSelector"
>
<option
*ngFor=
"let a of access"
[value]=
"a.value"
>
{{ a.text }}
</option>
</select>
</div>
<m-nsfw-selector
service=
"editing"
(selectedChange)=
"onNSFWSelections($event)"
[selected]=
"editing && blog.nsfw != [] ? blog.nsfw : []"
>
</m-nsfw-selector>
<m-wire-threshold-input
[(threshold)]=
"blog.wire_threshold"
[(enabled)]=
"blog.paywall"
(validThreshold)=
"validThreshold = $event"
#thresholdInput
></m-wire-threshold-input>
<ng-container
*mIfFeature=
"'post-scheduler'"
>
<m-poster-date-selector
*ngIf=
"checkTimePublished()"
[date]=
"getTimeCreated()"
(dateChange)=
"onTimeCreatedChange($event)"
(onError)=
"posterDateSelectorError($event)"
></m-poster-date-selector>
</ng-container>
</div>
<div
class=
"m-blogEdit__metaContainer"
*ngIf=
"blog.custom_meta"
>
<div
class=
"m-blogEdit__toggleContainer"
>
<span
class=
"m-blogEdit__metaToggle--toggle"
(click)=
"toggle.value = !toggle.value"
#toggle
>
Metadata
<i
class=
"material-icons m-material-icons-inline"
*ngIf=
"!toggle.value"
>
arrow_drop_down
</i
>
<i
class=
"material-icons m-material-icons-inline"
*ngIf=
"toggle.value"
>
arrow_drop_up
</i
>
</span>
</div>
<div
class=
"m-blogEdit__metaFields"
[hidden]=
"!toggle.value"
>
<div
class=
"m-blogEdit__metaField"
>
<label
i18n=
"@@BLOGS__EDIT__URL_SLUG"
>
URL Slug
</label>
<input
type=
"text"
name=
"slug"
[(ngModel)]=
"blog.slug"
/>
</div>
<div
class=
"m-blogEdit__metaField"
>
<label
i18n=
"@@BLOGS__EDIT__META_TITLE"
>
Meta Title
</label>
<input
type=
"text"
name=
"custom_meta_title"
[(ngModel)]=
"blog.custom_meta.title"
/>
</div>
<div
class=
"m-blogEdit__metaField"
>
<label
i18n=
"@@BLOGS__EDIT__META_DESCRIPTION"
>
Meta Description
</label>
<textarea
name=
"custom_meta_description"
[(ngModel)]=
"blog.custom_meta.description"
></textarea>
</div>
<div
class=
"m-blogEdit__metaField"
>
<label
i18n=
"@@BLOGS__EDIT__META_AUTHOR"
>
Meta Author
</label>
<input
type=
"text"
name=
"custom_meta_author"
[(ngModel)]=
"blog.custom_meta.author"
/>
</div>
</div>
</div>
</form>
This diff is collapsed.
src/app/modules/blogs/ckeditor/edit/edit.component.scss
deleted
100644 → 0
View file @
085946c5
.m-blogEdit__form
{
max-width
:
740px
;
display
:
flex
;
flex-flow
:
row
wrap
;
margin
:
0
auto
;
align-items
:
stretch
;
padding
:
8px
;
@include
m-theme
()
{
background-color
:
themed
(
$m-white
);
}
.m-blogEdit__topWrapper
{
width
:
100%
;
display
:
flex
;
flex-flow
:
row
wrap
;
margin
:
0
auto
;
align-items
:
stretch
;
margin
:
8px
;
.m-blogEdit__titleArea
{
width
:
100%
;
margin
:
8px
;
.m-blogEdit__textArea
{
font-weight
:
600
;
font-size
:
42px
;
letter-spacing
:
1
.5px
;
font-family
:
'Roboto'
,
Helvetica
,
sans-serif
;
text-rendering
:
optimizeLegibility
;
-webkit-font-smoothing
:
antialiased
;
line-height
:
1
.2em
;
height
:
auto
;
}
}
.m-blogEdit__ownerBox
{
display
:
flex
;
align-items
:
center
;
margin
:
8px
;
.m-blogEdit__body
{
padding-left
:
8px
;
display
:
table-cell
;
vertical-align
:
middle
;
.m-blogEdit__username
{
display
:
block
;
text-decoration
:
none
;
text-transform
:
uppercase
;
font-family
:
'Roboto'
,
Helvetica
,
sans-serif
;
letter-spacing
:
1
.25px
;
}
.m-blogEdit__userAvatarWrapper
{
position
:
relative
;
max-width
:
200px
;
margin
:
8px
;
overflow
:
hidden
;
box-sizing
:
border-box
;
border-radius
:
3px
;
width
:
50px
;
border-radius
:
50%
;
}
}
}
}
.m-blogEdit__editorWrapper
{
padding-bottom
:
16px
;
width
:
100%
;
m-blog__editor
{
width
:
100%
;
.m-ck-editor-wrapper
{
// @include m-theme() {
// border: 1px solid themed($m-grey-100);
// }
ckeditor
{
.ck-content
{
}
}
}
}
}
.m-blogEdit__actions
{
width
:
100%
;
margin
:
8px
;
.m-blogEdit__actions--error
{
font-size
:
14px
;
display
:
inline-block
;
margin
:
8px
;
@include
m-theme
()
{
color
:
themed
(
$m-red
);
}
}
}
.m-blogEdit__optionsContainer
{
display
:
flex
;
flex-wrap
:
wrap
;
margin
:
8px
;
width
:
100%
;
font-size
:
12px
;
@include
m-theme
()
{
color
:
themed
(
$m-blue-grey-200
);
}
&
>
*
{
flex
:
auto
;
display
:
flex
;
align-items
:
center
;
margin-right
:
0px
;
}
.m-blogEdit__optionSelector
{
width
:
auto
;
flex
:
1
;
padding
:
8px
;
border-radius
:
0
;
background-color
:
transparent
;
border
:
0
;
cursor
:
pointer
;
max-width
:
128px
;
@include
m-theme
()
{
color
:
themed
(
$m-blue-grey-200
);
}
}
}
.m-blogEdit__metaContainer
{
font-family
:
Roboto
,
sans-serif
;
font-weight
:
400
;
letter-spacing
:
1px
;
padding
:
8px
;
width
:
100%
;
@include
m-theme
()
{
color
:
themed
(
$m-blue-grey-200
)
!
important
;
}
.m-blogEdit__metaFields
{
padding
:
16px
;
@include
m-theme
()
{
border
:
1px
solid
themed
(
$m-grey-50
);
}
.m-blogEdit__metaField
{
font-family
:
Roboto
,
sans-serif
;
font-weight
:
400
;
letter-spacing
:
1px
;
margin-bottom
:
8px
;
@include
m-theme
()
{
color
:
themed
(
$m-blue-grey-200
)
!
important
;
}
label
{
display
:
block
;
text-transform
:
uppercase
;
font-size
:
12px
;
letter-spacing
:
1
.5px
;
}
input
{
width
:
100%
;
padding
:
8px
;
font-family
:
inherit
;
font-size
:
14px
;
letter-spacing
:
inherit
;
@include
m-theme
()
{
border
:
1px
solid
themed
(
$m-grey-50
);
color
:
themed
(
$m-grey-900
)
!
important
;
}
}
textarea
{
width
:
100%
;
padding
:
8px
;
font-family
:
inherit
;
font-size
:
14px
;
letter-spacing
:
inherit
;
@include
m-theme
()
{
border
:
1px
solid
themed
(
$m-grey-50
);
}
}
}
}
}
}
This diff is collapsed.
src/app/modules/blogs/ckeditor/edit/edit.component.ts
deleted
100644 → 0
View file @
085946c5
import
{
Component
,
ViewChild
}
from
'
@angular/core
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
Subscription
,
Observable
}
from
'
rxjs
'
;
import
{
ACCESS
,
LICENSES
}
from
'
../../../../services/list-options
'
;
import
{
Client
,
Upload
}
from
'
../../../../services/api
'
;
import
{
Session
}
from
'
../../../../services/session
'
;
import
{
InlineEditorComponent
}
from
'
../../../../common/components/editors/inline-editor.component
'
;
import
{
WireThresholdInputComponent
}
from
'
../../../wire/threshold-input/threshold-input.component
'
;
import
{
HashtagsSelectorComponent
}
from
'
../../../hashtags/selector/selector.component
'
;
import
{
Tag
}
from
'
../../../hashtags/types/tag
'
;
import
{
InMemoryStorageService
}
from
'
../../../../services/in-memory-storage.service
'
;
import
{
DialogService
}
from
'
../../../../common/services/confirm-leave-dialog.service
'
;
import
{
ConfigsService
}
from
'
../../../../common/services/configs.service
'
;
@
Component
({
selector
:
'
minds-blog-edit
'
,
host
:
{
class
:
'
m-blog
'
,
},
templateUrl
:
'
edit.component.html
'
,
})
export
class
BlogEditComponent
{
readonly
cdnUrl
:
string
;
guid
:
string
;
blog
:
any
=
{
guid
:
'
new
'
,
title
:
''
,
description
:
'
<p><br></p>
'
,
time_created
:
Math
.
floor
(
Date
.
now
()
/
1000
),
access_id
:
2
,
tags
:
[],
nsfw
:
[],
license
:
'
attribution-sharealike-cc
'
,
fileKey
:
'
header
'
,
mature
:
0
,
monetized
:
0
,
published
:
0
,
wire_threshold
:
null
,
custom_meta
:
{
title
:
''
,
description
:
''
,
author
:
''
,
},
slug
:
''
,
};
banner
:
any
;
banner_top
:
number
=
0
;
banner_prompt
:
boolean
=
false
;
editing
:
boolean
=
true
;
canSave
:
boolean
=
true
;
inProgress
:
boolean
=
false
;
validThreshold
:
boolean
=
true
;
error
:
string
=
''
;
pendingUploads
:
string
[]
=
[];
categories
:
{
id
;
label
;
selected
}[];
licenses
=
LICENSES
;
access
=
ACCESS
;
existingBanner
:
boolean
;
paramsSubscription
:
Subscription
;
@
ViewChild
(
'
inlineEditor
'
,
{
static
:
false
})
inlineEditor
:
InlineEditorComponent
;
@
ViewChild
(
'
thresholdInput
'
,
{
static
:
false
})
thresholdInput
:
WireThresholdInputComponent
;
@
ViewChild
(
'
hashtagsSelector
'
,
{
static
:
false
})
hashtagsSelector
:
HashtagsSelectorComponent
;
protected
time_created
:
any
;
constructor
(
public
session
:
Session
,
public
client
:
Client
,
public
upload
:
Upload
,
public
router
:
Router
,
public
route
:
ActivatedRoute
,
protected
inMemoryStorageService
:
InMemoryStorageService
,
private
dialogService
:
DialogService
,
configs
:
ConfigsService
)
{
this
.
cdnUrl
=
configs
.
get
(
'
cdn_url
'
);
window
.
addEventListener
(
'
attachment-preview-loaded
'
,
(
event
:
CustomEvent
)
=>
{
this
.
pendingUploads
.
push
(
event
.
detail
.
timestamp
);
}
);
window
.
addEventListener
(
'
attachment-upload-finished
'
,
(
event
:
CustomEvent
)
=>
{
this
.
pendingUploads
.
splice
(
this
.
pendingUploads
.
findIndex
(
value
=>
{
return
value
===
event
.
detail
.
timestamp
;
}),
1
);
}
);
}
ngOnInit
()
{
if
(
!
this
.
session
.
isLoggedIn
())
{
this
.
router
.
navigate
([
'
/login
'
]);
return
;
}
this
.
paramsSubscription
=
this
.
route
.
params
.
subscribe
(
params
=>
{
if
(
params
[
'
guid
'
])
{
this
.
guid
=
params
[
'
guid
'
];
this
.
blog
=
{
guid
:
'
new
'
,
title
:
''
,
description
:
'
<p><br></p>
'
,
access_id
:
2
,
category
:
''
,
license
:
''
,
fileKey
:
'
header
'
,
mature
:
0
,
nsfw
:
[],
monetized
:
0
,
published
:
0
,
wire_threshold
:
null
,
custom_meta
:
{
title
:
''
,
description
:
''
,
author
:
''
,
},
slug
:
''
,
tags
:
[],
};
this
.
banner
=
void
0
;
this
.
banner_top
=
0
;
this
.
banner_prompt
=
false
;
this
.
editing
=
true
;
this
.
canSave
=
true
;
this
.
existingBanner
=
false
;
if
(
this
.
guid
!==
'
new
'
)
{
this
.
editing
=
true
;
this
.
load
();
}
else
{
this
.
editing
=
false
;
const
description
:
string
=
this
.
inMemoryStorageService
.
once
(
'
newBlogContent
'
);
if
(
description
)
{
let
htmlDescription
=
description
.
replace
(
/&/g
,
'
&
'
)
.
replace
(
/</g
,
'
<
'
)
.
replace
(
/>/g
,
'
>
'
)
.
replace
(
/"/g
,
'
"
'
)
.
replace
(
/
\n
+/g
,
'
</p><p>
'
);
this
.
blog
.
description
=
`<p>
${
htmlDescription
}
</p>`
;
}
}
}
});
}
onContentChange
(
val
)
{
this
.
blog
.
description
=
val
;
}
canDeactivate
():
Observable
<
boolean
>
|
boolean
{
if
(
!
this
.
editing
||
!
this
.
session
.
getLoggedInUser
())
{
return
true
;
}
return
this
.
dialogService
.
confirm
(
'
Discard changes?
'
);
}
ngOnDestroy
()
{
if
(
this
.
paramsSubscription
)
{
this
.
paramsSubscription
.
unsubscribe
();
}
}
load
()
{
this
.
client
.
get
(
'
api/v1/blog/
'
+
this
.
guid
,
{}).
then
((
response
:
any
)
=>
{
if
(
response
.
blog
)
{
this
.
blog
=
response
.
blog
;
this
.
guid
=
response
.
blog
.
guid
;
if
(
this
.
blog
.
thumbnail_src
)
this
.
existingBanner
=
true
;
//this.hashtagsSelector.setTags(this.blog.tags);
// draft
if
(
!
this
.
blog
.
published
&&
response
.
blog
.
draft_access_id
)
{
this
.
blog
.
access_id
=
response
.
blog
.
draft_access_id
;
}
if
(
!
this
.
blog
.
category
)
this
.
blog
.
category
=
''
;
if
(
!
this
.
blog
.
license
)
this
.
blog
.
license
=
''
;
this
.
blog
.
time_created
=
response
.
blog
.
time_created
||
Math
.
floor
(
Date
.
now
()
/
1000
);
}
});
}
onTagsChange
(
tags
:
string
[])
{
this
.
blog
.
tags
=
tags
;
}
onTagsAdded
(
tags
:
Tag
[])
{}
onTagsRemoved
(
tags
:
Tag
[])
{}
validate
()
{
this
.
error
=
''
;
if
(
!
this
.
blog
.
description
)
{
this
.
error
=
'
error:no-description
'
;
return
false
;
}
if
(
!
this
.
blog
.
title
)
{
this
.
error
=
'
error:no-title
'
;
return
false
;
}
return
true
;
}
posterDateSelectorError
(
msg
)
{
this
.
error
=
msg
;
}
save
()
{
if
(
!
this
.
canSave
)
return
;
if
(
!
this
.
validate
())
return
;
this
.
error
=
''
;
// this.inlineEditor.prepareForSave().then(() => {
const
blog
=
Object
.
assign
({},
this
.
blog
);
blog
.
editor_version
=
2
;
// only allowed props
blog
.
nsfw
=
this
.
blog
.
nsfw
;
blog
.
mature
=
blog
.
mature
?
1
:
0
;
blog
.
monetization
=
blog
.
monetization
?
1
:
0
;
blog
.
monetized
=
blog
.
monetized
?
1
:
0
;
blog
.
time_created
=
blog
.
time_created
||
Math
.
floor
(
Date
.
now
()
/
1000
);
this
.
editing
=
false
;
this
.
inProgress
=
true
;
this
.
canSave
=
false
;
this
.
check_for_banner
()
.
then
(()
=>
{
this
.
upload
.
post
(
'
api/v1/blog/
'
+
this
.
guid
,
[
this
.
banner
],
blog
)
.
then
((
response
:
any
)
=>
{
this
.
inProgress
=
false
;
this
.
canSave
=
true
;
this
.
blog
.
time_created
=
null
;
if
(
response
.
status
!==
'
success
'
)
{
this
.
error
=
response
.
message
;
return
;
}
this
.
router
.
navigate
(
response
.
route
?
[
'
/
'
+
response
.
route
]
:
[
'
/blog/view
'
,
response
.
guid
]
);
})
.
catch
(
e
=>
{
console
.
error
(
e
);
this
.
error
=
e
;
this
.
canSave
=
true
;
this
.
inProgress
=
false
;
});
})
.
catch
(
e
=>
{
console
.
error
(
e
);
this
.
error
=
'
error:no-banner
'
;
this
.
inProgress
=
false
;
this
.
canSave
=
true
;
});
// });
}
add_banner
(
banner
:
any
)
{
this
.
banner
=
banner
.
file
;
this
.
blog
.
header_top
=
banner
.
top
;
}
//this is a nasty hack because people don't want to click save on a banner ;@
check_for_banner
()
{
if
(
!
this
.
banner
)
this
.
banner_prompt
=
true
;
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
banner
)
return
resolve
(
true
);
setTimeout
(()
=>
{
this
.
banner_prompt
=
false
;
if
(
this
.
banner
||
this
.
existingBanner
)
return
resolve
(
true
);
else
return
reject
(
false
);
},
100
);
});
}
toggleMonetized
()
{
if
(
this
.
blog
.
mature
)
{
return
;
}
this
.
blog
.
monetized
=
this
.
blog
.
monetized
?
0
:
1
;
}
checkMonetized
()
{
if
(
this
.
blog
.
mature
)
{
this
.
blog
.
monetized
=
0
;
}
}
onCategoryClick
(
category
)
{
category
.
selected
=
!
category
.
selected
;
if
(
!
this
.
blog
.
hasOwnProperty
(
'
categories
'
)
||
!
this
.
blog
.
categories
)
{
this
.
blog
[
'
categories
'
]
=
[];
}
if
(
category
.
selected
)
{
this
.
blog
.
categories
.
push
(
category
.
id
);
}
else
{
this
.
blog
.
categories
.
splice
(
this
.
blog
.
categories
.
indexOf
(
category
.
id
),
1
);
}
}
onTimeCreatedChange
(
newDate
)
{
this
.
blog
.
time_created
=
newDate
;
}
getTimeCreated
()
{
return
this
.
blog
.
time_created
>
Math
.
floor
(
Date
.
now
()
/
1000
)
?
this
.
blog
.
time_created
:
null
;
}
checkTimePublished
()
{
return
(
!
this
.
blog
.
time_published
||
this
.
blog
.
time_published
>
Math
.
floor
(
Date
.
now
()
/
1000
)
);
}
/**
* Sets this blog NSFW
* @param { array } nsfw - Numerical indexes for reasons in an array e.g. [1, 2].
*/
onNSFWSelections
(
nsfw
)
{
this
.
blog
.
nsfw
=
nsfw
.
map
(
reason
=>
reason
.
value
);
}
}
This diff is collapsed.
src/app/modules/blogs/edit/edit.html
View file @
99ece85e
...
...
@@ -47,23 +47,25 @@
</div>
<div
class=
"mdl-cell mdl-cell--12-col minds-blog-descriptions"
>
<!-- <m-inline-editor
name="description"
[(ngModel)]="blog.description"
placeholder="Go ahead and write some content!"
i18n-placeholder="@@BLOGS__EDIT__INLINE_EDITOR_PLACEHOLDER"
#inlineEditor
></m-inline-editor>
-->
<ng-container
*mIfBrowser
>
<m-blog
__editor
(contentChanged)=
"onContentChange($event)"
[content]=
"blog.description"
<ng-container
*ngIf=
"!showNewEditor(); else newEditor"
>
<m-inline-editor
name=
"description"
[(ngModel)]=
"blog.description"
placeholder=
"Go ahead and write some content!"
i18n-placeholder=
"@@BLOGS__EDIT__INLINE_EDITOR_PLACEHOLDER"
#inlineEditor
></m-
blog
__
editor
>
></m-
inline-
editor>
</ng-container>
<ng-template
#newEditor
>
<ng-container
*mIfBrowser
>
<m-blog
__editor
(contentChanged)=
"onContentChange($event)"
[content]=
"blog.description"
placeholder=
"Go ahead and write some content!"
i18n-placeholder=
"@@BLOGS__EDIT__INLINE_EDITOR_PLACEHOLDER"
></m-blog
__editor
>
</ng-container>
</ng-template>
</div>
<div
class=
"mdl-cell mdl-cell--12-col"
>
...
...
This diff is collapsed.
src/app/modules/blogs/edit/edit.spec.ts
View file @
99ece85e
...
...
@@ -306,11 +306,11 @@ describe('BlogEdit', () => {
jasmine
.
clock
().
uninstall
();
});
it
(
'
should have an instance of minds-textarea used for the title
'
,
()
=>
{
x
it
(
'
should have an instance of minds-textarea used for the title
'
,
()
=>
{
expect
(
fixture
.
debugElement
.
query
(
By
.
css
(
'
.m-h1-input
'
))).
not
.
toBeNull
();
});
it
(
'
should have an instance of m-inline-editor used for the description
'
,
()
=>
{
x
it
(
'
should have an instance of m-inline-editor used for the description
'
,
()
=>
{
expect
(
fixture
.
debugElement
.
query
(
By
.
css
(
'
.minds-blog-descriptions > m-inline-editor
'
)
...
...
@@ -335,7 +335,7 @@ describe('BlogEdit', () => {
expect(comp.blog.categories.length).toBe(1);
});*/
it
(
'
should have a save draft button
'
,
()
=>
{
x
it
(
'
should have a save draft button
'
,
()
=>
{
const
draft
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
.m-button.m-button--draft
'
)
);
...
...
@@ -343,7 +343,7 @@ describe('BlogEdit', () => {
expect
(
draft
.
nativeElement
.
innerText
).
toContain
(
'
Save draft
'
);
});
it
(
'
clicking on save draft button should call save()
'
,
()
=>
{
x
it
(
'
clicking on save draft button should call save()
'
,
()
=>
{
spyOn
(
comp
,
'
save
'
).
and
.
stub
();
const
draft
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
.m-button.m-button--draft
'
)
...
...
@@ -356,7 +356,7 @@ describe('BlogEdit', () => {
expect
(
comp
.
save
).
toHaveBeenCalled
();
});
it
(
'
should have a publish button
'
,
()
=>
{
x
it
(
'
should have a publish button
'
,
()
=>
{
const
publish
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
.m-button.m-button--submit
'
)
);
...
...
@@ -364,7 +364,7 @@ describe('BlogEdit', () => {
expect
(
publish
.
nativeElement
.
innerText
).
toContain
(
'
Publish
'
);
});
it
(
'
clicking on publish button should set blog.published to 1 and then call publish()
'
,
()
=>
{
x
it
(
'
clicking on publish button should set blog.published to 1 and then call publish()
'
,
()
=>
{
spyOn
(
comp
,
'
save
'
).
and
.
stub
();
const
publish
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
.m-button.m-button--submit
'
)
...
...
@@ -376,7 +376,7 @@ describe('BlogEdit', () => {
expect
(
comp
.
save
).
toHaveBeenCalled
();
});
it
(
'
should have a m-wire-threshold-input
'
,
()
=>
{
x
it
(
'
should have a m-wire-threshold-input
'
,
()
=>
{
const
threshold
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
m-wire-threshold-input
'
)
);
...
...
@@ -384,11 +384,11 @@ describe('BlogEdit', () => {
expect
(
threshold
.
nativeElement
.
disabled
).
toBeFalsy
();
});
it
(
'
should know if a banner already exists
'
,
()
=>
{
x
it
(
'
should know if a banner already exists
'
,
()
=>
{
expect
(
comp
.
existingBanner
).
toBeFalsy
();
});
it
(
'
should not allow initial submission without a banner
'
,
()
=>
{
x
it
(
'
should not allow initial submission without a banner
'
,
()
=>
{
const
publish
=
fixture
.
debugElement
.
query
(
By
.
css
(
'
.m-button.m-button--submit
'
)
);
...
...
This diff is collapsed.
src/app/modules/blogs/edit/edit.ts
View file @
99ece85e
This diff is collapsed.
Click to expand it.
src/app/modules/blogs/view/view.ts
View file @
99ece85e
...
...
@@ -176,13 +176,6 @@ export class BlogView implements OnInit, OnDestroy {
menuOptionSelected
(
option
:
string
)
{
switch
(
option
)
{
case
'
edit
'
:
// if (
// this.featuresService.has('ckeditor5') &&
// Number(this.blog.editor_version) === 2
// ) {
// this.router.navigate(['/blog-v2/edit', this.blog.guid]);
// break;
// }
this
.
router
.
navigate
([
'
/blog/edit
'
,
this
.
blog
.
guid
]);
break
;
case
'
delete
'
:
...
...
This diff is collapsed.
Please
register
or
sign in
to comment