Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamically load all scripts #961

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ sceditor.sublime-workspace
/docs
/coverage
.DS_Store
/codetests
/codetests
package-lock.json
/.vs
108 changes: 15 additions & 93 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const libCoverage = require('istanbul-lib-coverage');
const libReport = require('istanbul-lib-report');
const reports = require('istanbul-reports');
const sass = require('sass');
const nodeResolve = require('@rollup/plugin-node-resolve').default;
const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -86,12 +87,6 @@ module.exports = (grunt) => {
src: ['plugins/**.js', 'formats/**.js', 'icons/**.js'],
dest: 'dist/development/'
},
{
expand: true,
cwd: 'src/',
src: 'jquery.sceditor.default.css',
dest: 'dist/development/'
},
{
expand: true,
cwd: 'src/themes/icons/',
Expand Down Expand Up @@ -120,11 +115,6 @@ module.exports = (grunt) => {
src: 'example.html',
dest: 'dist/'
},
{
expand: true,
src: 'emoticons/**',
dest: 'dist/'
}
]
},
build: {
Expand Down Expand Up @@ -166,45 +156,20 @@ module.exports = (grunt) => {
},
build: {
files: {
'./minified/jquery.sceditor.min.js': [
'./src/jquery.sceditor.js'
],
'./minified/sceditor.min.js': [
'./src/sceditor.js'
]
}
},
dist: {
files: {
'./dist/development/jquery.sceditor.js': [
'./src/jquery.sceditor.js'
],
'./dist/development/sceditor.js': [
'./src/sceditor.js'
]
}
}
},

// Create the XHTML and BBCode bundled JS files
concat: {
dist: {
options: {
separator: ';'
},
files: {
'dist/development/jquery.sceditor.bbcode.js': [
'dist/development/jquery.sceditor.js',
'src/formats/bbcode.js'
],
'dist/development/jquery.sceditor.xhtml.js': [
'dist/development/jquery.sceditor.js',
'src/formats/xhtml.js'
]
}
}
},

