lumyjuwon / WYSIWYG

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Android Editor

DEMO


Demo will be attached.



AndroidX


This editor uses AndroidX.

You can migrate your project to AndroidX. (How to migrate : Here )



Functions


  • Text Size

  • Text Color

  • Text Background Color

  • Text Bold

  • Text Italic

  • Subscript

  • Superscript

  • Text Underline

  • Text Strike Through

  • Content Align (left, middle, right)

  • Insert Image

  • Insert Youtube

  • Undo

  • Redo

  • Indent

  • Outdent

  • InsertOrderedList

  • InsertUnorderedList

  • styleWithCSS



Setup


repositories {
    maven { url "https://jitpack.io" }
}

Add this maven to your project's build.gradle.

implementation 'com.github.lumyjuwon:Android-Rich-Wysiwyg-Editor:1.0.0'

And add this to your module's build gradle.



Methods


WE.exec = function(cmd, val) { // 
    val = (typeof(val) !== 'undefined') ? val : null;
    document.execCommand("styleWithCSS", null, (val !== null));
    document.execCommand(cmd, false, val);
    WE.editor.focus();
    console.log('hello world');
    WE.backuprange();
    WE.restorerange();
};

Performs execCommand basic methods. You can add more funtions. ( 한국어 , ENG )


WE.insertCss = function (property, value) {	
	let select = getSelection();
	let tag = select.getRangeAt(0).startContainer.parentNode;
	if (select.toString() == tag.textContent) {	
		if (tag.style[property] != value) {
			tag.style[property] = value;
		} else {
			tag.style.removeProperty(property);
		}
		if (tag.style.length == 0) {	
			tag.removeAttribute('style');
			if (tag.tagName == 'SPAN') {	
				WE.editor.innerHTML = WE.editor.innerHTML.replace(/<span>(.*?)<\/span>/g, '$1');
			}
		}
	} else {	
		document.execCommand("styleWithCSS", null, false);
		document.execCommand('foreColor', false, 'rgb(1, 1, 1)');	
		WE.editor.innerHTML = WE.editor.innerHTML.replace(/<font .+?>(.*?)<\/font>/g, '<span style="' + property + ': ' + value + '">$1</span>');	
	}
	WE.editor.focus();
};

Performs adding the css property to the dragged area.



Requirements


Android 5+



Credits




License


Copyright 2019 lumyjuwon

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

License:Apache License 2.0


Languages

Language:Java 85.9%Language:JavaScript 12.2%Language:HTML 1.9%