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

Providing #anchors in text #528

Closed
bigclumsyoaf opened this issue Feb 8, 2017 · 1 comment
Closed

Providing #anchors in text #528

bigclumsyoaf opened this issue Feb 8, 2017 · 1 comment

Comments

@bigclumsyoaf
Copy link

Hi, me again :-)

We would like to be able to add #anchors into the content, so that links can be targeted to specific areas of content. Has anybody done this before? Or have any suggestions where to start? I was thinking the easiest way would be a custom block which doesn't render any visible content, but just has an input for the anchor name. Has anybody tried this?

thanks

Daryl.

@matjemeisje
Copy link

I just made an "anchorable" mixin for this purpose:

SirTrevor.Block.prototype.availableMixins.push('anchorable');

SirTrevor.BlockMixins.Anchorable = {

mixinName: "Anchorable",

initializeAnchorable: function() {
SirTrevor.log("Adding anchorable to block " + this.blockID);
$(this.inner).append('<input class="st-input-string js-anchor-input" name="anchor" placeholder="Anchor name" style="width: 100%; margin-top: 10px; text-align: center">');
},

setAnchor: function(anchor) {
$(this.inner).find(".js-anchor-input").first().val(anchor);
}

};

Set anchorable: true in any block you want to apply it to. I hope it helps you.

@raffij raffij closed this as completed Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants