GithubHelp home page GithubHelp logo

Comments (3)

Gazook89 avatar Gazook89 commented on June 18, 2024

Try the ctrl k (or cmd k) hotkey for inserting a link. Is that what you expect the Link to Page snippet to do? If so, i assume it can be ported over quickly.

makeLink : function() {
		const isLink = /^\[(.*)\]\((.*)\)$/;
		const selection = this.codeMirror.getSelection().trim();
		let match;
		if(match = isLink.exec(selection)){
			const altText = match[1];
			const url     = match[2];
			this.codeMirror.replaceSelection(`${altText} ${url}`);
			const cursor = this.codeMirror.getCursor();
			this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - url.length }, { line: cursor.line, ch: cursor.ch });
		} else {
			this.codeMirror.replaceSelection(`[${selection || 'alt text'}](url)`);
			const cursor = this.codeMirror.getCursor();
			this.codeMirror.setSelection({ line: cursor.line, ch: cursor.ch - 4 }, { line: cursor.line, ch: cursor.ch - 1 });
		}
	},
	```

from homebrewery.

Gazook89 avatar Gazook89 commented on June 18, 2024

Actually maybe it is harder. The snippets are just text things, and the little JS involved is just for generating text strings. I'm not sure that it is good to conflate "plain text insertions" with "buttons that manipulate your existing text", it would be unexpected.

I do think that it would be valuable to have the "normal" toolbar of functions that you get in most WYSIWYG editors, with "Underline", "Bold", "Italic" and "add link", etc. But I think that is separate from text insertions.

from homebrewery.

ericscheid avatar ericscheid commented on June 18, 2024

Ah .. I see we do have a hot-key for insert link (ctrl-K), and it does the desired. For the life of me I couldn't remember if there was one, and the nearest thing was the Insert Link to Page snippet.

OK, don't change the insert snippet behaviour.

from homebrewery.

Related Issues (20)

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.