written 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/written/app/assets/javascripts/written/core/content.coffee +10 -10
  3. data/lib/written/app/assets/javascripts/written/core/cursor.coffee +6 -6
  4. data/lib/written/app/assets/javascripts/written/core/document.coffee +39 -6
  5. data/lib/written/app/assets/javascripts/written/parsers/block/code.coffee +34 -30
  6. data/lib/written/app/assets/javascripts/written/parsers/block/heading.coffee +28 -30
  7. data/lib/written/app/assets/javascripts/written/parsers/block/image.coffee +30 -49
  8. data/lib/written/app/assets/javascripts/written/parsers/block/olist.coffee +46 -49
  9. data/lib/written/app/assets/javascripts/written/parsers/block/paragraph.coffee +28 -32
  10. data/lib/written/app/assets/javascripts/written/parsers/block/quote.coffee +30 -32
  11. data/lib/written/app/assets/javascripts/written/parsers/block/ulist.coffee +43 -45
  12. data/lib/written/app/assets/javascripts/written/parsers/inline/code.coffee +28 -30
  13. data/lib/written/app/assets/javascripts/written/parsers/inline/italic.coffee +21 -25
  14. data/lib/written/app/assets/javascripts/written/parsers/inline/link.coffee +21 -25
  15. data/lib/written/app/assets/javascripts/written/parsers/inline/strong.coffee +21 -25
  16. data/lib/written/app/assets/javascripts/written/parsers/parsers.coffee +87 -19
  17. data/lib/written/app/assets/javascripts/written.coffee +0 -1
  18. data/lib/written/version.rb +1 -1
  19. data/test/server/app/assets/javascripts/application.coffee +5 -15
  20. metadata +2 -18
  21. data/lib/written/app/assets/javascripts/written/core/extensions/text.coffee +0 -2
  22. data/lib/written/app/assets/javascripts/written/core/stringify.coffee +0 -15
  23. data/lib/written/app/assets/javascripts/written/parsers/block.coffee +0 -69
  24. data/lib/written/app/assets/javascripts/written/parsers/inline/list.coffee +0 -27
  25. data/lib/written/app/assets/javascripts/written/parsers/inline.coffee +0 -81
  26. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/CustomElements.js +0 -32
  27. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/base.js +0 -40
  28. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/boot.js +0 -124
  29. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/observe.js +0 -318
  30. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/register.js +0 -369
  31. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/traverse.js +0 -86
  32. data/lib/written/app/assets/javascripts/written/polyfills/CustomElements/upgrade.js +0 -130
  33. data/lib/written/app/assets/javascripts/written/polyfills/MutationObserver/MutationObserver.js +0 -575
  34. data/lib/written/app/assets/javascripts/written/polyfills/WeakMap/WeakMap.js +0 -49
  35. data/lib/written/app/assets/javascripts/written/polyfills/base.coffee +0 -10
  36. data/lib/written/app/assets/javascripts/written/polyfills/dom.js +0 -104
@@ -1,25 +1,15 @@
1
1
  #= require 'written'
2
2
  #= require 'prism'
3
+ #
4
+ document.removeEventListener('DOMContentLoaded', Prism.highlightAll)
3
5
 
4
- code = Written.Parsers.Block.get('Code').prototype
5
- code.highlight = (element) ->
6
+ Written.Parsers.get('pre').highlightWith (element) ->
6
7
  Prism.highlightElement(element, false)
7
8
 
8
- code = Written.Parsers.Inline.get('Code').prototype
9
- code.highlight = (element) ->
9
+ Written.Parsers.get('code').highlightWith (element) ->
10
10
  Prism.highlightElement(element, false)
11
11
 
12
-
13
- if window.AWS?
14
- uploader = new Written.Uploaders.AWS({
15
- bucket: AWS.bucket,
16
- accessKey: AWS.accessKey,
17
- policy: AWS.policy,
18
- signature: AWS.signature
19
- })
20
-
21
- Written.Parsers.Block.get('Image').uploader(uploader)
22
-
23
12
  editor = new Written(document.getElementById('Editor'))
