Skip to content

Commit

Permalink
make OEmbeds non-editable + ability to edit OEmbeds on a later state
Browse files Browse the repository at this point in the history
  • Loading branch information
nielslyngsoe committed Sep 18, 2019
1 parent 5fb5388 commit bf9eeb4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
19 changes: 10 additions & 9 deletions src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
// Check nodename is a DIV and the claslist contains 'embeditem'
var selectedElm = editor.selection.getNode();
var nodeName = selectedElm.nodeName;
var embed = {};
var modify = null;

if(nodeName.toUpperCase() === "DIV" && selectedElm.classList.contains("embeditem")){
// See if we can go and get the attributes
Expand All @@ -441,18 +441,18 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
var embedHeight = editor.dom.getAttrib(selectedElm, "data-embed-height");
var embedConstrain = editor.dom.getAttrib(selectedElm, "data-embed-constrain");

embed = {
modify = {
url: embedUrl,
width: embedWidth,
height: embedHeight,
width: parseInt(embedWidth) || 0,
height: parseInt(embedHeight) || 0,
constrain: embedConstrain
};
}

if (callback) {
angularHelper.safeApply($rootScope, function() {
// pass the active element along so we can retrieve it later
callback(selectedElm, embed);
callback(selectedElm, modify);
});
}
}
Expand All @@ -469,11 +469,12 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s

var wrapper = tinymce.activeEditor.dom.create('div',
{
'class': 'mceNonEditable embeditem',
'class': 'embeditem',
'data-embed-url': embed.url,
'data-embed-height': embed.height,
'data-embed-width': embed.width,
'data-embed-constrain': embed.constrain
'data-embed-constrain': embed.constrain,
'contenteditable': false
},
embed.preview);

Expand Down Expand Up @@ -1304,9 +1305,9 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
});

//Create the embedded plugin
self.createInsertEmbeddedMedia(args.editor, function (activeElement, embed) {
self.createInsertEmbeddedMedia(args.editor, function (activeElement, modify) {
var embed = {
embed: embed,
modify: modify,
submit: function (model) {
self.insertEmbeddedMediaInEditor(args.editor, model.embed, activeElement);
editorService.close();
Expand Down
22 changes: 17 additions & 5 deletions src/Umbraco.Web.UI.Client/src/less/rte-content.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,31 @@
}


.umb-rte .mceNonEditable.embeditem {
.umb-rte .embeditem {
position:relative;
> * {
user-select: none;
pointer-events: none;
}
}

.umb-rte .mceNonEditable.embeditem::before {
.umb-rte .embeditem[data-mce-selected] {
outline: 2px solid @pinkLight;
}

.umb-rte .embeditem::before {
z-index:1000;
width:100%;
height:100%;
position:absolute;
content:' ';
background:rgba(0,0,0,0.1);
}

.umb-rte .mceNonEditable.embeditem[data-mce-selected] {
.umb-rte .embeditem[data-mce-selected]::before {
background:rgba(0,0,0,0.025);
}

.umb-rte *[data-mce-selected="inline-boundary"] {
background:rgba(0,0,0,0.025);
outline: 2px solid @pinkLight;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
supportsDimensions: false
};

if ($scope.model.original) {
angular.extend($scope.model.embed, $scope.model.original);
if ($scope.model.modify) {
angular.extend($scope.model.embed, $scope.model.modify);

showPreview();
}
Expand Down

0 comments on commit bf9eeb4

Please sign in to comment.