widget.css 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  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-editor__editable > .ck-widget.ck-widget_with-selection-handler:first-child,
  42. .ck-editor__editable blockquote > .ck-widget.ck-widget_with-selection-handler:first-child {
  43. /* Do not crop selection handler if a widget is a first-child in the blockquote or in the root editable.
  44. In fact, anything with overflow: hidden.
  45. https://github.com/ckeditor/ckeditor5-block-quote/issues/28
  46. https://github.com/ckeditor/ckeditor5-widget/issues/44
  47. https://github.com/ckeditor/ckeditor5-widget/issues/66 */
  48. margin-top: calc(1em + var(--ck-widget-handler-icon-size));
  49. }
  50. .ck .ck-widget.ck-widget_with-selection-handler {
  51. & .ck-widget__selection-handler {
  52. padding: 4px;
  53. box-sizing: border-box;
  54. /* Background and opacity will be animated as the handler shows up or the widget gets selected. */
  55. background-color: transparent;
  56. opacity: 0;
  57. /* Transition:
  58. * background-color for the .ck-widget_selected state change,
  59. * visibility for hiding the handler,
  60. * opacity for the proper look of the icon when the handler disappears. */
  61. transition:
  62. background-color var(--ck-widget-handler-animation-duration) var(--ck-widget-handler-animation-curve),
  63. visibility var(--ck-widget-handler-animation-duration) var(--ck-widget-handler-animation-curve),
  64. opacity var(--ck-widget-handler-animation-duration) var(--ck-widget-handler-animation-curve);
  65. /* Make only top corners round. */
  66. border-radius: var(--ck-border-radius) var(--ck-border-radius) 0 0;
  67. /* Place the drag handler outside the widget wrapper. */
  68. transform: translateY(-100%);
  69. left: calc(0px - var(--ck-widget-outline-thickness));
  70. /* Advertise using the look of the icon that once clicked the handler, the widget will be selected. */
  71. &:hover .ck-icon .ck-icon__selected-indicator {
  72. opacity: 1;
  73. }
  74. & .ck-icon {
  75. /* Make sure the dimensions of the icon are independent of the fon-size of the content. */
  76. width: var(--ck-widget-handler-icon-size);
  77. height: var(--ck-widget-handler-icon-size);
  78. color: var(--ck-color-widget-drag-handler-icon-color);
  79. /* The "selected" part of the icon is invisible by default */
  80. & .ck-icon__selected-indicator {
  81. opacity: 0;
  82. /* Note: The animation is longer on purpose. Simply feels better. */
  83. transition: opacity 300ms var(--ck-widget-handler-animation-curve);
  84. }
  85. }
  86. }
  87. /* Show the selection handler when the widget is selected. */
  88. &.ck-widget_selected,
  89. &.ck-widget_selected:hover {
  90. & .ck-widget__selection-handler {
  91. opacity: 1;
  92. background-color: var(--ck-color-focus-border);
  93. /* When the widget is selected, notify the user using the proper look of the icon. */
  94. & .ck-icon .ck-icon__selected-indicator {
  95. opacity: 1;
  96. }
  97. }
  98. }
  99. /* Show the selection handler on mouse hover over the widget. */
  100. &:hover .ck-widget__selection-handler {
  101. opacity: 1;
  102. background-color: var(--ck-color-widget-hover-border);
  103. }
  104. }
  105. /* In a RTL environment, align the selection handler to the right side of the widget */
  106. .ck[dir="rtl"] .ck-widget.ck-widget_with-selection-handler .ck-widget__selection-handler {
  107. left: auto;
  108. right: calc(0px - var(--ck-widget-outline-thickness));
  109. }
  110. /* Style the widget when it's selected but the editable it belongs to lost focus. */
  111. .ck-editor__editable.ck-blurred .ck-widget {
  112. &.ck-widget_selected,
  113. &.ck-widget_selected:hover {
  114. outline-color: var(--ck-color-widget-blurred-border);
  115. & .ck-widget__selection-handler,
  116. & .ck-widget__selection-handler:hover {
  117. background: var(--ck-color-widget-blurred-border);
  118. }
  119. }
  120. }
  121. .ck-editor__editable.ck-read-only .ck-widget {
  122. /* Disable visual effects of hover/active widget when CKEditor is in readOnly mode.
  123. See: https://github.com/ckeditor/ckeditor5/issues/1261 */
  124. --ck-widget-outline-thickness: 0;
  125. }