Code Monkey home page Code Monkey logo

cm-typewriter-scroll-obsidian's Introduction

Typewriter Scroll Obsidian Plugin

GitHub release (latest SemVer) GitHub All Releases

A plugin for Obsidian to enable typewriter-style scrolling, which keeps the view centered in the editor.

Screenshot

Compatibility

Custom plugins are only available for Obsidian v0.9.7+.

The current API of this repo targets Obsidian v0.10.0.

Notes

This is all very experimental at the moment, so parts might not work, etc.

Installation

From within Obsidian

From Obsidian v0.9.8, you can activate this plugin within Obsidian by doing the following:

  • Open Settings > Third-party plugin
  • Make sure Safe mode is off
  • Click Browse community plugins
  • Search for this plugin
  • Click Install
  • Once installed, close the community plugins window and activate the newly installed plugin

Updates

You can follow the same procedure to update the plugin

From GitHub

  • Download the Latest Release from the Releases section of the GitHub Repository
  • Extract the plugin folder from the zip to your vault's plugins folder: <vault>/.obsidian/plugins/
    Note: On some machines the .obsidian folder may be hidden. On MacOS you should be able to press Command+Shift+Dot to show the folder in Finder.
  • Reload Obsidian
  • If prompted about Safe Mode, you can disable safe mode and enable the plugin. Otherwise head to Settings, third-party plugins, make sure safe mode is off and enable the plugin from there.

Security

Third-party plugins can access files on your computer, connect to the internet, and even install additional programs.

The source code of this plugin is available on GitHub for you to audit yourself, but installing plugins into Obsidian is currently a matter of trust.

I can assure you here that I do nothing to collect your data, send information to the internet or otherwise do anything nefarious with your system. However, be aware that I could, and you only have my word that I don't.

This plugin does contain code copied from this repository, which I have modified for this plugin.

Development

This project uses Typescript to provide type checking and documentation.
The repo depends on the latest plugin API in Typescript Definition format, which contains TSDoc comments describing what it does.

Note: The Obsidian API is still in early alpha and is subject to change at any time!

If you want to contribute to development and/or just customize it with your own tweaks, you can do the following:

  • Clone this repo.
  • npm i or yarn to install dependencies
  • npm run build to compile.
  • Copy manifest.json, main.js and styles.css to a subfolder of your plugins folder (e.g, <vault>/.obsidian/plugins/<plugin-name>/)
  • Reload obsidian to see changes

Alternately, you can clone the repo directly into your plugins folder and once dependencies are installed use npm run dev to start compilation in watch mode.
You may have to reload obsidian (ctrl+R) to see changes.

Pricing

Huh? This is an open-source plugin I made for fun. It's completely free. However, if you absolutely have to send me money because you like it that much, feel free to throw some coins in my hat via the following:

GitHub Sponsors Paypal

Version History

0.2.2

  • Added a setting to adjust the typewriter mode offset (more towards the top or bottom of the page).
  • Fixed a bug preventing the typewriter mode from being disabled without reloading Obsidian.

0.2.1

  • Added padding to centre the top in live preview

0.2.0

  • CM6 (Live Preview) support!

0.1.1

  • Modified scroll so it won't work on mouse selection.
    • Instead, it specifically only works on 'up', 'down', 'left' and 'right' keyboard presses (alongside any typing edits).
  • Also, changed the cursor position used for the calculation so that shift+arrow selection is visible.
  • Fixed unexpected line jumping.

0.1.0

  • Updated APIs so toggling on and off should work again.

0.0.2

  • Added a basic 'Zen Mode' which dims non-active lines in the editor
    • "Active Line" will include an entire paragraph at this stage
    • Togglable in settings and via a command
  • Fixed some minor issues around disabling / enabling

0.0.1

Initial Release

cm-typewriter-scroll-obsidian's People

Contributors

actions-user avatar deathau avatar gordonped avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cm-typewriter-scroll-obsidian's Issues

Toggle Zen Mode + Typewriter together

