widget.css 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. @import "../mixins/_focus.css";
  6. @import "../mixins/_shadow.css";
  7. :root {
  8. --ck-widget-outline-thickness: 3px;
  9. --ck-widget-handler-icon-size: 16px;
  10. --ck-widget-handler-animation-duration: 200ms;
  11. --ck-widget-handler-animation-curve: ease;
  12. --ck-color-widget-blurred-border: hsl(0, 0%, 87%);
  13. --ck-color-widget-hover-border: hsl(43, 100%, 62%);
  14. --ck-color-widget-editable-focus-background: var(--ck-color-base-background);
  15. --ck-color-widget-drag-handler-icon-color: var(--ck-color-base-background);
  16. }
  17. .ck .ck-widget {
  18. outline-width: var(--ck-widget-outline-thickness);
  19. outline-style: solid;
  20. outline-color: transparent;
  21. transition: outline-color var(--ck-widget-handler-animation-duration) var(--ck-widget-handler-animation-curve);
  22. &.ck-widget_selected,
  23. &.ck-widget_selected:hover {
  24. outline: var(--ck-widget-outline-thickness) solid var(--ck-color-focus-border);
  25. }
  26. &:hover {
  27. outline-color: var(--ck-color-widget-hover-border);
  28. }
  29. }
  30. .ck .ck-editor__nested-editable {
  31. border: 1px solid transparent;
  32. /* The :focus style is applied before .ck-editor__nested-editable_focused class is rendered in the view.
  33. These styles show a different border for a blink of an eye, so `:focus` need to have same styles applied. */
  34. &.ck-editor__nested-editable_focused,
  35. &:focus {
  36. @mixin ck-focus-ring;
  37. @mixin ck-box-shadow var(--ck-inner-shadow);
  38. background-color: var(--ck-color-widget-editable-focus-background);
  39. }
  40. }
  41. .ck .ck-widget.ck-widget_selectable {
  42. & .ck-widget__selection-handler {
  43. padding: 4px;
  44. box-sizing: border-box;
  45. /* Background and opacity will be animated as the handler shows up or the widget gets selected. */
  46. background-color: transparent;
  47. opacity: 0;
  48. /* Transition:
  49. * background-color for the .ck-widget_selected state change,
  50. * visibility for hiding the handler,
  51. * opacity for the proper look of the icon when the handler disappears. */
  52. transition:
  53. background-color var(--ck-widget-handler-animation-duration) var(--ck-widget-handler-animation-curve),
  54. visibility var(--ck-widget-handler-animation-duration) var(--ck-widget-handler-animation-curve),
  55. opacity var(--ck-widget-handler-animation-duration) var(--ck-widget-handler-animation-curve);
  56. /* Make only top corners round. */
  57. border-radius: var(--ck-border-radius) var(--ck-border-radius) 0 0;
  58. /* Place the drag handler outside the widget wrapper. */
  59. transform: translateY(-100%);
  60. left: calc(0px - var(--ck-widget-outline-thickness));
  61. /* Advertise using the look of the icon that once clicked the handler, the widget will be selected. */
  62. &:hover .ck-icon .ck-icon__selected-indicator {
  63. opacity: 1;
  64. }
  65. & .ck-icon {
  66. /* Make sure the dimensions of the icon are independent of the fon-size of the content. */
  67. width: var(--ck-widget-handler-icon-size);
  68. height: var(--ck-widget-handler-icon-size);
  69. color: var(--ck-color-widget-drag-handler-icon-color);
  70. /* The "selected" part of the icon is invisible by default */
  71. & .ck-icon__selected-indicator {
  72. opacity: 0;
  73. /* Note: The animation is longer on purpose. Simply feels better. */
  74. transition: opacity 300ms var(--ck-widget-handler-animation-curve);
  75. }
  76. }
  77. }
  78. /* Show the selection handler when the widget is selected. */
  79. &.ck-widget_selected,
  80. &.ck-widget_selected:hover {
  81. & .ck-widget__selection-handler {
  82. opacity: 1;
  83. background-color: var(--ck-color-focus-border);
  84. /* When the widget is selected, notify the user using the proper look of the icon. */
  85. & .ck-icon .ck-icon__selected-indicator {
  86. opacity: 1;
  87. }
  88. }
  89. }
  90. /* Show the selection handler on mouse hover over the widget. */
  91. &:hover .ck-widget__selection-handler {
  92. opacity: 1;
  93. background-color: var(--ck-color-widget-hover-border);
  94. }
  95. }
  96. /* Style the widget when it's selected but the editable it belongs to lost focus. */
  97. .ck-editor__editable.ck-blurred .ck-widget {
  98. &.ck-widget_selected,
  99. &.ck-widget_selected:hover {
  100. outline-color: var(--ck-color-widget-blurred-border);
  101. & .ck-widget__selection-handler,
  102. & .ck-widget__selection-handler:hover {
  103. background: var(--ck-color-widget-blurred-border);
  104. }
  105. }
  106. }
  107. .ck-editor__editable.ck-read-only .ck-widget {
  108. /* Disable visual effects of hover/active widget when CKEditor is in readOnly mode.
  109. See: https://github.com/ckeditor/ckeditor5/issues/1261 */
  110. --ck-widget-outline-thickness: 0;
  111. }