24
13
  editor.initialize()
25
14
 
15
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: written
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pier-Olivier Thibault
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Written is a rich Markdown editor for the web.
14
14
  email: pothibo@gmail.com
@@ -29,11 +29,8 @@ files:
29
29
  - lib/written/app/assets/javascripts/written/core/cursor.coffee
30
30
  - lib/written/app/assets/javascripts/written/core/document.coffee
31
31
  - lib/written/app/assets/javascripts/written/core/extensions/string.coffee
32
- - lib/written/app/assets/javascripts/written/core/extensions/text.coffee
33
32
  - lib/written/app/assets/javascripts/written/core/history.coffee
34
33
  - lib/written/app/assets/javascripts/written/core/observer.coffee
35
- - lib/written/app/assets/javascripts/written/core/stringify.coffee
36
- - lib/written/app/assets/javascripts/written/parsers/block.coffee
37
34
  - lib/written/app/assets/javascripts/written/parsers/block/code.coffee
38
35
  - lib/written/app/assets/javascripts/written/parsers/block/heading.coffee
39
36
  - lib/written/app/assets/javascripts/written/parsers/block/image.coffee
@@ -41,24 +38,11 @@ files:
41
38
  - lib/written/app/assets/javascripts/written/parsers/block/paragraph.coffee
42
39
  - lib/written/app/assets/javascripts/written/parsers/block/quote.coffee
43
40
  - lib/written/app/assets/javascripts/written/parsers/block/ulist.coffee
44
- - lib/written/app/assets/javascripts/written/parsers/inline.coffee
45
41
  - lib/written/app/assets/javascripts/written/parsers/inline/code.coffee
46
42
  - lib/written/app/assets/javascripts/written/parsers/inline/italic.coffee
47
43
  - lib/written/app/assets/javascripts/written/parsers/inline/link.coffee
48
- - lib/written/app/assets/javascripts/written/parsers/inline/list.coffee
49
44
  - lib/written/app/assets/javascripts/written/parsers/inline/strong.coffee
50
45
  - lib/written/app/assets/javascripts/written/parsers/parsers.coffee
51
- - lib/written/app/assets/javascripts/written/polyfills/CustomElements/CustomElements.js
52
- - lib/written/app/assets/javascripts/written/polyfills/CustomElements/base.js
53
- - lib/written/app/assets/javascripts/written/polyfills/CustomElements/boot.js
54
- - lib/written/app/assets/javascripts/written/polyfills/CustomElements/observe.js
55
- - lib/written/app/assets/javascripts/written/polyfills/CustomElements/register.js
56
- - lib/written/app/assets/javascripts/written/polyfills/CustomElements/traverse.js
57
- - lib/written/app/assets/javascripts/written/polyfills/CustomElements/upgrade.js
58
- - lib/written/app/assets/javascripts/written/polyfills/MutationObserver/MutationObserver.js
59
- - lib/written/app/assets/javascripts/written/polyfills/WeakMap/WeakMap.js
60
- - lib/written/app/assets/javascripts/written/polyfills/base.coffee
61
- - lib/written/app/assets/javascripts/written/polyfills/dom.js
62
46
  - lib/written/app/assets/javascripts/written/uploaders/aws.coffee
63
47
  - lib/written/app/assets/stylesheets/written.scss
64
48
  - lib/written/railtie.rb
