question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hint "content" run-on with custom tag

See original GitHub issue

Using your example on your hint examples page (http://summernote.org/examples/#hint) I modified slightly the “content:” to highlight the item:

$(".hint2mention").summernote({
  height: 100,
  toolbar: false,
  hint: {
    mentions: ['jayden', 'sam', 'alvin', 'david'],
    match: /\B@(\w*)$/,
    search: function (keyword, callback) {
      callback($.grep(this.mentions, function (item) {
        return item.indexOf(keyword) == 0;
      }));
    },
    content: function (item) {
      return $("<b>").html('@' + item)[0];     // Changed from return '@'+item
    }    
  }
});

browser: Chrominium Version 50.0.2661.94 (64-bit) OS: Linux Mint 17.3 64 bit Summernote source used: http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.1/summernote.js

result is like this:

here is text @sam words beyond selection are stil bold

I cannot seem to terminate the ‘bold’.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

2reactions
Horndevcommented, Jan 27, 2019

For anyone wondering, I solved this by modifying the summernote code:

HintPopover.prototype.replace = function () {
          var $item = this.$content.find('.note-hint-item.active');
          if ($item.length) {
              var node = this.nodeFromItem($item);
              // XXX: consider to move codes to editor for recording redo/undo.
              this.lastWordRange.insertNode(node);
              range.createFromNode(node).collapse().select();
              this.lastWordRange = null;
              this.hide();
              this.context.triggerEvent('change', this.$editable.html(), this.$editable[0]);
              this.context.invoke('editor.focus');
              //hack to move cursor right
              this.context.invoke('editor.pasteHTML', '&zwnj;')
          }
      };

I added the last line so that it jumps out of the span.

2reactions
Arunadevicommented, Sep 27, 2016

This method returns the original set of elements for chaining purposes.(http://api.jquery.com/wrap/).

Guess we can’t really wrap it yet.

This works: return $("<span>").html('<strong>@' + item.name + '</strong><span>&nbsp;</span>')[0]

Read more comments on GitHub >

github_iconTop Results From Across the Web

java ee 6 - Custom tag file code assist not working in Eclipse ...
1) Try Window / Preferences / Web / JSP Files / Editor / Content Assist. Make sure the HTML and XML Tag Proposals...
Read more >
How To Create Custom Automation Tags - LambdaTest
LambdaTest allows you to group your automation tests using custom tags. In this document, we will see how to create custom tags and...
Read more >
Custom Templates Guide For Google Tag Manager
A comprehensive guide to building custom templates (both tag templates and variable templates) in Google Tag Manager.
Read more >
Personalize Content with Custom Fields | Digital Range Help Center ...
You can personalize the subject line, "From" name and content of your email by inserting personalization tags based on subscriber field data.
Read more >
GitHub Actions — Run a Workflow When Creating a Tag
You can even customize the publishing process with tags to ignore. For example, if you're preparing the new major release of your project,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found