Hello thanks for your plugin, I use it daily and very much appreciate the work you put in.

Just a small feature request:

  • I am using the Zen mode + typewriter together mostly, but not have both always on (I just use them in certain scenarios, but always together). Currently I have to hit 2 hotkeys to toggle them. Is it possible to toggle both at once?

Possible solutions:

  • combined hotkey
  • link them using a toggle switch so they are always both on or both off.

Idea: Delayed scrolling movement when clicking on a line.

Hey,

it would be very nice, if it is possible to implement that.
Right now the scrolling is more an instaneaous jump to the line when clicking. This is a bit confusing as there is a high load of perceptive change. It would be better, if there is a brief delay and then a smooth scrolling movement to the clicked line. This would help the brain to comprehend the change because there would be a lesser cognitive load.

feature request : no backspace mode

to extend on the typewriter user experience, having a mode that disables the backspace and arrow keys would be nice. I've seen this in some editors and it is quite useful when you want to force yourself to write without editing. Not sure how it is called though.

Not really an issue but a feature request: Add Hotkey for turning on and off

Hey,

I love the plugin - sometimes I absolutely hate it, especially for editing longer notes, the page jumps to much I get confused and it breaks my focus.

So: Could you add an option to add a hotkey to turn it on and off quickly :)

(Don't take the "I hate it" to literally, I could not resist describing my experience in such a nice contradicting way. The moments I love the plugin greatly outweigh the times I don't like it so much)

Clicking on block links jumps to top of file instead

I've just noticed this bug, and through a process of elimination have found that Typewriter Scoll is causing it. Essentially, when I click on a link to a block from another file, I jump to the top of the file instead of to the linked block. Would this be because the cursor defaults to the top of the file and so the view automatically adjusts?

Not working in Vim's normal mode

This is a wonderful plugin! I use Vim mode and I noticed when I'm in insert mode it works as expected, but when I'm in normal mode it behaves like normal and the cursor doesn't stay in the center of the screen. When I return to insert mode and move the cursor, the current line is centered as expected.

Sometimes using spacebar delets backwards on Android device

When I write with the focus mode of the plugin, then sometimes using the spacebar deletes backwards, sometimes just one character, sometimes several.

I use Samsung S4 tablet with Android.

If you need more info, feel free to refer back to me. (Also for the other issue I posted.)

Pause Zen mode on scroll

Zen mode is very helpful for writing, but distracting for reading.

Similar to the original feature in IA Writer, is it possible to pause Zen mode when scrolling? And then restart Zen mode on a mouse click or key press?

Error while opening a file

While opening a file from a link to a section ([[The Page#Section]]), due to this plugin, scroll location always ends up being at the top of the page. If the page is already open in other pane, and I click on the link again, it works fine and takes me to that section.
Definitely this is undesired. It should go to the desired section upon the first landing too.

Attached is the gif. Please see to it if it can be fixed :)

vid-1627489107852

Feature Request: Set Line Number for Cursor

I love this plugin! I use vim-scripts/scrollfix in Vim as well.

Will you please add a configuration for the line number that the cursor sits on.

I have Vim setup so that 1/4 of the page is above the cursor and 3/4 is below.

Zen mode only in active tab

In split-view mode, only the active page is affected by the Zen mode.

Would be nice if any inactive pages would be greyed out as well.

Obsidian_xe9jbaAOov

Typewriter Scroll breaks plugin Remember Cursor Position

Per dy-sh/obsidian-remember-cursor-position#16, Typewriter Scroll breaks this other plugin's primary function by resetting the position to the head of the file. I don't know enough about JS to know if there is an elegant way to make these plugins interact, but I have personally commented out line 79 in main.js, where it reads var cursor = cm.getCursor('head'); and it solved my problem. Obviously this will be reset the next time Typewriter updates, but it would be great if there were a solution to this conflict built-in. My bad---didn't test this properly and it does not work after all.

Typewriter Scroll makes my writing much more pleasant, thank you for your hard work!

RFE: Highlight current line

Instead of darkening the rest of the text, is it possible to use a background color for the line? Perhaps even scale the line a little to increase visibility even more?

Feature Request: Toggle only for one pane

When writing a new note I sometimes look at other notes and may want to copy a text snippet or footnote. With the plugin enabled switching between panes is rather annoying. Therefore it'd be great to only toggle the plugin for a specific pane.

Bug: when used in combination with Fastkeys deletes words.

When Typewriter Scroll is used in combination with Fastkeys(an Autohotkey alternative), it deletes the word I'm currently typing. Not always, and I couldn't find a pattern, but often enough to be announced. I had to turn it off.

I would like to continue to use it, but unfortunately, I can't in this state.

Please, let me know if you need additional info.

Conflict with Obsidian's new Table View

Causes tables to expand wildly in every direction and makes them unusable in the pre-release versions, and probably will continue to when it becomes official.

It does seem like development has discontinued but this plugin has been enabled pretty much from day 1 that I started using Obsidian. So either way, thanks for almost a year of making my Obsidian experience better!

"Shaky" text when typing each character (short documents)

When a note is not very long (like when it starts empty) and is entered in a "tall" window, each typed character makes the whole not text "shake". This is not very convenient.

In case this matters:

  • Zen mode is activated (focus on the current line).
  • The focused line is quite near the top of the pane.

Thanks!

Typewriter scrolling

Typewriter scrolling hasn't been working for me anymore since I deactivated the Legacy mode.
Are there any plans to get this plugin working for the newest Obsidian version and possibly with Legacy mode deactivated?
I enjoyed using this plugin a lot but cannot use it anymore.

[github]: missing topics

This repository doesn't have topics set such as obsidian, obsidian-md, obsidian-plugin which leads to less reach. Please add these topics, so Obsidian users can easily find the repository for this great plugin! ๐Ÿ˜Š

More a request than an issue...

This is a great plug-in, thank you.
I was wondering if there is an option to have it turned off as default and be able to toggle it when needed. I love it when writing, but when browsing through notes and copy-pasting it can be a little cumbersome. If I enable the plugin in Obsidian, then it is automatically on in every note I open; I would rather have it off by default and toggle it with a keyboard shortcut. (Now the shortcut only works if it's on by default.)
Regardless, thank you!

Zen Mode doesn't apply to centered LaTeX

When zen mode is enabled, normal text is dimmed as it should be. However, LaTeX with double dollar symbols ($$) that place it on a centered line is never dimmed.

Here is it working with single-dollar embedded LaTeX:
image

However it does not apply to full-line LaTeX:
image

It works in editor mode -
image

Thanks for making this plugin :)

Bug: Toggle on/off not working properly

Using version 0.1.0 of the plugin and v0.12.19 of Obsidian I have following issue:

  1. With typewriter scroll on, type something in a currently open note. Typewriter scroll works
  2. Turn typewriter scroll off (open command pane and select the command to toggle it off)
  3. In the same note, typewriter scroll is now correctly turned off
  4. Open another note in a different pane
  5. When typing in that other note, typewriter scroll is now suddenly turned ON? But in the "old" note it's still turned OFF.

A lot of Console Log Spam

Hello, it seems like there was a rather verbose console.log() left in the most recent release, specifically in the typewriter-scrolling.js file.

image

It seems like this was removed in commit 31f47b2 and just needs to be pushed to release.

Feature Request: Option to disable onCursorActivity

I find that commenting out the onCursorActivity function creates a more enjoyable experience while navigating through my documents. It would be great to have a toggle for that in the Obsidian Plugin Panel.

Issue with korean letters.

HI, Thank you for great plug in.

I'm using your plugin, and in korean scroll up a line after enter or . or , .. etc not another line.

I captured screen.

2021-08-11.8.33.05.mov

BUG: Hides bottom half of file explorer pane

When engaged, Typewrite Mode hides the bottom half of the standard file explorer plugin. I have turned typewriter mode on/off, and it consistently does this. I am surprised that no one else has reported this. So, I can only assume that typewriter mode is interacting with some other plugin or set of plugin that is unique to my setup.

I don't know if this will be of any use, but here is the list of my installed plugins:

  • advanced-toolbar
  • auto-note-mover
  • better-word-count
  • buttons
  • chem
  • cm-editor-syntax-highlight-obsidian
  • cm-typewriter-scroll-obsidian
  • cmdr
  • console
  • copilot
  • creases
  • csv-obsidian
  • customizable-menu
  • cycle-through-panes
  • daily-activity
  • dataview
  • dbfolder
  • duplicate-line
  • extract-url
  • file-explorer-note-count
  • file-tree-alternative
  • find-unlinked-files
  • highlightr-plugin
  • hk-code-block
  • hotkey-helper
  • hotkeysplus-obsidian
  • janitor
  • lapel
  • latex-matrices
  • matter
  • maximise-active-pane-obsidian
  • media-extended
  • meld-calc
  • mermaid-tools
  • metadata-menu
  • mrj-text-expand
  • multi-column-markdown
  • nldates-obsidian
  • note-refactor-obsidian
  • notion-like-tables
  • number-headings-obsidian
  • numerals
  • obsidian-admonition
  • obsidian-annotator
  • obsidian-apply-patterns
  • obsidian-asciimath
  • obsidian-auto-link-title
  • obsidian-better-codeblock
  • obsidian-book-search-plugin
  • obsidian-charts
  • obsidian-chat-view
  • obsidian-checklist-plugin
  • obsidian-code-block-enhancer
  • obsidian-collapse-all-plugin
  • obsidian-columns
  • obsidian-comments
  • obsidian-contextual-typography
  • obsidian-daily-notes-viewer
  • obsidian-diagrams-net
  • obsidian-dictionary-plugin
  • obsidian-divide-and-conquer
  • obsidian-dropbox-backups
  • obsidian-dynamic-highlights
  • obsidian-dynamic-toc
  • obsidian-emoji-toolbar
  • obsidian-excalidraw-plugin
  • obsidian-extract-pdf-highlights
  • obsidian-file-info-plugin
  • obsidian-file-path-to-uri
  • obsidian-filename-heading-sync
  • obsidian-fullscreen-plugin
  • obsidian-hotkeys-for-templates
  • obsidian-hypothesis-plugin
  • obsidian-icon-folder
  • obsidian-icon-shortcodes
  • obsidian-icons-plugin
  • obsidian-imgur-plugin
  • obsidian-jupyter
  • obsidian-kanban
  • obsidian-kroki
  • obsidian-latex-suite
  • obsidian-linter
  • obsidian-map-view
  • obsidian-mind-map
  • obsidian-minimal-settings
  • obsidian-nomnoml-diagram
  • obsidian-outliner
  • obsidian-plantuml
  • obsidian-pluck
  • obsidian-plugin-toc
  • obsidian-plugin-update-tracker
  • obsidian-raindrop-highlights
  • obsidian-regex-pipeline
  • obsidian-regex-replace
  • obsidian-rich-links
  • obsidian-show-file-path
  • obsidian-sort-and-permute-lines
  • obsidian-spaced-repetition
  • obsidian-structured-plugin
  • obsidian-style-settings
  • obsidian-tabs
  • obsidian-tasks-plugin
  • obsidian-text-expander
  • obsidian-text-format
  • obsidian-timeline
  • obsidian-to-anki-plugin
  • obsidian-underline
  • obsidian-vale
  • obsidian-zoom
  • omnisearch
  • open-note-to-window-title
  • podnotes
  • pseudocode-in-obs
  • quickadd
  • quote-of-the-day
  • readwise-official
  • recent-files-obsidian
  • remember-cursor-position
  • reveal-active-file-button
  • settings-search
  • slated-obsidian
  • supercharged-links-obsidian
  • table-editor-obsidian
  • tag-word-cloud
  • tag-wrangler
  • templater-obsidian
  • text-extractor
  • text-snippets-obsidian
  • things-logbook
  • url-into-selection
  • vantage-obsidian
  • workbench-obsidian
  • workspaces-plus

[Feature] Set number of visible lines before/after current line, like vim's scrolloff (Scroll offset) option

I'd like to add a feature where the number of visible lines above or below the current line always present during scrolling, here is a demo of the expected behaviour if a scrolloff option is set to 5:

simplescreenrecorder-2021-11-27_17 08 38

notice that the number of lines above the cursor is always 5 when scrolling up. The same effect for scrolling down is not yet implemented.

The following modification to typewriter-scrolling.js's CodeMirror.commands.scrollSelectionToCenter will implement this effect:

const ALWAYS_CENTRE = false; // turn off scroll offset, always centre the line // TODO add to settings
const SCROLL_OFFSET_LINES = 5; /* TODO add to settings */
CodeMirror.commands.scrollSelectionToCenter = function (cm) {
    var cursor = cm.getCursor('head');
    var charCoords = cm.charCoords(cursor, "local");
    var scrollInfo = cm.getScrollInfo();
    var top = charCoords.top;
    var halfLineHeight = (charCoords.bottom - top) / 2;
    var halfWindowHeight = cm.getWrapperElement().offsetHeight / 2;

    /* TODO define as global var on plugin load, cuz each line height is different and will lead to inconsistent offset sizes */
    var scrollOffset = 2 * halfLineHeight * SCROLL_OFFSET_LINES;
 
    var scrollTo = null;
    if (ALWAYS_CENTRE || scrollOffset >= halfWindowHeight - halfLineHeight) {
        scrollTo = Math.round((top - halfWindowHeight + halfLineHeight));
    }
    else if (top < scrollInfo.top + scrollOffset) {
        scrollTo = Math.round(top - scrollOffset);
    }
    else if (top + 2 * halfLineHeight > scrollInfo.top + scrollInfo.height - scrollOffset){
        /* this part is not working properly */
        scrollTo = Math.round(top + 2*halfLineHeight + scrollOffset - 2 * halfWindowHeight);
    }

    cm.scrollTo(null, scrollTo);
};

If it's okay, I will open a pull request and work on it.

TODO

  1. fix implementation for scrolling down
  2. add "Number of Lines always Visible above or below cursor during Scrolling" (SCROLL_OFFSET_LINES above) and "Always centre (current Typewriter scrolling behaviour)"
  3. calculate a fixed offset size based on line height in plugin onload()

Unexpected line jumping

Thank you so much for this plugin. It really helps me to focus on my writing.

Sadly I encountered a bug that occurs sometimes when breaking into a new line.

Kapture 2021-02-12 at 21 39 45s

Idea: Disable scrolling past top of file

I use this plugin to let me scroll past the end of a file so that I can keep the current line centered even while adding to the end of a file.

However, now I can also scroll past the top of a file which is a bit visually jarring! Granted, some might like that but it would be great to disable that.

Plugin not work

I'm using Plugin: v0.1.1, Obsidian: v0.13.19. Already turned on "Toggle Typewriter Scrolling" but the plugin not work. The cursur still on top of note. Can someone help me?

Live preview out of sync

The scrolling of the live preview is way out of sync.

At the top of the document for example, the edit side starts at the middle, but the preview text starts at the top.

Sadly this makes the plugin mostly unusable.

VS Code style typewriter scroll

In VS Code I use keyboard shortcuts for scrollLineDown/scrollLineUp commands.
They allow to scroll in typewriter style from any row, leaving cursor in that row.
Would it be possible to expose these commands in this plugin?

Live Preview Table not respecting typewriter offset

Unlike this previous issue, it seems that live preview tables does not respect the typewriter offset defined (with typewriter scroll toggled on). It is mildly annoying but bearable for now.

Either way, thx for making such a great plugin!

Attached is a video of what I am talking about.

Obsidian.SaMXr.mp4

Mobile support

It seems like this plugin does not work at the moment with obsidian mobile (can be enabled, but doesn't seem to have any effect) - would love to see support for it!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.