@@ -1,2 +0,0 @@
1
- Text::toString = ->
2
- @textContent
@@ -1,15 +0,0 @@
1
- ElementString = (node) ->
2
- node.textContent
3
-
4
- CustomElementString = (node) ->
5
- node.toString()
6
-
7
- TextNodeString = (node) ->
8
- node.textContent
9
-
10
- Written.Stringify = (node) ->
11
- switch
12
- when node.nodeType == Node.TEXT_NODE then TextNodeString(node)
13
- when node.hasAttribute('is') then CustomElementString(node)
14
- else ElementString(node)
15
-
@@ -1,69 +0,0 @@
1
- class @Written.Parsers.Block
2
- constructor: ->
3
- @parsers = []
4
-
5
- freeze: ->
6
- if Written.Parsers.Block.parsers.default?
7
- @parsers.push Written.Parsers.Block.parsers.default
8
-
9
- Object.freeze(this)
10
- Object.freeze(@parsers)
11
-
12
- use: (names) ->
13
- if typeof names == 'string' && names == 'all'
14
- @parsers = Written.Parsers.Block.parsers.available.slice()
15
- return this
16
-
17
- if typeof names == 'string'
18
- names = names.split(',').map (name) ->
19
- name.trim()
20
-
21
- parser = Written.Parsers.Block.parsers.available.find (obj) ->
22
- names.contains(obj.parser.name)
23
-
24
- if !parser?
25
- throw "Couldn't find parser #{names}."
26
- return this
27
-
28
- @parsers.push(parser)
29
- return this
30
-
31
- parse: (lines) =>
32
- blocks = []
33
- while (line = lines.pop()) != undefined
34
- str = line.toString()
35
- block = blocks[blocks.length - 1]
36
-
37
- if block? && block.multiline && block.accepts(line)
38
- block.append(line)
39
- continue
40
-
41
- blocks.push(@find(str))
42
-
43
- blocks
44
-
45
- find: (str) ->
46
- parser = undefined
47
- for p in @parsers
48
- if match = p.rule.exec(str)
49
- parser = new p(match)
50
- break
51
-
52
- return parser
53
-
54
-
55
- @Written.Parsers.Block.parsers = {
56
- available: []
57
- default: undefined
58
- }
59
-
60
- @Written.Parsers.Block.get = (name) ->
61
- Written.Parsers.Block.parsers.available.find (p) ->
62
- p.parserName.localeCompare(name) == 0
63
-
64
- @Written.Parsers.Block.register = (parser, defaultParser = false) ->
65
- if defaultParser
66
- Written.Parsers.Block.parsers.default = parser
67
- else
68
- Written.Parsers.Block.parsers.available.push parser
69
-
@@ -1,27 +0,0 @@
1
- prototype = Object.create(HTMLLIElement.prototype)
2
-
3
- prototype.getRange = (offset, walker) ->
4
- range = document.createRange()
5
-
6
- if !@firstChild?
7
- range.setStart(this, 0)
8
- else
9
- while walker.nextNode()
10
- if walker.currentNode.length < offset
11
- offset -= walker.currentNode.length
12
- continue
13
-
14
- range.setStart(walker.currentNode, offset)
15
- break
16
-
17
- range.collapse(true)
18
- range
19
-
20
- prototype.toString = ->
21
- @textContent
22
-
23
- document.registerElement('written-li', {
24
- prototype: prototype
25
- extends: 'li'
26
- })
27
-
@@ -1,81 +0,0 @@
1
- class @Written.Parsers.Inline
2
- constructor: ->
3
- @parsers = []
4
-
5
- freeze: ->
6
- Object.freeze(this)
7
- Object.freeze(@parsers)
8
-
9
- use: (names) ->
10
- if typeof names == 'string' && names == 'all'
11
- @parsers = Written.Parsers.Inline.parsers.available.slice()
12
- return this
13
-
14
- if typeof names == 'string'
15
- names = names.split(',').map (name) ->
16
- name.trim()
17
-
18
- parser = Written.Parsers.Inline.parsers.available.find (parser) ->
19
- names.contains(parser.name)
20
-
21
- if !parser?
22
- throw "Couldn't find parser #{name}."
23
- return this
24
-
25
- @parsers.push parser
26
- return this
27
-
28
- parse: (text) =>
29
- if Array.isArray(text)
30
- return text.map(@parse)
31
-
32
- parsers = []
33
- for p in @parsers
34
- if text.length is 0
35
- break
36
-
37
- p.rule.lastIndex = 0
38
-
39
- while match = p.rule.exec(text)
40
- parser = new p(match)
41
- parsers[parser.index()] = parser
42
-
43
- @merge(parsers, text)
44
-
45
-
46
- merge: (parsers, text) ->
47
- content = []
48
- buffer = ''
49
- index = 0
50
-
51
- while text[index]?
52
- if parser = parsers[index]
53
- content.push buffer.slice(0)
54
- content.push parser
55
- buffer = ''
56
- index += parser.length()
57
- else
58
- buffer += text[index]
59
- index += 1
60
-
61
- if buffer.length > 0
62
- content.push buffer
63
-
64
- content
65
-
66
- splice: (text, parser) ->
67
- start = parser.index()
68
- end = start + parser.length()
69
- text.slice(0, start) + text.slice(end, text.length)
70
-
71
-
72
- @Written.Parsers.Inline.get = (name) ->
73
- Written.Parsers.Inline.parsers.available.find (p) ->
74
- p.parserName.localeCompare(name) == 0
75
-
76
- @Written.Parsers.Inline.parsers = {
77
- available: []
78
- }
79
-
80
- @Written.Parsers.Inline.register = (parser) ->
81
- Written.Parsers.Inline.parsers.available.push(parser)
@@ -1,32 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
- * Code distributed by Google as part of the polymer project is also
8
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
- */
10
- (function() {
11
-
12
- // Establish polyfill scope. We do this here to store flags. Flags are not
13
- // supported in the build.
14
- window.CustomElements = window.CustomElements || {flags:{}};
15
-
16
- // Flags. Convert url arguments to flags
17
- var flags = {};
18
- if (!flags.noOpts) {
19
- location.search.slice(1).split('&').forEach(function(option) {
20
- var parts = option.split('=');
21
- var match;
22
- if (parts[0] && (match = parts[0].match(/wc-(.+)/))) {
23
- flags[match[1]] = parts[1] || true;
24
- }
25
- });
26
- }
27
-
28
-
29
- // exports
30
- window.CustomElements.flags = flags;
31
-
32
- })();
@@ -1,40 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
- * Code distributed by Google as part of the polymer project is also
8
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
- */
10
- window.CustomElements = window.CustomElements || {flags:{}};
11
-
12
- (function(scope) {
13
-
14
- // imports
15
- var flags = scope.flags;
16
-
17
- // world's simplest module initializer
18
- var modules = [];
19
- var addModule = function(module) {
20
- modules.push(module);
21
- };
22
-
23
- var initializeModules = function() {
24
- modules.forEach(function(module) {
25
- module(scope);
26
- });
27
- };
28
-
29
- // exports
30
- scope.addModule = addModule;
31
- scope.initializeModules = initializeModules;
32
- scope.hasNative = Boolean(document.registerElement);
33
- scope.isIE = /Trident/.test(navigator.userAgent);
34
-
35
- // NOTE: For consistent timing, use native custom elements only when not
36
- // polyfilling other key related web components features.
37
- scope.useNative = !flags.register && scope.hasNative &&
38
- !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative);
39
-
40
- })(window.CustomElements);
@@ -1,124 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4
- * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
- * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
- * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
- * Code distributed by Google as part of the polymer project is also
8
- * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
- */
10
- (function(scope){
11
-
12
- // imports
13
- var useNative = scope.useNative;
14
- var initializeModules = scope.initializeModules;
15
-
16
- var isIE = scope.isIE;
17
-
18
- // If native, setup stub api and bail.
19
- // NOTE: we fire `WebComponentsReady` under native for api compatibility
20
- if (useNative) {
21
- // stub
22
- var nop = function() {};
23
-
24
- // exports
25
- scope.watchShadow = nop;
26
- scope.upgrade = nop;
27
- scope.upgradeAll = nop;
28
- scope.upgradeDocumentTree = nop;
29
- scope.upgradeSubtree = nop;
30
- scope.takeRecords = nop;
31
-
32
- scope.instanceof = function(obj, base) {
33
- return obj instanceof base;
34
- };
35
-
36
- } else {
37
- // Initialize polyfill modules. Note, polyfill modules are loaded but not
38
- // executed; this is a convenient way to control which modules run when
39
- // the polyfill is required and allows the polyfill to load even when it's
40
- // not needed.
41
- initializeModules();
42
- }
43
-
44
- // imports
45
- var upgradeDocumentTree = scope.upgradeDocumentTree;
46
- var upgradeDocument = scope.upgradeDocument;
47
-
48
- // ShadowDOM polyfill wraps elements but some elements like `document`
49
- // cannot be wrapped so we help the polyfill by wrapping some elements.
50
- if (!window.wrap) {
51
- if (window.ShadowDOMPolyfill) {
52
- window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded;
53
- window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded;
54
- } else {
55
- window.wrap = window.unwrap = function(node) {
56
- return node;
57
- };
58
- }
59
- }
60
-
61
- // eagarly upgrade imported documents
62
- if (window.HTMLImports) {
63
- window.HTMLImports.__importsParsingHook = function(elt) {
64
- if (elt.import) {
65
- upgradeDocument(wrap(elt.import));
66
- }
67
- };
68
- }
69
-
70
- // bootstrap parsing
71
- function bootstrap() {
72
- // one more upgrade to catch out of order registrations
73
- upgradeDocumentTree(window.wrap(document));
74
- // install upgrade hook if HTMLImports are available
75
- // set internal 'ready' flag, now document.registerElement will trigger
76
- // synchronous upgrades
77
- window.CustomElements.ready = true;
78
- // async to ensure *native* custom elements upgrade prior to this
79
- // DOMContentLoaded can fire before elements upgrade (e.g. when there's
80
- // an external script)
81
- // Delay doubly to help workaround
82
- // https://code.google.com/p/chromium/issues/detail?id=516550.
83
- // CustomElements must use requestAnimationFrame in attachedCallback
84
- // to query style/layout data. The WebComponentsReady event is intended
85
- // to convey overall readiness, which ideally should be after elements
86
- // are attached. Adding a slight extra delay to WebComponentsReady
87
- // helps preserve this guarantee.
88
- var requestAnimationFrame = window.requestAnimationFrame || function(f) {
89
- setTimeout(f, 16);
90
- };
91
- requestAnimationFrame(function() {
92
- setTimeout(function() {
93
- // capture blunt profiling data
94
- window.CustomElements.readyTime = Date.now();
95
- if (window.HTMLImports) {
96
- window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime;
97
- }
98
- // notify the system that we are bootstrapped
99
- document.dispatchEvent(
100
- new CustomEvent('WebComponentsReady', {bubbles: true})
101
- );
102
- });
103
- });
104
- }
105
-
106
- // When loading at readyState complete time (or via flag), boot custom elements
107
- // immediately.
108
- // If relevant, HTMLImports must already be loaded.
109
- if (document.readyState === 'complete' || scope.flags.eager) {
110
- bootstrap();
111
- // When loading at readyState interactive time, bootstrap only if HTMLImports
112
- // are not pending. Also avoid IE as the semantics of this state are unreliable.
113
- } else if (document.readyState === 'interactive' && !window.attachEvent &&
114
- (!window.HTMLImports || window.HTMLImports.ready)) {
115
- bootstrap();
116
- // When loading at other readyStates, wait for the appropriate DOM event to
117
- // bootstrap.
118
- } else {
119
- var loadEvent = window.HTMLImports && !window.HTMLImports.ready ?
120
- 'HTMLImportsLoaded' : 'DOMContentLoaded';
121
- window.addEventListener(loadEvent, bootstrap);
122
- }
123
-
124
- })(window.CustomElements);