diff --git a/CHANGELOG b/CHANGELOG index 926e829..d29ea32 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,16 @@ +*0.3* + +* Removed iFrame support and transitioned to contentEditable. This drops + support for Firefox 2. + +*0.2.1* (February 3, 2010) + +* Added Editor#queryValueCommandState for testing custom query commands. + +* Added execCommand delegates for fontSelection, fontSizeSelection, + backgroundColorSelection, backgroundColorSelected, alignSelection, + and alignSelected. + *0.2* (March 29, 2009) * For performance reasons, automatic textarea saving is now disabled by diff --git a/MIT-LICENSE b/LICENSE similarity index 97% rename from MIT-LICENSE rename to LICENSE index 118f33a..4eb22c4 100644 --- a/MIT-LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2008 Joshua Peek +Copyright (c) 2010 Joshua Peek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.markdown b/README.markdown index 9cf3243..78d377f 100644 --- a/README.markdown +++ b/README.markdown @@ -11,15 +11,14 @@ way and leaves the UI design to you. WysiHat currently supports: -* Microsoft Internet Explorer for Windows, version 6.0 and higher -* Mozilla Firefox 2.0 and higher -* Apple Safari 3.0 and higher -* Opera 9.52 and higher -* Google Chrome +* Microsoft Internet Explorer for Windows, version 7.0 +* Mozilla Firefox 3.0 +* Apple Safari 4.0 +* Google Chrome 4.0 ### Dependencies -* Prototype 1.6 or later (http://prototypejs.org/) +* Prototype 1.7 or later (http://prototypejs.org/) ## Documentation diff --git a/Rakefile b/Rakefile index 2258128..338bf8e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,154 +1,115 @@ require 'rake' -require 'rake/testtask' +require 'rake/clean' require 'rake/rdoctask' +require 'rake/testtask' -WYSIHAT_ROOT = File.expand_path(File.dirname(__FILE__)) -WYSIHAT_SRC_DIR = File.join(WYSIHAT_ROOT, 'src') -WYSIHAT_DIST_DIR = File.join(WYSIHAT_ROOT, 'dist') -WYSIHAT_DOC_DIR = File.join(WYSIHAT_ROOT, 'doc') -WYSIHAT_WEBSITE_DIR = File.join(WYSIHAT_ROOT, 'website') -WYSIHAT_TEST_DIR = File.join(WYSIHAT_ROOT, 'test') -WYSIHAT_TEST_UNIT_DIR = File.join(WYSIHAT_TEST_DIR, 'unit') -WYSIHAT_TMP_DIR = File.join(WYSIHAT_TEST_UNIT_DIR, 'tmp') +CLEAN.include 'test/unit/tmp' +CLOBBER.include 'dist' +CLOBBER.include 'doc' -desc "Update git submodules" -task :update_submodules do - system("git submodule init") - system("git submodule update") +WYSIHAT_ROOT = File.expand_path(File.dirname(__FILE__)) +WYSIHAT_SRC_DIR = File.join(WYSIHAT_ROOT, 'src') + + +# Distribution + +file 'dist/prototype.js' => :sprockets do |t| + prototype_src_dir = "#{WYSIHAT_ROOT}/vendor/prototype/src" + + secretary = Sprockets::Secretary.new( + :root => prototype_src_dir, + :load_path => [prototype_src_dir], + :source_files => ["prototype.js"] + ) + + FileUtils.mkdir_p File.dirname(t.name) + secretary.concatenation.save_to(t.name) +end + +file 'dist/wysihat.js' => Dir['src/**/*'] + [:sprockets] do |t| + secretary = Sprockets::Secretary.new( + :root => WYSIHAT_SRC_DIR, + :load_path => [WYSIHAT_SRC_DIR], + :source_files => ["wysihat.js"] + ) + + FileUtils.mkdir_p File.dirname(t.name) + secretary.concatenation.save_to(t.name) end task :default => :dist desc "Builds the distribution." -task :dist => ["sprocketize:prototype", "sprocketize:wysihat"] +task :dist => ['dist/prototype.js', 'dist/wysihat.js'] -task :watch do - ENV['WATCH'] = "1" - Rake::Task["sprocketize:wysihat"].invoke -end -namespace :sprocketize do - task :dist_dir do - FileUtils.mkdir_p(WYSIHAT_DIST_DIR) - end +# Documentation - task :wysihat => [:update_submodules, :dist_dir] do - require File.join(WYSIHAT_ROOT, "vendor", "sprockets", "lib", "sprockets") - require File.join(WYSIHAT_ROOT, "vendor", "sprockwatch", "lib", "sprockwatch") +desc "Builds the documentation." +file 'doc' => Dir['src/**/*'] + [:sprockets, :pdoc] do + require 'tempfile' + Tempfile.open('pdoc') do |temp| secretary = Sprockets::Secretary.new( - :root => File.join(WYSIHAT_ROOT, "src"), + :root => WYSIHAT_SRC_DIR, :load_path => [WYSIHAT_SRC_DIR], - :source_files => ["wysihat.js"] + :source_files => ["wysihat.js"], + :strip_comments => false ) - save = lambda { - secretary.concatenation.save_to(File.join(WYSIHAT_DIST_DIR, "wysihat.js")) - } - - ENV['WATCH'] ? secretary.watch!(&save) : save.call + secretary.concatenation.save_to(temp.path) + PDoc::Runner.new(temp.path, :destination => "#{WYSIHAT_ROOT}/doc").run end +end - task :prototype => [:update_submodules, :dist_dir] do - require File.join(WYSIHAT_ROOT, "vendor", "sprockets", "lib", "sprockets") - prototype_root = File.join(WYSIHAT_ROOT, "vendor", "prototype") - prototype_src_dir = File.join(prototype_root, 'src') +# Tests - secretary = Sprockets::Secretary.new( - :root => File.join(prototype_root, "src"), - :load_path => [prototype_src_dir], - :source_files => ["prototype.js"] - ) +file 'test/unit/tmp/tests' => Dir['test/unit/*.js'] + [:unittest_js, :dist] do + FileUtils.mkdir_p File.dirname('test/unit/tmp/tests') - secretary.concatenation.save_to(File.join(WYSIHAT_DIST_DIR, "prototype.js")) - end + builder = UnittestJS::Builder::SuiteBuilder.new({ + :input_dir => "#{WYSIHAT_ROOT}/test/unit", + :assets_dir => "#{WYSIHAT_ROOT}/dist" + }) + builder.collect + builder.render end -desc "Empties the output directory and builds the documentation." -task :doc => 'doc:build' - -namespace :doc do - desc "Builds the documentation" - task :build => [:update_submodules, :clean] do - require File.join(WYSIHAT_ROOT, "vendor", "sprockets", "lib", "sprockets") - require File.join(WYSIHAT_ROOT, "vendor", "pdoc", "lib", "pdoc") - require 'tempfile' - - Tempfile.open("pdoc") do |temp| - secretary = Sprockets::Secretary.new( - :root => File.join(WYSIHAT_ROOT, "src"), - :load_path => [WYSIHAT_SRC_DIR], - :source_files => ["wysihat.js"], - :strip_comments => false - ) - - secretary.concatenation.save_to(temp.path) - PDoc::Runner.new(temp.path, - :output => WYSIHAT_DOC_DIR, - :templates => WYSIHAT_WEBSITE_DIR - ).run - end - end +desc "Builds the distribution, runs the JavaScript unit tests and collects their results." +task :test => 'test/unit/tmp/tests' - task :publish => :build do - Dir.chdir(WYSIHAT_DOC_DIR) do - system "git init" - system "git add ." - system "git commit -m \"import docs\"" - system "git remote add origin git@github.com:josh/wysihat.git" - system "git checkout -b gh-pages" - system "git push -f origin gh-pages" - end - end - desc "Empties documentation directory" - task :clean do - rm_rf WYSIHAT_DOC_DIR - end +# Vendored libs + +task :sprockets => 'vendor/sprockets/lib/sprockets.rb' do + $:.unshift File.expand_path('vendor/sprockets/lib', WYSIHAT_ROOT) + require 'sprockets' end -desc "Builds the distribution, runs the JavaScript unit tests and collects their results." -task :test => ['test:build', 'test:run'] - -namespace :test do - task :run do - testcases = ENV['TESTCASES'] - browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',') - tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',') - runner = UnittestJS::WEBrickRunner::Runner.new(:test_dir => WYSIHAT_TMP_DIR) - - Dir[File.join(WYSIHAT_TMP_DIR, '*_test.html')].each do |file| - file = File.basename(file) - test = file.sub('_test.html', '') - unless tests_to_run && !tests_to_run.include?(test) - runner.add_test(file, testcases) - end - end - - UnittestJS::Browser::SUPPORTED.each do |browser| - unless browsers_to_test && !browsers_to_test.include?(browser) - runner.add_browser(browser.to_sym) - end - end - - trap('INT') { runner.teardown; exit } - runner.run - end +task :pdoc => 'vendor/pdoc/lib/pdoc.rb' do + $:.unshift File.expand_path('vendor/pdoc/lib', WYSIHAT_ROOT) + require 'pdoc' +end - task :build => [:clean, :dist] do - require File.join(WYSIHAT_ROOT, "vendor", "unittest_js", "lib", "unittest_js") - builder = UnittestJS::Builder::SuiteBuilder.new({ - :input_dir => WYSIHAT_TEST_UNIT_DIR, - :assets_dir => WYSIHAT_DIST_DIR - }) - selected_tests = (ENV['TESTS'] || '').split(',') - builder.collect(*selected_tests) - builder.render - end +task :unittest_js => 'vendor/unittest_js/lib/unittest_js.rb' do + $:.unshift File.expand_path('vendor/unittest_js/lib', WYSIHAT_ROOT) + require 'unittest_js' +end - task :clean do - require File.join(WYSIHAT_ROOT, "vendor", "unittest_js", "lib", "unittest_js") - UnittestJS::Builder.empty_dir!(WYSIHAT_TMP_DIR) - end +file 'vendor/pdoc/lib/pdoc.rb' do + Rake::Task['update_submodules'].invoke +end + +file 'vendor/sprockets/lib/sprockets.rb' do + Rake::Task['update_submodules'].invoke +end + +file 'vendor/unittest_js/lib/unittest_js.rb' do + Rake::Task['update_submodules'].invoke +end + +task :update_submodules do + system "git submodule init" + system "git submodule update" end diff --git a/examples/custom_buttons.html b/examples/custom_buttons.html index d1fcbbe..97da787 100644 --- a/examples/custom_buttons.html +++ b/examples/custom_buttons.html @@ -1,36 +1,15 @@ - - + +
Oops, you need to build the package before running this example. It's easy: just run rake
in the project's directory.
This example shows you how to create a simple UI for inserting (un)ordered Lists
+ +
+ document.on("dom:loaded", function() {
+ var editor = WysiHat.Editor.attach('content');
+ var toolbar = new WysiHat.Toolbar(editor);
+
+ toolbar.addButton({
+ label: "Ordered List",
+ handler: function(editor) { return editor.toggleOrderedList(); }
+ });
+
+ toolbar.addButton({
+ label: "Unordered List",
+ handler: function(editor) { return editor.toggleUnorderedList(); }
+ });
+ });
+
+
+
+
+
diff --git a/examples/simple.html b/examples/simple.html
index 6939602..40ae534 100644
--- a/examples/simple.html
+++ b/examples/simple.html
@@ -1,36 +1,15 @@
-
-
+
+