Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable CodeMirror when on Mobile #2730

Closed
tgrosinger opened this issue Jan 24, 2017 · 5 comments
Closed

Disable CodeMirror when on Mobile #2730

tgrosinger opened this issue Jan 24, 2017 · 5 comments

Comments

@tgrosinger
Copy link
Contributor

@tgrosinger tgrosinger commented Jan 24, 2017

TiddlyWiki version: 5.1.13
CodeMirror version: 5.1.13

The codemirror plugin does not work very well on mobile. Errors pop up frequently and sometimes the written content is even lost. There should be a way to automatically disable codemirror only when on mobile.

This issue is a continuation of this discussion: https://groups.google.com/forum/#!topic/tiddlywiki/Usrl0OQyESY

As noted by @Jermolene, the $:/config/EditorTypeMappings/text/vnd.tiddlywiki tiddler is not wikified when being read for configuration, so changing the value using a mechanism like the $reveal widget is not an option.

@pmario

This comment has been minimized.

Copy link
Contributor

@pmario pmario commented Jan 24, 2017

I think, to make this work, we would need to modify the core plugin initialisation. IMO there isn't much, that the user can do atm. except manually disabling the plugin and save / reload. :/

@tgrosinger

This comment has been minimized.

Copy link
Contributor Author

@tgrosinger tgrosinger commented Jan 24, 2017

Yeah, that is what @Jermolene indicated as well (a startup module). I might be interested in looking into that, but would need pointers of where to start digging. I have worked in plugin-space a bit, but have not done much in core yet.

@buggyj

This comment has been minimized.

Copy link
Contributor

@buggyj buggyj commented Jan 26, 2017

maybe along the lines of

/*\
title: $:/core/modules/macros/hackeditorstring.js
type: application/javascript
module-type: startup


\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

// Export name and synchronous status
exports.name = "hackeditstring";
exports.after = ["load-modules"];
exports.synchronous = true;


exports.startup = function() {


if ($tw.browser)
if (/Android|webOS|iPhone|iPad|iPod|Opera Mini/i.test(navigator.userAgent || navigator.vendor || window.opera)) {
		$tw.wiki.addTiddler(new $tw.Tiddler({title: "$:/config/EditorTypeMappings/text/vnd.tiddlywiki", text: "text"}));
			}
else {
		$tw.wiki.addTiddler(new $tw.Tiddler({title: "$:/config/EditorTypeMappings/text/vnd.tiddlywiki", text: "codemirror"}));
}
}

})();
@tgrosinger

This comment has been minimized.

Copy link
Contributor Author

@tgrosinger tgrosinger commented Jan 26, 2017

This works great, thank you @buggyj.

I think it might be good to package this up as a plugin, since not everyone wants this exact behavior. I will look into extending it into something more configurable and generic.

@buggyj

This comment has been minimized.

Copy link
Contributor

@buggyj buggyj commented Jan 26, 2017

@tgrosinger - it's just a general idea to get you started, this piece of code does not match the cores' coding style (look at the use of braces and spaces - there is probably a code style guide somewhere), I have no idea if it would capture all smart phones, and if this is applicable for tablets?? So I think there is some work to do yet.

I would expect this functionality to go into the codemirror plugin as you are suggesting.

@tgrosinger tgrosinger closed this Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.