-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce additional CKEditor theming (#5)
- Loading branch information
Austin Green
authored
Feb 1, 2021
1 parent
93052da
commit 9581cde
Showing
16 changed files
with
584 additions
and
26 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
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,3 +1,6 @@ | ||
{ | ||
"extends": "@zendeskgarden/stylelint-config" | ||
"extends": "@zendeskgarden/stylelint-config", | ||
"rules": { | ||
"selector-max-specificity": null | ||
} | ||
} |
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,47 @@ | ||
/** | ||
* Copyright Zendesk, Inc. | ||
* | ||
* Use of this source code is governed under the Apache License, Version 2.0 | ||
* found at http://www.apache.org/licenses/LICENSE-2.0. | ||
*/ | ||
|
||
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview'; | ||
import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; | ||
import codeBlockIcon from '@zendeskgarden/svg-icons/src/16/terminal-window-stroke.svg'; | ||
import { getNormalizedAndLocalizedLanguageDefinitions } from '@ckeditor/ckeditor5-code-block/src/utils'; | ||
|
||
export class CodeBlockUI extends Plugin { | ||
init() { | ||
const editor = this.editor; | ||
const t = editor.t; | ||
const componentFactory = editor.ui.componentFactory; | ||
const normalizedLanguageDefs = getNormalizedAndLocalizedLanguageDefinitions(editor); | ||
const defaultLanguageDefinition = normalizedLanguageDefs[0]; | ||
|
||
componentFactory.add('codeBlock', locale => { | ||
const command = editor.commands.get('codeBlock'); | ||
|
||
const buttonView = new ButtonView(locale); | ||
|
||
buttonView.set({ | ||
label: t('Insert code block'), | ||
tooltip: true, | ||
keystroke: 'CTRL+SHIFT+6', | ||
icon: codeBlockIcon, | ||
isToggleable: true | ||
}); | ||
|
||
buttonView.bind('isEnabled').to(command); | ||
|
||
buttonView.on('execute', () => { | ||
editor.execute('codeBlock', { | ||
language: defaultLanguageDefinition.language | ||
}); | ||
|
||
editor.editing.view.focus(); | ||
}); | ||
|
||
return buttonView; | ||
}); | ||
} | ||
} |
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,8 +1,35 @@ | ||
/* stylelint-disable-next-line selector-max-specificity */ | ||
.ck.ck-button:not(.ck-disabled):hover .ck-button__icon { | ||
color: #49545c; /* GREY-700 */ | ||
} | ||
.ck.ck-button { | ||
&:focus { | ||
/* stylelint-disable-next-line color-function-notation */ | ||
box-shadow: rgba(31, 115, 183, .35) 0 0 0 3px; /* BLUE-600 */ | ||
} | ||
|
||
&:focus, | ||
&:active { | ||
border-color: transparent; | ||
} | ||
|
||
&:not(.ck-disabled) { | ||
cursor: pointer; | ||
} | ||
|
||
& .ck-button__icon { | ||
color: #68737d; /* GREY-600 */ | ||
} | ||
|
||
&:hover:not(.ck-disabled,.ck-on) { | ||
& .ck-button__icon { | ||
color: #49545c; /* GREY-700 */ | ||
} | ||
} | ||
|
||
&.ck-on { | ||
& .ck-button__icon { | ||
color: #2f3941; /* GREY-800 */ | ||
} | ||
} | ||
|
||
.ck.ck-button:not(.ck-disabled) { | ||
cursor: pointer; | ||
&.ck-disabled:active { | ||
box-shadow: none; | ||
} | ||
} |
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,15 @@ | ||
.ck-content pre { | ||
margin: 0; | ||
margin-top: var(--ck-spacing-large); | ||
margin-bottom: var(--ck-spacing-large); | ||
border-radius: var(--ck-border-radius-small); | ||
background-color: #f8f9f9; /* GREY-100 */ | ||
padding: var(--ck-spacing-large); | ||
overflow: auto; | ||
white-space: pre; | ||
color: var(--ck-color-base-text); | ||
|
||
& code { | ||
background-color: inherit; | ||
} | ||
} |
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,94 @@ | ||
/* stylelint-disable declaration-no-important, | ||
max-nesting-depth, selector-max-compound-selectors */ | ||
|
||
@keyframes zd-menu--top-open { | ||
0% { | ||
transform: translateY(var(--ck-spacing-extra-large)); | ||
} | ||
} | ||
|
||
@keyframes zd-menu--bottom-open { | ||
0% { | ||
transform: translateY(calc(var(--ck-spacing-extra-large) * -1)); | ||
} | ||
} | ||
|
||
.ck.ck-dropdown { | ||
& .ck-button.ck-dropdown__button { | ||
& .ck-dropdown__arrow { | ||
transition: transform .25s ease-in-out 0s, color .25s ease-in-out 0s; | ||
} | ||
|
||
&.ck-on { | ||
border-radius: var(--ck-border-radius); | ||
|
||
& .ck-dropdown__arrow { | ||
transform: rotate(180deg); | ||
} | ||
} | ||
} | ||
|
||
& .ck-dropdown__panel { | ||
animation: .2s cubic-bezier(.15, .85, .35, 1.2); | ||
border-radius: var(--ck-border-radius) !important; | ||
|
||
&:not(.ck-dropdown__panel-visible) { | ||
display: inline-block; | ||
transition: opacity .2s ease-in-out, .2s visibility 0s linear; | ||
visibility: hidden; | ||
opacity: 0; | ||
} | ||
|
||
&.ck-dropdown__panel-visible { | ||
visibility: visible; | ||
opacity: 1; | ||
|
||
&.ck-dropdown__panel_ne, | ||
&.ck-dropdown__panel_nw { | ||
animation-name: zd-menu--top-open; | ||
} | ||
|
||
&.ck-dropdown__panel_se, | ||
&.ck-dropdown__panel_sw { | ||
animation-name: zd-menu--bottom-open; | ||
} | ||
} | ||
|
||
& > :first-child { | ||
margin-top: var(--ck-spacing-standard); | ||
} | ||
|
||
& > :last-child { | ||
margin-bottom: var(--ck-spacing-standard); | ||
} | ||
|
||
&.ck-dropdown__panel_ne, | ||
&.ck-dropdown__panel_nw { | ||
bottom: calc(100% + 4px); | ||
} | ||
|
||
&.ck-dropdown__panel_se, | ||
&.ck-dropdown__panel_sw { | ||
top: calc(100% + 4px); | ||
bottom: auto; | ||
} | ||
|
||
& .ck-list .ck-list__item .ck-button { | ||
border-radius: 0 !important; | ||
} | ||
} | ||
} | ||
|
||
.ck[dir='rtl'].ck-dropdown { | ||
& .ck-button.ck-dropdown__button { | ||
& .ck-dropdown__arrow { | ||
transition: transform .25s ease-in-out 0s, color .25s ease-in-out 0s; | ||
} | ||
|
||
&.ck-on { | ||
& .ck-dropdown__arrow { | ||
transform: rotate(-180deg); | ||
} | ||
} | ||
} | ||
} |
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,9 +1,8 @@ | ||
.ck.ck-editor__editable_inline { | ||
.ck.ck-editor__editable { | ||
padding: 0 var(--ck-spacing-large); | ||
} | ||
|
||
/* Hide widget mobile type-around feature */ | ||
/* stylelint-disable-next-line selector-max-specificity */ | ||
.ck.ck-editor__editable .ck-widget .ck-widget__type-around__button { | ||
display: none; | ||
/* Hide widget mobile type-around feature */ | ||
& .ck-widget .ck-widget__type-around__button { | ||
display: none; | ||
} | ||
} |
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,3 +1,22 @@ | ||
/* stylelint-disable selector-max-compound-selectors, | ||
selector-combinator-space-before, indentation, | ||
declaration-no-important */ | ||
|
||
.ck-content hr { | ||
margin: var(--ck-spacing-unit) 0; | ||
margin: var(--ck-spacing-standard) 0; | ||
background-color: #d8dcde; /* GREY-300 */ | ||
height: 1px; | ||
} | ||
|
||
.ck .ck-widget.ck-horizontal-line { | ||
&.ck-widget_selected:not(.ck-widget_type-around_show-fake-caret_before, | ||
.ck-widget_type-around_show-fake-caret_after) { | ||
outline-color: transparent !important; | ||
border-radius: var(--ck-border-radius) !important; | ||
box-shadow: var(--ck-focus-outer-shadow), 0 0; | ||
|
||
& hr { | ||
background-color: var(--ck-color-base-focus); | ||
} | ||
} | ||
} |
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,3 +1,3 @@ | ||
.ck .ck-link_selected { | ||
border-radius: 2px; | ||
background: none; | ||
} |
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
Oops, something went wrong.