<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][12747] trunk/src: BP Blocks: introduce the first BP Activity Block {U+01F64C}</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/12747">12747</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/12747","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-10-10 18:06:52 +0000 (Sat, 10 Oct 2020)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>BP Blocks: introduce the first BP Activity Block {U+01F64C}

To use this block, you simply need to paste the permalink of a single activity to embed it the block's placeholder. It will include the activity embed into your post or page.

Props espellcaste, imath

See <a href="http://buddypress.trac.wordpress.org/ticket/8369">#8369</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpactivityclassesclassbpactivitycomponentphp">trunk/src/bp-activity/classes/class-bp-activity-component.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcbpactivitybpactivityblocksphp">trunk/src/bp-activity/bp-activity-blocks.php</a></li>
<li>trunk/src/bp-activity/js/blocks/</li>
<li><a href="#trunksrcbpactivityjsblocksembedactivityjs">trunk/src/bp-activity/js/blocks/embed-activity.js</a></li>
<li>trunk/src/js/bp-activity/</li>
<li>trunk/src/js/bp-activity/js/</li>
<li>trunk/src/js/bp-activity/js/blocks/</li>
<li><a href="#trunksrcjsbpactivityjsblocksbabelrc">trunk/src/js/bp-activity/js/blocks/.babelrc</a></li>
<li>trunk/src/js/bp-activity/js/blocks/embed-activity/</li>
<li><a href="#trunksrcjsbpactivityjsblocksembedactivityeditjs">trunk/src/js/bp-activity/js/blocks/embed-activity/edit.js</a></li>
<li><a href="#trunksrcjsbpactivityjsblocksembedactivitysavejs">trunk/src/js/bp-activity/js/blocks/embed-activity/save.js</a></li>
<li><a href="#trunksrcjsbpactivityjsblocksembedactivityjs">trunk/src/js/bp-activity/js/blocks/embed-activity.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpactivitybpactivityblocksphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-activity/bp-activity-blocks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/bp-activity-blocks.php                              (rev 0)
+++ trunk/src/bp-activity/bp-activity-blocks.php        2020-10-10 18:06:52 UTC (rev 12747)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,33 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * BP Activity Blocks Functions.
+ *
+ * @package BuddyPress
+ * @subpackage ActvityBlocks
+ * @since 7.0.0
+ */
+
+// Exit if accessed directly.
+if ( ! defined( 'ABSPATH' ) ) {
+       exit;
+}
+
+/**
+ * Add BP Activity blocks specific settings to the BP Blocks Editor ones.
+ *
+ * @since 7.0.0
+ *
+ * @param array $bp_editor_settings BP blocks editor settings.
+ * @return array BP Activity blocks editor settings.
+ */
+function bp_activity_editor_settings( $bp_editor_settings = array() ) {
+       return array_merge(
+               $bp_editor_settings,
+               array(
+                       'activity' => array(
+                               'embedScriptURL' => includes_url( 'js/wp-embed.min.js' ),
+                       ),
+               )
+       );
+}
+add_filter( 'bp_blocks_editor_settings', 'bp_activity_editor_settings' );
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/bp-activity/bp-activity-blocks.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcbpactivityclassesclassbpactivitycomponentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-activity/classes/class-bp-activity-component.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/classes/class-bp-activity-component.php     2020-10-10 14:00:44 UTC (rev 12746)
+++ trunk/src/bp-activity/classes/class-bp-activity-component.php       2020-10-10 18:06:52 UTC (rev 12747)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -55,7 +55,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'adminbar',
</span><span class="cx" style="display: block; padding: 0 10px">                        'template',
</span><span class="cx" style="display: block; padding: 0 10px">                        'functions',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'cache'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'cache',
+                       'blocks',
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Notifications support.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -472,4 +473,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function rest_api_init( $controllers = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px">                parent::rest_api_init( array( 'BP_REST_Activity_Endpoint' ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Register the BP Activity Blocks.
+        *
+        * @since 7.0.0
+        *
+        * @param array $blocks Optional. See BP_Component::blocks_init() for
+        *                      description.
+        */
+       public function blocks_init( $blocks = array() ) {
+               parent::blocks_init(
+                       array(
+                               'bp/embed-activity' => array(
+                                       'name'               => 'bp/embed-activity',
+                                       'editor_script'      => 'bp-embed-activity-block',
+                                       'editor_script_url'  => plugins_url( 'js/blocks/embed-activity.js', dirname(  __FILE__ ) ),
+                                       'editor_script_deps' => array(
+                                               'wp-blocks',
+                                               'wp-element',
+                                               'wp-i18n',
+                                               'wp-components',
+                                               'wp-block-editor',
+                                               'wp-data',
+                                               'wp-compose',
+                                       ),
+                               ),
+                       )
+               );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcbpactivityjsblocksembedactivityjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-activity/js/blocks/embed-activity.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/js/blocks/embed-activity.js                         (rev 0)
+++ trunk/src/bp-activity/js/blocks/embed-activity.js   2020-10-10 18:06:52 UTC (rev 12747)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,445 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// modules are defined as an array
+// [ module function, map of requires ]
+//
+// map of requires is short require name -> numeric require
+//
+// anything defined in a previous bundle is accessed via the
+// orig method which is the require for previous bundles
+parcelRequire = (function (modules, cache, entry, globalName) {
+  // Save the require from previous bundle to this closure if any
+  var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
+  var nodeRequire = typeof require === 'function' && require;
+
+  function newRequire(name, jumped) {
+    if (!cache[name]) {
+      if (!modules[name]) {
+        // if we cannot find the module within our internal map or
+        // cache jump to the current global require ie. the last bundle
+        // that was added to the page.
+        var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
+        if (!jumped && currentRequire) {
+          return currentRequire(name, true);
+        }
+
+        // If there are other bundles on this page the require from the
+        // previous one is saved to 'previousRequire'. Repeat this as
+        // many times as there are bundles until the module is found or
+        // we exhaust the require chain.
+        if (previousRequire) {
+          return previousRequire(name, true);
+        }
+
+        // Try the node require function if it exists.
+        if (nodeRequire && typeof name === 'string') {
+          return nodeRequire(name);
+        }
+
+        var err = new Error('Cannot find module \'' + name + '\'');
+        err.code = 'MODULE_NOT_FOUND';
+        throw err;
+      }
+
+      localRequire.resolve = resolve;
+      localRequire.cache = {};
+
+      var module = cache[name] = new newRequire.Module(name);
+
+      modules[name][0].call(module.exports, localRequire, module, module.exports, this);
+    }
+
+    return cache[name].exports;
+
+    function localRequire(x){
+      return newRequire(localRequire.resolve(x));
+    }
+
+    function resolve(x){
+      return modules[name][1][x] || x;
+    }
+  }
+
+  function Module(moduleName) {
+    this.id = moduleName;
+    this.bundle = newRequire;
+    this.exports = {};
+  }
+
+  newRequire.isParcelRequire = true;
+  newRequire.Module = Module;
+  newRequire.modules = modules;
+  newRequire.cache = cache;
+  newRequire.parent = previousRequire;
+  newRequire.register = function (id, exports) {
+    modules[id] = [function (require, module) {
+      module.exports = exports;
+    }, {}];
+  };
+
+  var error;
+  for (var i = 0; i < entry.length; i++) {
+    try {
+      newRequire(entry[i]);
+    } catch (e) {
+      // Save first error but execute all entries
+      if (!error) {
+        error = e;
+      }
+    }
+  }
+
+  if (entry.length) {
+    // Expose entry point to Node, AMD or browser globals
+    // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
+    var mainExports = newRequire(entry[entry.length - 1]);
+
+    // CommonJS
+    if (typeof exports === "object" && typeof module !== "undefined") {
+      module.exports = mainExports;
+
+    // RequireJS
+    } else if (typeof define === "function" && define.amd) {
+     define(function () {
+       return mainExports;
+     });
+
+    // <script>
+    } else if (globalName) {
+      this[globalName] = mainExports;
+    }
+  }
+
+  // Override the current require with this new one
+  parcelRequire = newRequire;
+
+  if (error) {
+    // throw error from earlier, _after updating parcelRequire_
+    throw error;
+  }
+
+  return newRequire;
+})({"dEOc":[function(require,module,exports) {
+function _arrayWithHoles(arr) {
+  if (Array.isArray(arr)) return arr;
+}
+
+module.exports = _arrayWithHoles;
+},{}],"RonT":[function(require,module,exports) {
+function _iterableToArrayLimit(arr, i) {
+  if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
+  var _arr = [];
+  var _n = true;
+  var _d = false;
+  var _e = undefined;
+
+  try {
+    for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
+      _arr.push(_s.value);
+
+      if (i && _arr.length === i) break;
+    }
+  } catch (err) {
+    _d = true;
+    _e = err;
+  } finally {
+    try {
+      if (!_n && _i["return"] != null) _i["return"]();
+    } finally {
+      if (_d) throw _e;
+    }
+  }
+
+  return _arr;
+}
+
+module.exports = _iterableToArrayLimit;
+},{}],"LGpM":[function(require,module,exports) {
+function _arrayLikeToArray(arr, len) {
+  if (len == null || len > arr.length) len = arr.length;
+
+  for (var i = 0, arr2 = new Array(len); i < len; i++) {
+    arr2[i] = arr[i];
+  }
+
+  return arr2;
+}
+
+module.exports = _arrayLikeToArray;
+},{}],"Vzqv":[function(require,module,exports) {
+var arrayLikeToArray = require("./arrayLikeToArray");
+
+function _unsupportedIterableToArray(o, minLen) {
+  if (!o) return;
+  if (typeof o === "string") return arrayLikeToArray(o, minLen);
+  var n = Object.prototype.toString.call(o).slice(8, -1);
+  if (n === "Object" && o.constructor) n = o.constructor.name;
+  if (n === "Map" || n === "Set") return Array.from(n);
+  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
+}
+
+module.exports = _unsupportedIterableToArray;
+},{"./arrayLikeToArray":"LGpM"}],"sa4T":[function(require,module,exports) {
+function _nonIterableRest() {
+  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+}
+
+module.exports = _nonIterableRest;
+},{}],"xkYc":[function(require,module,exports) {
+var arrayWithHoles = require("./arrayWithHoles");
+
+var iterableToArrayLimit = require("./iterableToArrayLimit");
+
+var unsupportedIterableToArray = require("./unsupportedIterableToArray");
+
+var nonIterableRest = require("./nonIterableRest");
+
+function _slicedToArray(arr, i) {
+  return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
+}
+
+module.exports = _slicedToArray;
+},{"./arrayWithHoles":"dEOc","./iterableToArrayLimit":"RonT","./unsupportedIterableToArray":"Vzqv","./nonIterableRest":"sa4T"}],"Sjre":[function(require,module,exports) {
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.default = void 0;
+
+var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * WordPress dependencies.
+ */
+var _wp = wp,
+    _wp$element = _wp.element,
+    createElement = _wp$element.createElement,
+    Fragment = _wp$element.Fragment,
+    useState = _wp$element.useState,
+    __ = _wp.i18n.__,
+    _wp$components = _wp.components,
+    Placeholder = _wp$components.Placeholder,
+    SandBox = _wp$components.SandBox,
+    Button = _wp$components.Button,
+    ExternalLink = _wp$components.ExternalLink,
+    Spinner = _wp$components.Spinner,
+    Toolbar = _wp$components.Toolbar,
+    ToolbarButton = _wp$components.ToolbarButton,
+    compose = _wp.compose.compose,
+    withSelect = _wp.data.withSelect,
+    _wp$blockEditor = _wp.blockEditor,
+    RichText = _wp$blockEditor.RichText,
+    BlockControls = _wp$blockEditor.BlockControls;
+
+var EditEmbedActivity = function EditEmbedActivity(_ref) {
+  var attributes = _ref.attributes,
+      setAttributes = _ref.setAttributes,
+      isSelected = _ref.isSelected,
+      bpSettings = _ref.bpSettings,
+      preview = _ref.preview,
+      fetching = _ref.fetching;
+  var url = attributes.url,
+      caption = attributes.caption;
+  var embedScriptURL = bpSettings.embedScriptURL;
+
+  var label = __('BuddyPress Activity URL', 'buddypress');
+
+  var _useState = useState(url),
+      _useState2 = (0, _slicedToArray2.default)(_useState, 2),
+      value = _useState2[0],
+      setURL = _useState2[1];
+
+  var _useState3 = useState(!url),
+      _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
+      isEditingURL = _useState4[0],
+      setIsEditingURL = _useState4[1];
+
+  var onSubmit = function onSubmit(event) {
+    if (event) {
+      event.preventDefault();
+    }
+
+    setIsEditingURL(false);
+    setAttributes({
+      url: value
+    });
+  };
+
+  var switchBackToURLInput = function switchBackToURLInput(event) {
+    if (event) {
+      event.preventDefault();
+    }
+
+    setIsEditingURL(true);
+  };
+
+  var editToolbar = createElement(BlockControls, null, createElement(Toolbar, null, createElement(ToolbarButton, {
+    icon: "edit",
+    title: __('Edit URL', 'buddypress'),
+    onClick: switchBackToURLInput
+  })));
+
+  if (isEditingURL) {
+    return createElement(Placeholder, {
+      icon: "buddicons-activity",
+      label: label,
+      className: "wp-block-embed",
+      instructions: __('Paste the link to the activity content you want to display on your site.', 'buddypress')
+    }, createElement("form", {
+      onSubmit: onSubmit
+    }, createElement("input", {
+      type: "url",
+      value: value || '',
+      className: "components-placeholder__input",
+      "aria-label": label,
+      placeholder: __('Enter URL to embed here…', 'buddypress'),
+      onChange: function onChange(event) {
+        return setURL(event.target.value);
+      }
+    }), createElement(Button, {
+      isPrimary: true,
+      type: "submit"
+    }, __('Embed', 'buddypress'))), createElement("div", {
+      className: "components-placeholder__learn-more"
+    }, createElement(ExternalLink, {
+      href: __('https://codex.buddypress.org/activity-embeds/')
+    }, __('Learn more about activity embeds', 'buddypress'))));
+  }
+
+  if (fetching) {
+    return createElement("div", {
+      className: "wp-block-embed is-loading"
+    }, createElement(Spinner, null), createElement("p", null, __('Embedding…', 'buddypress')));
+  }
+
+  if (!preview || !preview['x_buddypress'] || 'activity' !== preview['x_buddypress']) {
+    // Reset the URL.
+    setAttributes({
+      url: ''
+    });
+    return createElement(Fragment, null, editToolbar, createElement(Placeholder, {
+      icon: "buddicons-activity",
+      label: label
+    }, createElement("p", {
+      className: "components-placeholder__error"
+    }, __('The URL you provided is not a permalink to a BuddyPress Activity. Please use another URL.', 'buddypress'))));
+  }
+
+  return createElement(Fragment, null, !isEditingURL && editToolbar, createElement("figure", {
+    className: "wp-block-embed is-type-bp-activity"
+  }, createElement("div", {
+    className: "wp-block-embed__wrapper"
+  }, createElement(SandBox, {
+    html: preview && preview.html ? preview.html : '',
+    scripts: [embedScriptURL]
+  })), (!RichText.isEmpty(caption) || isSelected) && createElement(RichText, {
+    tagName: "figcaption",
+    placeholder: __('Write caption…', 'buddypress'),
+    value: caption,
+    onChange: function onChange(value) {
+      return setAttributes({
+        caption: value
+      });
+    },
+    inlineToolbar: true
+  })));
+};
+
+var editEmbedActivityBlock = compose([withSelect(function (select, ownProps) {
+  var url = ownProps.attributes.url;
+  var editorSettings = select('core/editor').getEditorSettings();
+
+  var _select = select('core'),
+      getEmbedPreview = _select.getEmbedPreview,
+      isRequestingEmbedPreview = _select.isRequestingEmbedPreview;
+
+  var preview = undefined !== url && getEmbedPreview(url);
+  var fetching = undefined !== url && isRequestingEmbedPreview(url);
+  return {
+    bpSettings: editorSettings.bp.activity || {},
+    preview: preview,
+    fetching: fetching
+  };
+})])(EditEmbedActivity);
+var _default = editEmbedActivityBlock;
+exports.default = _default;
+},{"@babel/runtime/helpers/slicedToArray":"xkYc"}],"zmBI":[function(require,module,exports) {
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.default = void 0;
+
+/**
+ * WordPress dependencies.
+ */
+var _wp = wp,
+    RichText = _wp.blockEditor.RichText,
+    createElement = _wp.element.createElement;
+
+var saveEmbedActivityBlock = function saveEmbedActivityBlock(_ref) {
+  var attributes = _ref.attributes;
+  var url = attributes.url,
+      caption = attributes.caption;
+
+  if (!url) {
+    return null;
+  }
+
+  return createElement("figure", {
+    className: "wp-block-embed is-type-bp-activity"
+  }, createElement("div", {
+    className: "wp-block-embed__wrapper"
+  }, "\n".concat(url, "\n")
+  /* URL needs to be on its own line. */
+  ), !RichText.isEmpty(caption) && createElement(RichText.Content, {
+    tagName: "figcaption",
+    value: caption
+  }));
+};
+
+var _default = saveEmbedActivityBlock;
+exports.default = _default;
+},{}],"hBDw":[function(require,module,exports) {
+"use strict";
+
+var _edit = _interopRequireDefault(require("./embed-activity/edit"));
+
+var _save = _interopRequireDefault(require("./embed-activity/save"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * WordPress dependencies.
+ */
+var _wp = wp,
+    __ = _wp.i18n.__,
+    registerBlockType = _wp.blocks.registerBlockType;
+/**
+ * Internal dependencies.
+ */
+
+registerBlockType('bp/embed-activity', {
+  title: __('Embed an activity', 'buddypress'),
+  description: __('Add a block that displays the activity content pulled from this or other community sites.', 'buddypress'),
+  icon: 'buddicons-activity',
+  category: 'buddypress',
+  attributes: {
+    url: {
+      type: 'string'
+    },
+    caption: {
+      type: 'string',
+      source: 'html',
+      selector: 'figcaption'
+    }
+  },
+  supports: {
+    align: true
+  },
+  edit: _edit.default,
+  save: _save.default
+});
+},{"./embed-activity/edit":"Sjre","./embed-activity/save":"zmBI"}]},{},["hBDw"], null)
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/bp-activity/js/blocks/embed-activity.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcjsbpactivityjsblocksbabelrc"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-activity/js/blocks/.babelrc</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-activity/js/blocks/.babelrc                               (rev 0)
+++ trunk/src/js/bp-activity/js/blocks/.babelrc 2020-10-10 18:06:52 UTC (rev 12747)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,3 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+{
+       "presets": ["@wordpress/default"]
+}
</ins></span></pre></div>
<a id="trunksrcjsbpactivityjsblocksembedactivityeditjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-activity/js/blocks/embed-activity/edit.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-activity/js/blocks/embed-activity/edit.js                         (rev 0)
+++ trunk/src/js/bp-activity/js/blocks/embed-activity/edit.js   2020-10-10 18:06:52 UTC (rev 12747)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,183 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * WordPress dependencies.
+ */
+const {
+       element: {
+               createElement,
+               Fragment,
+               useState,
+       },
+       i18n: {
+               __,
+       },
+       components: {
+               Placeholder,
+               SandBox,
+               Button,
+               ExternalLink,
+               Spinner,
+               Toolbar,
+               ToolbarButton,
+       },
+       compose: {
+               compose,
+       },
+       data: {
+               withSelect,
+       },
+       blockEditor: {
+               RichText,
+               BlockControls,
+       }
+} = wp;
+
+const EditEmbedActivity = ( {
+       attributes,
+       setAttributes,
+       isSelected,
+       bpSettings,
+       preview,
+       fetching
+} ) => {
+       const { url, caption } = attributes;
+       const { embedScriptURL } = bpSettings;
+       const label = __( 'BuddyPress Activity URL', 'buddypress' );
+       const [ value, setURL ] = useState( url );
+       const [ isEditingURL, setIsEditingURL ] = useState( ! url );
+
+       const onSubmit = ( event ) => {
+               if ( event ) {
+                       event.preventDefault();
+               }
+
+               setIsEditingURL( false );
+               setAttributes( { url: value } );
+       };
+
+       const switchBackToURLInput = ( event ) => {
+               if ( event ) {
+                       event.preventDefault();
+               }
+
+               setIsEditingURL( true );
+       };
+
+       const editToolbar = (
+               <BlockControls>
+                       <Toolbar>
+                               <ToolbarButton
+                                       icon="edit"
+                                       title={ __( 'Edit URL', 'buddypress' ) }
+                                       onClick={ switchBackToURLInput }
+                               />
+                       </Toolbar>
+               </BlockControls>
+       );
+
+       if ( isEditingURL ) {
+               return (
+                       <Placeholder
+                               icon="buddicons-activity"
+                               label={ label }
+                               className="wp-block-embed"
+                               instructions={ __( 'Paste the link to the activity content you want to display on your site.', 'buddypress' ) }
+                       >
+                               <form onSubmit={ onSubmit }>
+                                       <input
+                                               type="url"
+                                               value={ value || '' }
+                                               className="components-placeholder__input"
+                                               aria-label={ label }
+                                               placeholder={ __( 'Enter URL to embed here…', 'buddypress' ) }
+                                               onChange={ ( event ) => setURL( event.target.value ) }
+                                       />
+                                       <Button isPrimary type="submit">
+                                               { __( 'Embed', 'buddypress' ) }
+                                       </Button>
+                               </form>
+                               <div className="components-placeholder__learn-more">
+                                       <ExternalLink
+                                               href={ __(
+                                                       'https://codex.buddypress.org/activity-embeds/'
+                                               ) }
+                                       >
+                                               { __( 'Learn more about activity embeds', 'buddypress' ) }
+                                       </ExternalLink>
+                               </div>
+                       </Placeholder>
+               );
+       }
+
+       if ( fetching ) {
+               return (
+                       <div className="wp-block-embed is-loading">
+                               <Spinner />
+                               <p>{ __( 'Embedding…', 'buddypress' ) }</p>
+                       </div>
+               );
+       }
+
+       if ( ! preview || ! preview['x_buddypress'] || 'activity' !== preview['x_buddypress'] ) {
+               // Reset the URL.
+               setAttributes( { url: '' } );
+
+               return (
+                       <Fragment>
+                               { editToolbar }
+                               <Placeholder
+                                       icon="buddicons-activity"
+                                       label={ label }
+                               >
+                                       <p className="components-placeholder__error">
+                                               { __( 'The URL you provided is not a permalink to a BuddyPress Activity. Please use another URL.', 'buddypress' ) }
+                                       </p>
+                               </Placeholder>
+                       </Fragment>
+               );
+       }
+
+       return (
+               <Fragment>
+                       { ! isEditingURL && editToolbar }
+                       <figure className="wp-block-embed is-type-bp-activity">
+                               <div className="wp-block-embed__wrapper">
+                                       <SandBox
+                                               html={ preview && preview.html ? preview.html : '' }
+                                               scripts={ [ embedScriptURL ] }
+                                       />
+                               </div>
+                               { ( ! RichText.isEmpty( caption ) || isSelected ) && (
+                                       <RichText
+                                               tagName="figcaption"
+                                               placeholder={ __( 'Write caption…', 'buddypress' ) }
+                                               value={ caption }
+                                               onChange={ ( value ) => setAttributes( { caption: value } ) }
+                                               inlineToolbar
+                                       />
+                               ) }
+                       </figure>
+               </Fragment>
+       );
+}
+
+const editEmbedActivityBlock = compose( [
+       withSelect( ( select, ownProps ) => {
+               const { url } = ownProps.attributes;
+               const editorSettings = select( 'core/editor' ).getEditorSettings();
+               const {
+                       getEmbedPreview,
+                       isRequestingEmbedPreview,
+               } = select( 'core' );
+
+               const preview = undefined !== url && getEmbedPreview( url );
+               const fetching = undefined !== url && isRequestingEmbedPreview( url );
+
+               return {
+                       bpSettings: editorSettings.bp.activity || {},
+                       preview: preview,
+                       fetching: fetching,
+               };
+       } ),
+] )( EditEmbedActivity );
+
+export default editEmbedActivityBlock;
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/bp-activity/js/blocks/embed-activity/edit.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcjsbpactivityjsblocksembedactivitysavejs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-activity/js/blocks/embed-activity/save.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-activity/js/blocks/embed-activity/save.js                         (rev 0)
+++ trunk/src/js/bp-activity/js/blocks/embed-activity/save.js   2020-10-10 18:06:52 UTC (rev 12747)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,37 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * WordPress dependencies.
+ */
+const {
+       blockEditor: {
+               RichText,
+       },
+       element: {
+               createElement,
+       },
+} = wp;
+
+const saveEmbedActivityBlock = ( { attributes } ) => {
+       const { url, caption } = attributes;
+
+       if ( ! url ) {
+               return null;
+       }
+
+       return (
+               <figure className="wp-block-embed is-type-bp-activity">
+                       <div className="wp-block-embed__wrapper">
+                       {
+                               `\n${ url }\n` /* URL needs to be on its own line. */
+                       }
+                       </div>
+                       { ! RichText.isEmpty( caption ) && (
+                               <RichText.Content
+                                       tagName="figcaption"
+                                       value={ caption }
+                               />
+                       ) }
+               </figure>
+       );
+};
+
+export default saveEmbedActivityBlock;
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/bp-activity/js/blocks/embed-activity/save.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcjsbpactivityjsblocksembedactivityjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/js/bp-activity/js/blocks/embed-activity.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/js/bp-activity/js/blocks/embed-activity.js                              (rev 0)
+++ trunk/src/js/bp-activity/js/blocks/embed-activity.js        2020-10-10 18:06:52 UTC (rev 12747)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,39 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * WordPress dependencies.
+ */
+const {
+       i18n: {
+               __,
+       },
+       blocks: {
+               registerBlockType,
+       },
+} = wp;
+
+/**
+ * Internal dependencies.
+ */
+import editEmbedActivityBlock from './embed-activity/edit';
+import saveEmbedActivityBlock from './embed-activity/save';
+
+registerBlockType( 'bp/embed-activity', {
+       title: __( 'Embed an activity', 'buddypress' ),
+       description: __( 'Add a block that displays the activity content pulled from this or other community sites.', 'buddypress' ),
+       icon: 'buddicons-activity',
+       category: 'buddypress',
+       attributes: {
+               url: {
+                       type: 'string',
+               },
+               caption: {
+                       type: 'string',
+                       source: 'html',
+                       selector: 'figcaption',
+               },
+       },
+       supports: {
+               align: true,
+       },
+       edit: editEmbedActivityBlock,
+       save: saveEmbedActivityBlock,
+} );
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/js/bp-activity/js/blocks/embed-activity.js
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>

</body>
</html>