BitPoet

ProcessMention: "Forum Mentions" style page link autocomplete for CKEditor

Recommended Posts

Since I was stuck to my flat today I took up a wish and rolled a Process module / CKEditor plugin combo that adds @-autocomplete like the mentions here in the forum to CKEditor fields. It's configurable, but only in module settings for now, the positioning of the select list is quite off and there's still some visual work to be done, so it is in early alpha state.

Nonetheless, if you want to take a look, here it is:
https://github.com/BitPoet/ProcessMention

ProcessMention.thumb.gif.95c93384bdb4430cbfb2be50f34d23ec.gif

 

After installation, you may want to look into the "Additional selector" entry in the module's settings. You will most likely want to limit results to certain templates there.

 

Edit: Updated to version 0.0.30 with fixed positioning of the dropdown.
Edit2: Settings are configurable in field context now. If pwmentions is enabled, the according settings are shown on the "Input" tab.

 

  • Like 13

Share this post


Link to post
Share on other sites

very cool, this will be very useful!

Share this post


Link to post
Share on other sites

@BitPoet,

thank you for your effort. ;)

I tried your ProcessMention module, and it does not work (see below). However, ...

... I could suggest:

  • In the README.md file > Installation, you can add the step "Copy ProcessMention.css and ProcessMention.module from the module folder to the site/modules/InputfieldCKEditor directory.

... I have to say:

  • Rather than querying the server every time via Ajax to get mentions, you could cache the mentions client-side (in a hidden HTML element, local storage or JS config) - credit
  • Of course, the output  (e.g. fix positioning of selection list in plugin.js) is important.

Regarding my issue with the ProcessMention module, when I type the e.g. @Sca text then the Ajax-HTTP request is fired but I get the following Network Headers:

ProcessMention-Network_Headers.jpg.15210dae3568728386b8dadfef57f7e3.jpg

Note: In the image, the gray-covered areas are the path to access the admin of my PW installation.

P.S.: I read the code and I would help someway, but I have to learn a little more about github and the languages. :rolleyes:

 

Share this post


Link to post
Share on other sites

@LAPS: thanks for the feedback. I'm not sure how the redirect comes to be and need to ponder that and perhaps run some more tests. What PW version are you on? Do you have languages active?

The positioning issue has meanwhile been fixed.

6 hours ago, LAPS said:

In the README.md file > Installation, you can add the step "Copy ProcessMention.css and ProcessMention.module from the module folder to the site/modules/InputfieldCKEditor directory.

This isn't necessary. The .module and .css file are fine in their own module directory underneath site/modules (and keeping two copies under site/modules is like to lead to trouble). It's just the plugin.js that needs to go into the InputfieldCKEditor/plugins/pwmentions path so both the editor and PW can pick it up.

I'm not sure client side caching is much of an issue, as every keystroke will change the result list and the unfiltered list might be far too long to download. I usually only do that with decent sized lists when I perform client-side filtering.

Share this post


Link to post
Share on other sites

Update: settings can now be changed on per-field basis on the fields' "Input" tab. Latest version is on github.

Share this post


Link to post
Share on other sites

@BitPoet The module doesn't remove the mention page on uninstall, it's not found because it's hidden.

If you create it in the getModuleInfo method it will be removed by PW on uninstall.

public static function getModuleInfo() {
	return array(
		...
		"page" => [
			"name" => "mention",
			"title" => "Mention",
			"status" => "hidden"
		]
	);
}

 

Share this post


Link to post
Share on other sites

@fbg13: Good point, thanks. I have incorporated that. Makes the code a lot shorter too :)

  • Like 1

Share this post


Link to post
Share on other sites
On 22/01/2018 at 6:28 AM, BitPoet said:

I'm not sure how the redirect comes to be and need to ponder that and perhaps run some more tests. What PW version are you on? Do you have languages active?

I am using ProcessWire 3.0.62 and I do not have languages active.

I installed the latest version of ProcessMention, but I continue to get the '301 Moved Permanently' from http://localhost:8888/ADMIN-PATH/mention.

However, if I use http://127.0.0.1:8888/ADMIN-PATH/mention, it seems to work a little more: I get a 200 OK response but the "list of mentions" is not populated because the response code is an entire HTML page (including css, js, etc.).

Share this post


Link to post
Share on other sites

@LAPS: I just tested it with a stock 3.0.62 (basic profile) in different browsers and the module works there, so it's likely some leftover / failed cleanup from an older install. Can you uninstall the module in the backend and make sure that you don't have any pages named "mention" in the page tree under Admin? If yes, just delete it manually. Also, please check that you don't have an older module version lying around in the InputfieldCKEditor directory.

Then, best download the very latest version (0.0.70) from the github repo  and install that. Don't forget to copy plugins.js into the correct path, and best clear your browser cache. After installing the module, you should see a page titled "Mention Autocomplete" in the page tree under Admin.

  • Like 1

Share this post


Link to post
Share on other sites