// Minify the JavaScript
uglify: {
build: {
Expand All @@ -220,24 +185,6 @@ module.exports = (grunt) => {
src: 'minified/sceditor.min.js',
dest: 'minified/sceditor.min.js'
},
{
src: 'minified/jquery.sceditor.min.js',
dest: 'minified/jquery.sceditor.min.js'
},
{
src: [
'minified/jquery.sceditor.min.js',
'src/formats/bbcode.js'
],
dest: 'minified/jquery.sceditor.bbcode.min.js'
},
{
src: [
'minified/jquery.sceditor.min.js',
'src/formats/xhtml.js'
],
dest: 'minified/jquery.sceditor.xhtml.min.js'
},
{
expand: true,
filter: 'isFile',
Expand All @@ -248,42 +195,18 @@ module.exports = (grunt) => {
]
}
},

// Convert the less CSS theme files into CSS
less: {
build: {
options: {
paths: ['src/themes/', 'src/themes/icons'],
cleancss: true
},
files: [
{
expand: true,
filter: 'isFile',
cwd: 'src/themes/',
src: ['*.less'],
dest: 'minified/themes/',
ext: '.min.css'
}
]
},
dist: {
options: {
paths: ['src/themes/', 'src/themes/icons'],
cleancss: true
},
files: [
{
expand: true,
filter: 'isFile',
cwd: 'src/themes/',
src: ['*.less'],
dest: 'dist/development/themes/',
ext: '.css'
}
]
}
},

sass: {
options: {
implementation: sass,
sourceMap: false
},
build: {
files: {
"minified/themes/sceditor.min.css": 'src/themes/sceditor.scss'
}
}
},

// Manage CSS vendor prefixes
postcss: {
Expand Down Expand Up @@ -338,11 +261,11 @@ module.exports = (grunt) => {
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-rollup');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-sass');

grunt.registerTask('default', ['test']);

Expand All @@ -352,10 +275,10 @@ module.exports = (grunt) => {
// Minifies the source
grunt.registerTask('build', [
'clean:build',
'sass',
'copy:build',
'rollup:build',
'uglify:build',
'less:build',
'postcss:build'
]);

Expand All @@ -368,7 +291,6 @@ module.exports = (grunt) => {
'rollup:dist',
'concat:dist',
'copy:dist',
'less:dist'
]);

// Creates the simplified distributable ZIP
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Include the SCEditor JavaScript:
```html
<link rel="stylesheet" href="minified/themes/default.min.css" />
<script src="minified/sceditor.min.js"></script>
<script src="minified/formats/bbcode.js"></script>
<script src="minified/formats/xhtml.js"></script>
```

Then to convert a textarea into SCEditor, simply do:
Expand Down
Binary file removed emoticons/alien.png
Binary file not shown.
Binary file removed emoticons/angel.png
Binary file not shown.
Binary file removed emoticons/angry.png
Binary file not shown.
Binary file removed emoticons/blink.png
Binary file not shown.
Binary file removed emoticons/blush.png
Binary file not shown.
Binary file removed emoticons/cheerful.png
Binary file not shown.
Binary file removed emoticons/cool.png
Binary file not shown.
9 changes: 0 additions & 9 deletions emoticons/credits.txt

This file was deleted.

Binary file removed emoticons/cwy.png
Binary file not shown.
Binary file removed emoticons/devil.png
Binary file not shown.
Binary file removed emoticons/dizzy.png
Binary file not shown.
Binary file removed emoticons/ermm.png
Binary file not shown.
Binary file removed emoticons/face.png
Binary file not shown.
Binary file removed emoticons/getlost.png
Binary file not shown.
Binary file removed emoticons/grin.png
Binary file not shown.
Binary file removed emoticons/happy.png
Binary file not shown.
Binary file removed emoticons/heart.png
Binary file not shown.
Binary file removed emoticons/kissing.png
Binary file not shown.
Binary file removed emoticons/laughing.png
Binary file not shown.
Binary file removed emoticons/ninja.png
Binary file not shown.
Binary file removed emoticons/pinch.png
Binary file not shown.
Binary file removed emoticons/pouty.png
Binary file not shown.
Binary file removed emoticons/sad.png
Binary file not shown.
Binary file removed emoticons/shocked.png
Binary file not shown.
Binary file removed emoticons/sick.png
Binary file not shown.
Binary file removed emoticons/sideways.png
Binary file not shown.
Binary file removed emoticons/silly.png
Diff not rendered.
Binary file removed emoticons/sleeping.png
Diff not rendered.
Binary file removed emoticons/smile.png
Diff not rendered.
Binary file removed emoticons/tongue.png
Diff not rendered.
Binary file removed emoticons/unsure.png
Diff not rendered.
Binary file removed emoticons/w00t.png
Diff not rendered.
Binary file removed emoticons/wassat.png
Diff not rendered.
Binary file removed emoticons/whistling.png
Diff not rendered.
Binary file removed emoticons/wink.png
Diff not rendered.
Binary file removed emoticons/wub.png
Diff not rendered.
Binary file removed example/emoticons/alien.png
Diff not rendered.
Binary file removed example/emoticons/angel.png
Diff not rendered.
Binary file removed example/emoticons/angry.png
Diff not rendered.
Binary file removed example/emoticons/blink.png
Diff not rendered.
Binary file removed example/emoticons/blush.png
Diff not rendered.
Binary file removed example/emoticons/cheerful.png
Diff not rendered.
Binary file removed example/emoticons/cool.png
Diff not rendered.
9 changes: 0 additions & 9 deletions example/emoticons/credits.txt

This file was deleted.

Binary file removed example/emoticons/cwy.png
Diff not rendered.
Binary file removed example/emoticons/devil.png
Diff not rendered.
Binary file removed example/emoticons/dizzy.png
Diff not rendered.
Binary file removed example/emoticons/ermm.png
Diff not rendered.
Binary file removed example/emoticons/face.png
Diff not rendered.
Binary file removed example/emoticons/getlost.png
Diff not rendered.
Binary file removed example/emoticons/grin.png
Diff not rendered.
Binary file removed example/emoticons/happy.png
Diff not rendered.
Binary file removed example/emoticons/heart.png
Diff not rendered.
Binary file removed example/emoticons/kissing.png
Diff not rendered.
Binary file removed example/emoticons/laughing.png
Diff not rendered.
Binary file removed example/emoticons/ninja.png
Diff not rendered.
Binary file removed example/emoticons/pinch.png
Diff not rendered.
Binary file removed example/emoticons/pouty.png
Diff not rendered.
Binary file removed example/emoticons/sad.png
Diff not rendered.
Binary file removed example/emoticons/shocked.png
Diff not rendered.
Binary file removed example/emoticons/sick.png
Diff not rendered.
Binary file removed example/emoticons/sideways.png
Diff not rendered.
Binary file removed example/emoticons/silly.png
Diff not rendered.
Binary file removed example/emoticons/sleeping.png
Diff not rendered.
Binary file removed example/emoticons/smile.png
Diff not rendered.
Binary file removed example/emoticons/tongue.png
Diff not rendered.
Binary file removed example/emoticons/unsure.png
Diff not rendered.
Binary file removed example/emoticons/w00t.png
Diff not rendered.
Binary file removed example/emoticons/wassat.png
Diff not rendered.
Binary file removed example/emoticons/whistling.png
Diff not rendered.
Binary file removed example/emoticons/wink.png
Diff not rendered.
Binary file removed example/emoticons/wub.png
Diff not rendered.
125 changes: 62 additions & 63 deletions example/example.html
Original file line number Diff line number Diff line change
@@ -1,91 +1,90 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>SCEditor Demo</title>

<link rel="stylesheet" href="../minified/themes/default.min.css" id="theme-style" />
<link rel="stylesheet" href="../minified/themes/sceditor.min.css" id="theme-style" />
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">

<script src="../minified/sceditor.min.js"></script>
<script src="../minified/icons/monocons.js"></script>
<script src="../minified/icons/fontawesome.js"></script>
<script src="../minified/formats/bbcode.js"></script>

<style>
html {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
form div {
padding: .5em;
}
code:before {
position: absolute;
content: 'Code:';
top: -1.35em;
left: 0;
}
code {
margin-top: 1.5em;
position: relative;
background: #eee;
border: 1px solid #aaa;
white-space: pre;
padding: .25em;
min-height: 1.25em;
}
code:before, code {
display: block;
text-align: left;
}
</style>
<script src="../minified/plugins/dragdrop.js"></script>
<script src="../minified/plugins/undo.js"></script>

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" rel="stylesheet">
</head>
<body>

<form action="" method="post">
<div>
<textarea id="example" style="height:300px;width:600px;">[center][size=3][b]BBCode SCEditor[/b][/size][/center]
<main class="container">
<div class="bg-body-tertiary p-5 rounded">
<h1>SCEditor example</h1>
<div>
<textarea id="example" class="form-control" style="height:300px;width:600px;" title="editor">[center][size=3][b]BBCode SCEditor[/b][/size][/center]

Give it a try! :)

[color=#ff00]Red text! [/color][color=#3399ff]Blue?[/color]
[quote]CONTENT

[ul][li]A simple list[/li][li]list item 2[/li][/ul]
https://www.sceditor.com/

Just type [b]:[/b]) and it should be converted into :) as you type.</textarea>
PS: I've not used it and don't have any connection to it.[/quote]

@[userlink]tha_watcha[/userlink]

[code=markup]<pre><code class="language-css">p { color: red }</code></pre>[/code]

[color=#ff00]Red text! [/color][color=#3399ff]Blue?[/color]

[list][*]A simple list[*]list item 2[/list]
Just type [b]:[/b]) and it should be converted into :) as you typed.</textarea>

