Esempio n. 1
0
        public void SaveEditedSmartContent()
        {
            //update the element ID with the new smart content id (this preserves undo-ability)
            _smartContentElement.id = ContentSourceManager.MakeContainingElementId(_contentSourceId, _smartContentId);
            SmartContentInsertionHelper.InsertEditorHtmlIntoElement(_contentSourceContext, _contentSource, _smartContent, _smartContentElement);

            //reinit the smart content so it is re-cloned
            MakeSmartContentEditable();
        }
Esempio n. 2
0
        private Size UpdateHtmlForResize(Size newSize, bool isComplete)
        {
            Size targetElementSize = newSize;

            if (_contentSource.ResizeCapabilities != ResizeCapabilities.None)
            {
                SmartContent content = SmartContent;

                //base the new size on target element preferred by the source
                //(apply the difference in size to the last known size of the target element)
                targetElementSize = new Size(
                    Math.Max(1, _initialTargetSize.Width + (newSize.Width - _initialParentSize.Width)),
                    Math.Max(1, _initialTargetSize.Height + (newSize.Height - _initialParentSize.Height))
                    );

                if (_preserveAspectRatio)
                {
                    targetElementSize = Utility.GetScaledMaxSize(_aspectRatio, targetElementSize.Width, targetElementSize.Height);
                }

                //let the resizer know about the new size, and regenerate the content
                if (isComplete)
                {
                    _contentSource.OnResizeComplete(content, targetElementSize);
                }
                else
                {
                    _contentSource.OnResizing(content, targetElementSize);
                }

                //insert the new content into the DOM (TODO: need undo support for this)
                SmartContentInsertionHelper.InsertEditorHtmlIntoElement(_contentSourceContext, _contentSource, content, HTMLElement);

                Invalidate();

                if (_resizedListener != null)
                {
                    _resizedListener(newSize, isComplete);
                }

                EditorContext.DamageServices.AddDamage(EditorContext.MarkupServices.CreateMarkupRange(HTMLElement, false));
            }
            return(targetElementSize);
        }