Glad to hear :) Then all that's left is a webserver or hostname lookup configuration issue. Probably related to IPv6. Disabling IPv6 in the web server may be enough to fix this.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      Checkbox Reversed
      Modifies InputfieldCheckbox so that it shows the reverse of its true value. The checkbox will be unchecked when the field value is 1 and checked when the field value is not 1.
      Background
      The core FieldtypeCheckbox does not have a setting that allows a checkbox to be checked by default. One reason for this is that only a checked field saves a value to the database. An unchecked field does not save "0" to the database, but rather does not save any value for the field at all. Therefore there is no way to distinguish between a new field that has not yet been saved (and therefore could potentially get a default checked state) and a field that has deliberately been saved as unchecked.
      Because of this you sometimes have to use a checkbox in the opposite way than you would like. Suppose your client has requested a checkbox labelled "Bootylicious" that will be checked by default. This isn't possible with FieldtypeCheckbox so instead you have to convince them that a checkbox labelled "Not bootylicious" that is unchecked by default is just as good. This alternative will achieve the same thing, but it's not ideal.
      A solution
      This module doesn't change the limitations of the core checkbox field, but it provides a workaround that allows you to show the checkbox with the desired default state and label. So in the example above you would still name the field "not_bootylicious" (otherwise it could get confusing in your template files) but you can label the field "Bootylicious" and the checkbox will appear checked when its true value is actually unchecked, and vice versa. This allows new pages to show the checkbox checked by default. Clear as mud?
      Usage
      Install the Checkbox Reversed module.
      For any Checkbox field where you want the inputfield to show the reverse of its true value, activate the "Reverse the checked state of this inputfield?" option in the field settings.

       
      https://github.com/Toutouwai/CheckboxReversed
      http://modules.processwire.com/modules/checkbox-reversed/
    • By louisstephens
      I have been following @bernhard's great tutorial on creating a Dashboard and everything has very easy to understand so far. However, I need to add a select field that a template is using (so users can create a new page from the dashboard), but I am really at a complete lost on how to achieve this. I have been googling, but can't really find anything on the matter.
      $field = $this->modules->get('InputfieldSelect'); $field->name = "Select Manufacturer"; $field->findPagesSelector = "template=basic-page"; //not needed for select field $field->labelFieldName = "title"; $field->name = "Manufacturer Select"; $field->columnWidth = 34; $fieldset->add($field); I have the above code, which was originally an InputfieldPage, but since this is an options field, I have changed it. Has anyone actually gotten a select from a template (and its' values) in a module?
    • By Lex Sanchez
      Video or Social Post Embed
      Based on the TextformatterVideoEmbed module developed by Ryan Cramer, we have added the possibility to embed publications of the main social networks Facebook, Twitter and Instagram.
      ProcessWire Textformatter module that enables translation of YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu URLs to full embed codes, resulting in a viewable video or social post in textarea fields you apply it to.
      How to install
      Download or Clone from Github: https://github.com/lexsanchez/VideoOrSocialPostEmbed
      Copy the VideoOrSocialPostEmbed.module file to your /site/modules/ directory (or place it in /site/modules/VideoOrSocialPostEmbed/).
      Click check for new modules in ProcessWire Admin Modules screen. Click install for the module labeled: "Video or Social Post Embed".
      Now you will be on the module config screen. Please make note of the config options and set as you see fit.
      How to use
      Edit your body field in Setup > Fields (or whatever field(s) you will be placing videos in). On the details tab, find the Text Formatters field and select "Video or Social Post Embed". Save.
      Edit a page using the field you edited and paste in YouTube, Vimeo, Facebook, Twitter, Instagram and/or Issuu URLs each on their own paragraph.
      Example
      How it might look in your editor (like TinyMCE):
      How it works
      This module uses YouTube, Vimeo, Instagram, Facebook, Twitter and Issuu oEmbed services to generate the embed codes populated in your content. After these services are queried the first time, the embed code is cached so that it doesn't need to be pulled again.
      Configuration
      You may want to update the max width and max height settings on the module's configuration screen. You should make these consistent with what is supported by your site design.
      If you change these max width / max height settings you may also want to check the box to clear cache, so that YouTube/Vimeo/Facebook/Twitter/Instagram/Issuu oembed services will generate new embed codes for you.
      Using with Markdown, Textile or other LML
      This text formatter is looking for a YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu video URL surrounded by paragraph tags. As a result, if you are using Markdown or Textile (or something else like it) you want that text formatter to run before this one. That ensures that the expected paragraph tags will be present when VideoOrSocialPostEmbed runs. You can control the order that text formatters are run in by drag/drop sorting in the field editor.
      Copyright 2018 by Ryan Cramer / Updated by Lex Sanchez
    • By kixe
      Email Verification
      This module provides functions to validate email adresses and hosts. The module generates a textfile for blacklisted mailhosts (trashmail), which will be always up to date.
      Download
      https://modules.processwire.com/modules/email-verification/
      API
      // get module $mailcheck = $modules->get('EmailVerification'); // return bool/ string - automatted update of blacklist file $mailcheck->blacklisted(email|domain) // return bool - validate a top level domain, checks against IANA list $mailcheck->validTLD(tld) // return array of punycoded TLDs - cyclic updated, data pulled from IANA $mailcheck->getTLDs(cycle=2592000) // return bool - checks syntax converts to punycode $mailcheck->validDomainName(domain); // return bool - checks punycode encoded syntax $mailcheck->validHostName(host); // return bool - checks syntax and accessibility $mailcheck->validHost(email|domain) // add a single value to blacklist $mailcheck->addToBlacklist(email|domain) USAGE
      $mailcheck = $modules->get('EmailCheck'); $email = 'susi@trashmail.com'; if($mailcheck->blacklisted($email)) echo 'Email Provider not allowed'; if(!$mailcheck->validHost($email)) echo 'Mailhost not available'; Example blacklist file:  blacklist.txt