Plugin: cursor #
Cursor #
Snippet to partially increase cursor thickness #
The characters are not typos!
Reference: Core styles of the default cursors, obtained from inspection
.ͼ1.cm-focused {
outline: 1px dotted #212121;
}
.ͼ1 {
position: relative !important;
box-sizing: border-box;
display: flex !important;
flex-direction: column;
}
.ͼ1 .cm-scroller {
display: flex !important;
align-items: flex-start !important;
font-family: monospace;
line-height: 1.4;
height: 100%;
overflow-x: auto;
position: relative;
z-index: 0;
}
.ͼ1 .cm-content[contenteditable=true] {
-webkit-user-modify: read-write-plaintext-only;
}
.ͼ1 .cm-content {
margin: 0;
flex-grow: 2;
flex-shrink: 0;
display: block;
white-space: pre;
word-wrap: normal;
box-sizing: border-box;
padding: 4px 0;
outline: none;
}
.ͼ1 .cm-lineWrapping {
white-space: pre-wrap;
white-space: break-spaces;
word-break: break-word;
overflow-wrap: anywhere;
flex-shrink: 1;
}
.ͼ2 .cm-content {
caret-color: black;
}
.ͼ3 .cm-content {
caret-color: white;
}
.ͼ1 .cm-line {
display: block;
padding: 0 2px 0 6px;
}
.ͼ1 .cm-layer>* {
position: absolute;
}
.ͼ1 .cm-layer {
position: absolute;
left: 0;
top: 0;
contain: size style;
}
.ͼ2 .cm-selectionBackground {
background: #d9d9d9;
}
.ͼ3 .cm-selectionBackground {
background: #222;
}
.ͼ2.cm-focused>.cm-scroller>.cm-selectionLayer .cm-selectionBackground {
background: #d7d4f0;
}
.ͼ3.cm-focused>.cm-scroller>.cm-selectionLayer .cm-selectionBackground {
background: #233;
}
.ͼ1 .cm-cursorLayer {
pointer-events: none;
}
.ͼ1.cm-focused>.cm-scroller>.cm-cursorLayer {
animation: steps(1) cm-blink 1.2s infinite;
}
@keyframes cm-blink {
50% {
opacity: 0;
}
}
@keyframes cm-blink2 {
50% {
opacity: 0;
}
}
.ͼ1 .cm-cursor,
.ͼ1 .cm-dropCursor {
border-left: 1.2px solid black;
margin-left: -0.6px;
pointer-events: none;
}
.ͼ1 .cm-cursor {
display: none;
}
.ͼ3 .cm-cursor {
border-left-color: #444;
}
.ͼ1 .cm-dropCursor {
position: absolute;
}
.ͼ1.cm-focused>.cm-scroller>.cm-cursorLayer .cm-cursor {
display: block;
}
.ͼ2 .cm-activeLine {
background-color: #cceeff44;
}
.ͼ3 .cm-activeLine {
background-color: #99eeff33;
}
.ͼ2 .cm-specialChar {
color: red;
}
.ͼ3 .cm-specialChar {
color: #f78;
}
.ͼ1 .cm-gutters {
flex-shrink: 0;
display: flex;
height: 100%;
box-sizing: border-box;
left: 0;
z-index: 200;
}
.ͼ2 .cm-gutters {
background-color: #f5f5f5;
color: #6c6c6c;
border-right: 1px solid #ddd;
}
.ͼ3 .cm-gutters {
background-color: #333338;
color: #ccc;
}
.ͼ1 .cm-gutter {
display: flex !important;
flex-direction: column;
flex-shrink: 0;
box-sizing: border-box;
min-height: 100%;
overflow: hidden;
}
.ͼ1 .cm-gutterElement {
box-sizing: border-box;
}
.ͼ1 .cm-lineNumbers .cm-gutterElement {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
white-space: nowrap;
}
.ͼ2 .cm-activeLineGutter {
background-color: #e2f2ff;
}
.ͼ3 .cm-activeLineGutter {
background-color: #222227;
}
.ͼ1 .cm-panels {
box-sizing: border-box;
position: sticky;
left: 0;
right: 0;
}
.ͼ2 .cm-panels {
background-color: #f5f5f5;
color: black;
}
.ͼ2 .cm-panels-top {
border-bottom: 1px solid #ddd;
}
.ͼ2 .cm-panels-bottom {
border-top: 1px solid #ddd;
}
.ͼ3 .cm-panels {
background-color: #333338;
color: white;
}
.ͼ1 .cm-tab {
display: inline-block;
overflow: hidden;
vertical-align: bottom;
}
.ͼ1 .cm-widgetBuffer {
vertical-align: text-top;
height: 1em;
width: 0;
display: inline;
}
.ͼ1 .cm-placeholder {
color: #888;
display: inline-block;
vertical-align: top;
}
.ͼ1 .cm-highlightSpace:before {
content: attr(data-display);
position: absolute;
pointer-events: none;
color: #888;
}
.ͼ1 .cm-highlightTab {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>');
background-size: auto 100%;
background-position: right 90%;
background-repeat: no-repeat;
}
.ͼ1 .cm-trailingSpace {
background-color: #ff332255;
}
.ͼ1 .cm-button {
vertical-align: middle;
color: inherit;
font-size: 70%;
padding: .2em 1em;
border-radius: 1px;
}
.ͼ2 .cm-button:active {
background-image: linear-gradient(#b4b4b4, #d0d3d6);
}
.ͼ2 .cm-button {
background-image: linear-gradient(#eff1f5, #d9d9df);
border: 1px solid #888;
}
.ͼ3 .cm-button:active {
background-image: linear-gradient(#111, #333);
}
.ͼ3 .cm-button {
background-image: linear-gradient(#393939, #111);
border: 1px solid #888;
}
.ͼ1 .cm-textfield {
vertical-align: middle;
color: inherit;
font-size: 70%;
border: 1px solid silver;
padding: .2em .5em;
}
.ͼ2 .cm-textfield {
background-color: white;
}
.ͼ3 .cm-textfield {
border: 1px solid #555;
background-color: inherit;
}
.ͼp .cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer) {
display: none;
}
.ͼp .cm-vim-panel {
padding: 0px 10px;
font-family: monospace;
min-height: 1.3em;
}
.ͼp .cm-vim-panel input {
border: none;
outline: none;
}
.ͼo .cm-vimMode .cm-line {
caret-color: transparent !important;
}
.ͼo .cm-fat-cursor {
position: absolute;
border: none;
white-space: pre;
}
.ͼo.cm-focused .cm-fat-cursor {
background: var(--interactive-accent);
color: var(--text-on-accent);
}
.ͼo:not(.cm-focused) .cm-fat-cursor {
outline: solid 1px #ff9696;
color: transparent !important;
}
There are two types of cursors, .cm-cursor (end-border of selection) and .cm-dropCursor (caret when user is typing). The following style only works on the former, using accent colour from iB theme, with default accent as fallback.
/* disable animation for cm-cursor */
.ͼ1.cm-focused>.cm-scroller>.cm-cursorLayer {
animation: none !important;
}
/* colour and width for cm-cursor */
/* dropCursor does not work for some reason */
/* mimics fat-cursor */
/* better than border-left method for more consistent sizes */
/* colour: iB theme, with default theme as fallback */
.ͼ1 .cm-cursor,
.ͼ1 .cm-dropCursor {
visibility: visible !important;
display: block;
position: absolute;
border: none;
white-space: pre;
outline: 1px solid var(--indicator-color, var(--interactive-accent));
color: transparent !important;
margin-left: 0.5px;
}
/* colour for cm-dropCursor */
.markdown-source-view.mod-cm6 .cm-content {
caret-color: var(--indicator-color, var(--interactive-accent));
}
Ninja cursor #
Repo: vrtmrz/ninja-cursor
After making little changes to this comment in the Ninja cursor repository, I finally feel like this plugin could be a serious default cursor alternative (on desktop). Still not perfect, because the huge cursor bar on left when you select multiple lines still exists, but during typing it is a much more pleasant experience than the default cursor.
Notes for Obsidian iOS:
- When made thick and tall enough, the x-cursor will cover (not replace) the blinking cursor on iOS as well. The numbers below are tested minimals for this purpose.
- After launching Obsidian, the plugin takes a few seconds (I guess maybe even on some less powerful desktop devices) to start-up, before which you will see the default cursor;
- During scrolling, the x-cursor will stay at its on-screen position (as opposed to: in-text position) for a split second, and may stay there until tapping at a new position. If your main writing device is iOS, this is experience-breaking.
If you want to use this solution, disable the previous cursor snippet, and add the following instead. I changed the width and height, and the blinking animation. You cannot write animation: none to stop it, because that will leave you with no cursor. Unfortunately I think it is just how this plugin works.
/* iAWriter-ish style. */
.cursorWrapper .x-cursor {
background: var(--indicator-color, var(--interactive-accent));
width: 3px;
left: -1px;
top: calc(-5px - var(--header-height));
height: calc(10px + var(--cursor-height));
transition: opacity;
}
/* The cursor colour in a light theme */
.theme-light .x-cursor {
background: var(--indicator-color, var(--interactive-accent));
}
/*The cursor colour in a dark theme */
.theme-dark .x-cursor {
/* replace if you want purple cursor
background: rgba(225,187, 225, 1); */
background: var(--indicator-color, var(--interactive-accent));
}
/* remove normal cursor when ninjacursor is installed.
Alternative method: caret-color: rgba(0, 0, 0, 1);
*/
body:has(.x-cursor) .cm-editor * {
caret-color: transparent;
}
/* Disable movement effect */
.cursorWrapper .x-cursor::after {
display: none;
}
/* Remove normal cursor on text selection */
.cm-cursorLayer {
animation: none !important;
visibility: hidden !important;
}
/* Blinking */
.cursorWrapper .x-cursor0 {
animation: blink0 1s 1s both infinite;
}
.cursorWrapper .x-cursor1 {
animation: blink1 1s 1s both infinite;
}
/* Changed the numbers so that it never blinks */
@keyframes blink1 {
0% { opacity: 1; }
45% { opacity: 1; }
50% { opacity: 1; }
95% { opacity: 1; }
100% { opacity: 1; }
}
@keyframes blink0 {
0% { opacity: 1; }
45% { opacity: 1; }
50% { opacity: 1; }
95% { opacity: 1; }
100% { opacity: 1; }
}