</div>

<div>
<label for="theme">Theme:</label>
<select id="theme">
<option value="default">Default</option>
<option value="defaultdark">Default dark</option>
<option value="modern">Modern</option>
<option value="office-toolbar">Office Toolbar</option>
<option value="office">Office</option>
<option value="square">Square</option>
</select>
</div>
</div>
</main>

</form>

<div class="container">
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
<p class="col-md-4 mb-0 text-body-secondary">SCEditor is licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></p>
</footer>
</div>


<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/prism.min.js"></script>
Fixed Show fixed Hide fixed
<script>
var textarea = document.getElementById('example');
sceditor.create(textarea, {
format: 'bbcode',
icons: 'monocons',
style: '../minified/themes/content/default.min.css'
});



var themeInput = document.getElementById('theme');
themeInput.onchange = function() {
var theme = '../minified/themes/' + themeInput.value + '.min.css';

sceditor.create(textarea, {
extensionsUrl: 'http://localhost/bbcode.json',
autoExpand: true,
maxLength: 32767,
plugins: 'emojis',

document.getElementById('theme-style').href = theme;
};
//emojis: ['😊', '❤️', '😄', '😄', '😄', '😄', '😄', '😄', '😄', '😄', '😄', '😄'],
styles: ['https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css','https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css', 'https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css'],
toolbar: 'bold,italic,underline,strike|' +
'font,size,color|mark|' +
'email,link,unlink,quote,code,|image,albums|attachments|' +
'emojis|' +
'bulletlist,orderedlist|left,center,right|indent,outdent|' +
'cut,copy,pastetext,removeformat|' +
'undo,redo|' +
'youtube,vimeo,instagram,facebook,media,extensions|source|reply|table'
});


</script>

<p>SCEditor is licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></p>



</body>
</html>
Loading
Loading