diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..cfcbb4d
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,9 @@
+# Element Link Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
+
+## 1.0.0 - 2019-05-07
+### Added
+- Initial release
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..80fd4b9
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,9 @@
+The MIT License (MIT)
+
+Copyright (c) 2019 Marion Newlevant
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fee8b3c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,33 @@
+# Element Link plugin for Craft CMS 3.x
+
+Add a link to the CP edit page for Entries, Categories, and other Elements
+
+![Screenshot](resources/screenshots/ElementLink.png)
+
+## Requirements
+
+This plugin requires Craft CMS 3.0.0-beta.23 or later.
+
+## Installation
+
+To install the plugin, follow these instructions.
+
+1. Open your terminal and go to your Craft project:
+
+ cd /path/to/project
+
+2. Then tell Composer to load the plugin:
+
+ composer require craft-element_link/element-link
+
+3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Element Link.
+
+or
+
+1. Install via the Plugin Store
+
+Brought to you by [Marion Newlevant](http://marion.newlevant.com)
+
+Inspired in part by the [Download Assets](https://plugins.craftcms.com/download-assets) plugin.
+
+Icon: link by Gregor Cresnar from the Noun Project
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..e65714a
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,43 @@
+{
+ "name": "marionnewlevant/element-link",
+ "description": "Add a link to the CP edit page for Entries, Categories, and other Elements",
+ "type": "craft-plugin",
+ "version": "1.0.0",
+ "keywords": [
+ "craft",
+ "cms",
+ "craftcms",
+ "craft-plugin",
+ "element link"
+ ],
+ "support": {
+ "docs": "https://github.com/craft-element_link/element-link/blob/master/README.md",
+ "issues": "https://github.com/craft-element_link/element-link/issues"
+ },
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Marion Newlevant",
+ "homepage": "http://marion.newlevant.com"
+ }
+ ],
+ "require": {
+ "craftcms/cms": "^3.0.0-RC1"
+ },
+ "autoload": {
+ "psr-4": {
+ "marionnewlevant\\elementlink\\": "src/"
+ }
+ },
+ "extra": {
+ "name": "Element Link",
+ "handle": "element-link",
+ "hasCpSettings": false,
+ "hasCpSection": false,
+ "changelogUrl": "https://raw.githubusercontent.com/craft-element_link/element-link/master/CHANGELOG.md",
+ "components": {
+ "elementLinkService": "marionnewlevant\\elementlink\\services\\ElementLinkService"
+ },
+ "class": "marionnewlevant\\elementlink\\ElementLink"
+ }
+}
diff --git a/resources/screenshots/ElementLink.png b/resources/screenshots/ElementLink.png
new file mode 100644
index 0000000..3029b2d
Binary files /dev/null and b/resources/screenshots/ElementLink.png differ
diff --git a/src/ElementLink.php b/src/ElementLink.php
new file mode 100644
index 0000000..dc475c0
--- /dev/null
+++ b/src/ElementLink.php
@@ -0,0 +1,87 @@
+getRequest()->getIsCpRequest() && !Craft::$app->getUser()->getIsGuest() && !Craft::$app->getRequest()->getIsAjax())
+ {
+ // Register our asset bundle
+ Craft::$app->getView()->registerAssetBundle(ElementLinkAsset::class);
+ }
+
+ Craft::info(
+ Craft::t(
+ 'element-link',
+ '{name} plugin loaded',
+ ['name' => $this->name]
+ ),
+ __METHOD__
+ );
+ }
+
+ // Protected Methods
+ // =========================================================================
+
+}
diff --git a/src/assetbundles/elementlink/ElementLinkAsset.php b/src/assetbundles/elementlink/ElementLinkAsset.php
new file mode 100644
index 0000000..4bfe508
--- /dev/null
+++ b/src/assetbundles/elementlink/ElementLinkAsset.php
@@ -0,0 +1,58 @@
+sourcePath = "@marionnewlevant/elementlink/assetbundles/elementlink/dist";
+
+ // define the dependencies
+ $this->depends = [
+ CpAsset::class,
+ ];
+
+ // define the relative path to CSS/JS files that should be registered with the page
+ // when this asset bundle is registered
+ $this->js = [
+ 'js/elementlink.js',
+ ];
+
+ $this->css = [
+ 'css/elementlink.css',
+ ];
+
+ parent::init();
+ }
+}
diff --git a/src/assetbundles/elementlink/dist/css/elementlink.css b/src/assetbundles/elementlink/dist/css/elementlink.css
new file mode 100644
index 0000000..6f85702
--- /dev/null
+++ b/src/assetbundles/elementlink/dist/css/elementlink.css
@@ -0,0 +1,66 @@
+/*
+positioning with css. The .linked class is from download assets plugin.
+*/
+/* styles to make space on the label */
+body.ltr .element.elementLinkYes .label {
+ padding-right: 20px;
+}
+body.ltr .element.elementLinkYes.linked .label {
+ padding-right: 40px;
+}
+
+body.ltr .element.removable.elementLinkYes .label {
+ padding-right: 40px;
+}
+body.ltr .element.removable.elementLinkYes.linked .label {
+ padding-right: 60px;
+}
+
+body.rtl .element.elementLinkYes .label {
+ padding-left: 20px;
+}
+body.rtl .element.elementLinkYes.linked .label {
+ padding-left: 40px;
+}
+
+body.rtl .element.removable.elementLinkYes .label {
+ padding-left: 40px;
+}
+body.rtl .element.removable.elementLinkYes.linked .label {
+ padding-left: : 60px;
+}
+
+/* anchor styles */
+body.ltr .element .elementLink {
+ position: absolute;
+ right: 22px;
+}
+
+body.ltr .element.linked .elementLink {
+ right: 42px;
+}
+
+body.rtl .element .elementLink {
+ position: absolute;
+ left: 22px;
+}
+
+body.rtl .element.linked .elementLink {
+ left: 42px;
+}
+
+.element .elementLink::before {
+ content: '';
+ display: inline-block;
+ width: 19px;
+ height: 14px;
+ background-image: url('../img/elementLink.svg');
+ background-size: 19px 14px;
+ line-height: 1;
+ vertical-align: middle;
+}
+
+.element .elementLink:hover::before {
+ background-image: url('../img/elementLink-focus.svg');
+}
+
diff --git a/src/assetbundles/elementlink/dist/img/elementLink-focus.svg b/src/assetbundles/elementlink/dist/img/elementLink-focus.svg
new file mode 100644
index 0000000..57535a0
--- /dev/null
+++ b/src/assetbundles/elementlink/dist/img/elementLink-focus.svg
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/src/assetbundles/elementlink/dist/img/elementLink.svg b/src/assetbundles/elementlink/dist/img/elementLink.svg
new file mode 100644
index 0000000..eb3a46a
--- /dev/null
+++ b/src/assetbundles/elementlink/dist/img/elementLink.svg
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/src/assetbundles/elementlink/dist/js/elementlink.js b/src/assetbundles/elementlink/dist/js/elementlink.js
new file mode 100644
index 0000000..c866d9e
--- /dev/null
+++ b/src/assetbundles/elementlink/dist/js/elementlink.js
@@ -0,0 +1,39 @@
+$(function () { // for namespacing if nothing else...
+ var g_lastRequest = null;
+
+ // called every second to look for new elements to add the cp link to
+ var addLinks = function() {
+ // find the elements not yet tagged w/ class .elementLink
+ var $elements = $('.field .input .element:not(.elementLink)');
+
+ $elements.each(function() {
+ var $thisElement = $(this);
+ var $label = $thisElement.find('.label');
+ $thisElement.addClass('elementLink');
+ // phone home to get the cpEditUrl for the element
+ g_lastRequest = Craft.postActionRequest(
+ 'element-link/default/element-edit-url',
+ {
+ elementType: $thisElement.data('type'),
+ elementId: $thisElement.data('id'),
+ siteId: $thisElement.data('site-id')
+ },
+ function(response, textStatus) {
+ if (textStatus == 'success' && response && response['editUrl']) {
+ // add the link to the dom
+ $thisElement.addClass('elementLinkYes');
+ var $a = $('', {
+ class: 'elementLink',
+ target: '_blank',
+ href: response['editUrl']
+ });
+ $a.insertBefore($label);
+ }
+ }
+ );
+ });
+ };
+
+ addLinks();
+ window.setInterval(addLinks, 1000);
+});
\ No newline at end of file
diff --git a/src/controllers/DefaultController.php b/src/controllers/DefaultController.php
new file mode 100644
index 0000000..54d33cb
--- /dev/null
+++ b/src/controllers/DefaultController.php
@@ -0,0 +1,79 @@
+requireAcceptsJson();
+
+ $elementId = (int)(Craft::$app->getRequest()->getBodyParam('elementId'));
+ $elementType = Craft::$app->getRequest()->getBodyParam('elementType');
+ $siteId = (int)(Craft::$app->getRequest()->getBodyParam('siteId'));
+
+ $editUrl = ElementLink::$plugin->elementLinkService->editUrl($elementId, $elementType, $siteId);
+
+ if ($editUrl)
+ {
+ $json = $this->asJson([
+ 'success' => true,
+ 'editUrl' => $editUrl,
+ ]);
+ return $json;
+
+ }
+ else
+ {
+ $json = $this->asJson([
+ 'success' => false,
+ 'error' => 'no cpEditUrl',
+ ]);
+ return $json;
+ }
+ }
+}
diff --git a/src/icon.svg b/src/icon.svg
new file mode 100644
index 0000000..dc678da
--- /dev/null
+++ b/src/icon.svg
@@ -0,0 +1,13 @@
+
+
\ No newline at end of file
diff --git a/src/services/ElementLinkService.php b/src/services/ElementLinkService.php
new file mode 100644
index 0000000..3acec86
--- /dev/null
+++ b/src/services/ElementLinkService.php
@@ -0,0 +1,54 @@
+elementLinkService->editUrl()
+ *
+ * @return mixed
+ */
+ public function editUrl(int $elementId, string $elementType, int $siteId)
+ {
+ $element = Craft::$app->elements->getElementById($elementId, $elementType, $siteId);
+ if ($element)
+ {
+ return $element->cpEditUrl;
+ }
+ return null;
+ }
+}
diff --git a/src/translations/en/element-link.php b/src/translations/en/element-link.php
new file mode 100644
index 0000000..d9321d7
--- /dev/null
+++ b/src/translations/en/element-link.php
@@ -0,0 +1,25 @@
+ 'Element Link plugin loaded',
+];