Commit ddb19780 authored by Gaurav Kapoor's avatar Gaurav Kapoor Committed by Gaurav Kapoor
Browse files

Issue #3259891 by jennypanighetti, gaurav.kapoor: CKEditor 5 dependency?

parent e0d8cf2d
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ CONTENTS OF THIS FILE
INTRODUCTION
------------

The CKEditor Tweetable Text module is an extension to the Drupal 8 CKEditor
The CKEditor Tweetable Text module is an extension to the Drupal 9 CKEditor 5
module.

Provides an input filter and WYSIWYG plugin for making text in content
@@ -29,9 +29,8 @@ REQUIREMENTS

This module requires the following outside of Drupal core.

 * CKEditor plugin library - https://ckeditor.com/cke4/addon/tweetabletext
 This library will be automatically downloaded if you install this module using
 composer. If not, run composer install to download it.
 * CKEditor plugin library - https://github.com/gkapoor121212/ckeditor5-tweetable-text
 This library has been included along with codebase of this module.


INSTALLATION
@@ -57,8 +56,7 @@ MAINTAINERS
-----------

Module created by:
 *  Vishal Gupta - https://www.drupal.org/u/vishal9619
 *  Gaurav Kapoor - https://www.drupal.org/u/gauravkapoor

Module maintained by:
 * Gaurav Kapoor - https://www.drupal.org/u/gauravkapoor
 * Anmol Goel - https://www.drupal.org/u/anmolgoyal74
+1 −4
Original line number Diff line number Diff line
{
  "name": "drupal/tweetext",
  "description": "Enables the creation of webforms and questionnaires. Provides an input filter and WYSIWYG plugin for making text in content tweetable, just by clicking on the sentence or phrase itself!",
  "description": "Provides an input filter and WYSIWYG plugin for making text in content tweetable, just by clicking on the sentence or phrase itself!",
  "type": "drupal-module",
  "license": "GPL-2.0-or-later",
  "minimum-stability": "dev",
@@ -15,8 +15,5 @@
  "support": {
    "issues": "https://www.drupal.org/project/issues/tweetext",
    "source": "https://git.drupalcode.org/project/tweetext"
  },
  "require": {
    "drupal-ckeditor-libraries-group/tweetabletext": "master"
  }
}
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+12 −6
Original line number Diff line number Diff line
@@ -86,18 +86,24 @@ export default class TweetableTextEditing extends Plugin {
			const displayText = modelItem.getAttribute('displayText');
			const tweetableTextVal = modelItem.getAttribute('tweetableTextVal');

			// Logic to convert input into a tweetable text.
			const twitterBaseUrl = 'https://twitter.com/intent/tweet?';
			const encodedValue = encodeURI( tweetableTextVal );
			const linkUrl = twitterBaseUrl + 'text=' + encodedValue;

			// Generate link element for the required Twitter link.
			const linkElement = viewWriter.createAttributeElement( 'a', { href:linkUrl }, { priority: 5 } );

			// Generate a wrapping span element around tweetable text.
			viewWriter.insert(linkElement);
			const tweetableTextView = viewWriter.createContainerElement('span', {
				class: 'tweetableText'
			}, {
				isAllowedInsideAttributeElement: true
			});

			// Logic to convert input into a tweetable text.
			const twitterBaseUrl = 'http://twitter.com/intent/tweet?';
			const encodedValue = encodeURI( tweetableTextVal );
			const linkUrl = twitterBaseUrl + 'text=' + encodedValue;

			const innerText = viewWriter.createText(displayText, { linkHref: linkUrl });
			// Generate display text and insert it in the view.
			const innerText = viewWriter.createText(displayText);
			viewWriter.insert(viewWriter.createPositionAt( tweetableTextView, 0), innerText);

			return tweetableTextView;
+0 −59
Original line number Diff line number Diff line
<?php

namespace Drupal\tweetext\Plugin\CKEditorPlugin;

use Drupal\editor\Entity\Editor;
use Drupal\ckeditor\CKEditorPluginBase;

/**
 * Defines the "tweetext" plugin.
 *
 * @CKEditorPlugin(
 *   id = "tweetabletext",
 *   label = @Translation("Tweet button"),
 *   module = "tweetext"
 * )
 */
class Tweetbutton extends CKEditorPluginBase {

  /**
   * Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile().
   */
  public function getFile() {
    return 'libraries/tweetabletext/plugin.js';
  }

  /**
   * {@inheritdoc}
   */
  public function getLibraries(Editor $editor) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function isInternal() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getButtons() {
    return [
      'TweetableText' => [
        'label' => $this->t('Tweet Button'),
        'image' => base_path() . 'libraries/tweetabletext/icons/tweetabletext.png',
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getConfig(Editor $editor) {
    return [];
  }

}
Loading