@zipify/wysiwyg 1.1.1 → 1.2.1-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/.github/actions/lint-css/action.yaml +1 -3
  2. package/.release-it.json +2 -1
  3. package/dist/cli.js +3 -3
  4. package/dist/wysiwyg.css +24 -25
  5. package/dist/wysiwyg.mjs +641 -618
  6. package/jest.config.js +3 -0
  7. package/lib/components/base/Modal.vue +21 -2
  8. package/lib/components/base/__tests__/Modal.test.js +1 -0
  9. package/lib/components/toolbar/controls/link/LinkControl.vue +22 -10
  10. package/lib/components/toolbar/controls/link/LinkControlHeader.vue +3 -3
  11. package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +8 -8
  12. package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +1 -1
  13. package/lib/components/toolbar/controls/link/composables/useLink.js +10 -6
  14. package/lib/composables/__tests__/__snapshots__/useEditor.test.js.snap +1 -1
  15. package/lib/composables/useEditor.js +4 -3
  16. package/lib/enums/TextSettings.js +2 -0
  17. package/lib/extensions/FontStyle.js +2 -2
  18. package/lib/extensions/FontWeight.js +2 -0
  19. package/lib/extensions/Link.js +13 -15
  20. package/lib/extensions/StylePreset.js +33 -3
  21. package/lib/extensions/TextDecoration.js +6 -12
  22. package/lib/extensions/__tests__/FontFamily.test.js +7 -6
  23. package/lib/extensions/__tests__/FontWeight.test.js +19 -10
  24. package/lib/extensions/__tests__/StylePreset.test.js +52 -2
  25. package/lib/extensions/__tests__/TextDecoration.test.js +11 -40
  26. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +2 -2
  27. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +1 -1
  28. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +1 -1
  29. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +19 -1
  30. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +2 -2
  31. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +17 -1
  32. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +26 -1
  33. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +2 -2
  34. package/lib/extensions/__tests__/__snapshots__/Margin.test.js.snap +2 -2
  35. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +22 -2
  36. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +3 -46
  37. package/package.json +22 -22
  38. package/lib/components/toolbar/controls/link/LinkControlApply.vue +0 -35
  39. package/node_modules_lambda/acorn-globals/node_modules/.bin/acorn +0 -4
  40. package/node_modules_lambda/acorn-globals/node_modules/acorn/CHANGELOG.md +0 -620
  41. package/node_modules_lambda/acorn-globals/node_modules/acorn/LICENSE +0 -21
  42. package/node_modules_lambda/acorn-globals/node_modules/acorn/README.md +0 -269
  43. package/node_modules_lambda/acorn-globals/node_modules/acorn/bin/acorn +0 -4
  44. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.d.ts +0 -209
  45. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js +0 -5186
  46. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js.map +0 -1
  47. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs +0 -5155
  48. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.d.ts +0 -2
  49. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.map +0 -1
  50. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/bin.js +0 -64
  51. package/node_modules_lambda/acorn-globals/node_modules/acorn/package.json +0 -35
  52. package/node_modules_lambda/cssstyle/node_modules/cssom/LICENSE.txt +0 -20
  53. package/node_modules_lambda/cssstyle/node_modules/cssom/README.mdown +0 -67
  54. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSDocumentRule.js +0 -39
  55. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSFontFaceRule.js +0 -36
  56. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSHostRule.js +0 -37
  57. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSImportRule.js +0 -132
  58. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframeRule.js +0 -37
  59. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframesRule.js +0 -39
  60. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSMediaRule.js +0 -41
  61. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSOM.js +0 -3
  62. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSRule.js +0 -43
  63. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleDeclaration.js +0 -148
  64. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleRule.js +0 -190
  65. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleSheet.js +0 -88
  66. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSSupportsRule.js +0 -36
  67. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValue.js +0 -43
  68. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValueExpression.js +0 -344
  69. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MatcherList.js +0 -62
  70. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MediaList.js +0 -61
  71. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/StyleSheet.js +0 -17
  72. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/clone.js +0 -82
  73. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/index.js +0 -21
  74. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/parse.js +0 -464
  75. package/node_modules_lambda/cssstyle/node_modules/cssom/package.json +0 -18
  76. package/node_modules_lambda/data-urls/node_modules/whatwg-url/LICENSE.txt +0 -21
  77. package/node_modules_lambda/data-urls/node_modules/whatwg-url/README.md +0 -106
  78. package/node_modules_lambda/data-urls/node_modules/whatwg-url/index.js +0 -27
  79. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/Function.js +0 -42
  80. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL-impl.js +0 -209
  81. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL.js +0 -442
  82. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams-impl.js +0 -130
  83. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams.js +0 -472
  84. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/VoidFunction.js +0 -26
  85. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/encoding.js +0 -16
  86. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/infra.js +0 -26
  87. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/percent-encoding.js +0 -142
  88. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/url-state-machine.js +0 -1244
  89. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/urlencoded.js +0 -106
  90. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/utils.js +0 -190
  91. package/node_modules_lambda/data-urls/node_modules/whatwg-url/package.json +0 -58
  92. package/node_modules_lambda/data-urls/node_modules/whatwg-url/webidl2js-wrapper.js +0 -7
  93. package/node_modules_lambda/escodegen/node_modules/estraverse/.jshintrc +0 -16
  94. package/node_modules_lambda/escodegen/node_modules/estraverse/LICENSE.BSD +0 -19
  95. package/node_modules_lambda/escodegen/node_modules/estraverse/README.md +0 -153
  96. package/node_modules_lambda/escodegen/node_modules/estraverse/estraverse.js +0 -805
  97. package/node_modules_lambda/escodegen/node_modules/estraverse/gulpfile.js +0 -70
  98. package/node_modules_lambda/escodegen/node_modules/estraverse/package.json +0 -40
  99. package/node_modules_lambda/escodegen/node_modules/levn/LICENSE +0 -22
  100. package/node_modules_lambda/escodegen/node_modules/levn/README.md +0 -196
  101. package/node_modules_lambda/escodegen/node_modules/levn/lib/cast.js +0 -298
  102. package/node_modules_lambda/escodegen/node_modules/levn/lib/coerce.js +0 -285
  103. package/node_modules_lambda/escodegen/node_modules/levn/lib/index.js +0 -22
  104. package/node_modules_lambda/escodegen/node_modules/levn/lib/parse-string.js +0 -113
  105. package/node_modules_lambda/escodegen/node_modules/levn/lib/parse.js +0 -102
  106. package/node_modules_lambda/escodegen/node_modules/levn/package.json +0 -47
  107. package/node_modules_lambda/escodegen/node_modules/optionator/CHANGELOG.md +0 -56
  108. package/node_modules_lambda/escodegen/node_modules/optionator/LICENSE +0 -22
  109. package/node_modules_lambda/escodegen/node_modules/optionator/README.md +0 -238
  110. package/node_modules_lambda/escodegen/node_modules/optionator/lib/help.js +0 -260
  111. package/node_modules_lambda/escodegen/node_modules/optionator/lib/index.js +0 -465
  112. package/node_modules_lambda/escodegen/node_modules/optionator/lib/util.js +0 -54
  113. package/node_modules_lambda/escodegen/node_modules/optionator/package.json +0 -44
  114. package/node_modules_lambda/escodegen/node_modules/prelude-ls/CHANGELOG.md +0 -99
  115. package/node_modules_lambda/escodegen/node_modules/prelude-ls/LICENSE +0 -22
  116. package/node_modules_lambda/escodegen/node_modules/prelude-ls/README.md +0 -15
  117. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Func.js +0 -65
  118. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/List.js +0 -686
  119. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Num.js +0 -130
  120. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Obj.js +0 -154
  121. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Str.js +0 -92
  122. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/index.js +0 -178
  123. package/node_modules_lambda/escodegen/node_modules/prelude-ls/package.json +0 -52
  124. package/node_modules_lambda/escodegen/node_modules/source-map/CHANGELOG.md +0 -301
  125. package/node_modules_lambda/escodegen/node_modules/source-map/LICENSE +0 -28
  126. package/node_modules_lambda/escodegen/node_modules/source-map/README.md +0 -742
  127. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.debug.js +0 -3234
  128. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.js +0 -3233
  129. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js +0 -2
  130. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js.map +0 -1
  131. package/node_modules_lambda/escodegen/node_modules/source-map/lib/array-set.js +0 -121
  132. package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64-vlq.js +0 -140
  133. package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64.js +0 -67
  134. package/node_modules_lambda/escodegen/node_modules/source-map/lib/binary-search.js +0 -111
  135. package/node_modules_lambda/escodegen/node_modules/source-map/lib/mapping-list.js +0 -79
  136. package/node_modules_lambda/escodegen/node_modules/source-map/lib/quick-sort.js +0 -114
  137. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-consumer.js +0 -1145
  138. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-generator.js +0 -425
  139. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-node.js +0 -413
  140. package/node_modules_lambda/escodegen/node_modules/source-map/lib/util.js +0 -488
  141. package/node_modules_lambda/escodegen/node_modules/source-map/package.json +0 -73
  142. package/node_modules_lambda/escodegen/node_modules/source-map/source-map.d.ts +0 -98
  143. package/node_modules_lambda/escodegen/node_modules/source-map/source-map.js +0 -8
  144. package/node_modules_lambda/escodegen/node_modules/type-check/LICENSE +0 -22
  145. package/node_modules_lambda/escodegen/node_modules/type-check/README.md +0 -210
  146. package/node_modules_lambda/escodegen/node_modules/type-check/lib/check.js +0 -126
  147. package/node_modules_lambda/escodegen/node_modules/type-check/lib/index.js +0 -16
  148. package/node_modules_lambda/escodegen/node_modules/type-check/lib/parse-type.js +0 -196
  149. package/node_modules_lambda/escodegen/node_modules/type-check/package.json +0 -40
  150. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  151. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/Changelog.md +0 -212
  152. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/LICENSE +0 -21
  153. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/README.md +0 -130
  154. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -597
  155. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-data.js +0 -188
  156. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/index.js +0 -23
  157. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/internal.js +0 -198
  158. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  159. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  160. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data.js +0 -179
  161. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  162. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  163. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  164. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  165. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  166. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  167. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -56
  168. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  169. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf16.js +0 -197
  170. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf32.js +0 -319
  171. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf7.js +0 -290
  172. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  173. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.d.ts +0 -41
  174. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.js +0 -180
  175. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/streams.js +0 -109
  176. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/package.json +0 -44
@@ -1,64 +0,0 @@
1
- 'use strict';
2
-
3
- var path = require('path');
4
- var fs = require('fs');
5
- var acorn = require('./acorn.js');
6
-
7
- var infile, forceFile, silent = false, compact = false, tokenize = false;
8
- var options = {};
9
-
10
- function help(status) {
11
- var print = (status === 0) ? console.log : console.error;
12
- print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]");
13
- print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]");
14
- process.exit(status);
15
- }
16
-
17
- for (var i = 2; i < process.argv.length; ++i) {
18
- var arg = process.argv[i];
19
- if ((arg === "-" || arg[0] !== "-") && !infile) { infile = arg; }
20
- else if (arg === "--" && !infile && i + 2 === process.argv.length) { forceFile = infile = process.argv[++i]; }
21
- else if (arg === "--locations") { options.locations = true; }
22
- else if (arg === "--allow-hash-bang") { options.allowHashBang = true; }
23
- else if (arg === "--silent") { silent = true; }
24
- else if (arg === "--compact") { compact = true; }
25
- else if (arg === "--help") { help(0); }
26
- else if (arg === "--tokenize") { tokenize = true; }
27
- else if (arg === "--module") { options.sourceType = "module"; }
28
- else {
29
- var match = arg.match(/^--ecma(\d+)$/);
30
- if (match)
31
- { options.ecmaVersion = +match[1]; }
32
- else
33
- { help(1); }
34
- }
35
- }
36
-
37
- function run(code) {
38
- var result;
39
- try {
40
- if (!tokenize) {
41
- result = acorn.parse(code, options);
42
- } else {
43
- result = [];
44
- var tokenizer = acorn.tokenizer(code, options), token;
45
- do {
46
- token = tokenizer.getToken();
47
- result.push(token);
48
- } while (token.type !== acorn.tokTypes.eof)
49
- }
50
- } catch (e) {
51
- console.error(infile && infile !== "-" ? e.message.replace(/\(\d+:\d+\)$/, function (m) { return m.slice(0, 1) + infile + " " + m.slice(1); }) : e.message);
52
- process.exit(1);
53
- }
54
- if (!silent) { console.log(JSON.stringify(result, null, compact ? null : 2)); }
55
- }
56
-
57
- if (forceFile || infile && infile !== "-") {
58
- run(fs.readFileSync(infile, "utf8"));
59
- } else {
60
- var code = "";
61
- process.stdin.resume();
62
- process.stdin.on("data", function (chunk) { return code += chunk; });
63
- process.stdin.on("end", function () { return run(code); });
64
- }
@@ -1,35 +0,0 @@
1
- {
2
- "name": "acorn",
3
- "description": "ECMAScript parser",
4
- "homepage": "https://github.com/acornjs/acorn",
5
- "main": "dist/acorn.js",
6
- "types": "dist/acorn.d.ts",
7
- "module": "dist/acorn.mjs",
8
- "version": "7.4.1",
9
- "engines": {"node": ">=0.4.0"},
10
- "maintainers": [
11
- {
12
- "name": "Marijn Haverbeke",
13
- "email": "marijnh@gmail.com",
14
- "web": "https://marijnhaverbeke.nl"
15
- },
16
- {
17
- "name": "Ingvar Stepanyan",
18
- "email": "me@rreverser.com",
19
- "web": "https://rreverser.com/"
20
- },
21
- {
22
- "name": "Adrian Heine",
23
- "web": "http://adrianheine.de"
24
- }
25
- ],
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/acornjs/acorn.git"
29
- },
30
- "license": "MIT",
31
- "scripts": {
32
- "prepare": "cd ..; npm run build:main && npm run build:bin"
33
- },
34
- "bin": {"acorn": "./bin/acorn"}
35
- }
@@ -1,20 +0,0 @@
1
- Copyright (c) Nikita Vasilyev
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,67 +0,0 @@
1
- # CSSOM
2
-
3
- CSSOM.js is a CSS parser written in pure JavaScript. It is also a partial implementation of [CSS Object Model](http://dev.w3.org/csswg/cssom/).
4
-
5
- CSSOM.parse("body {color: black}")
6
- -> {
7
- cssRules: [
8
- {
9
- selectorText: "body",
10
- style: {
11
- 0: "color",
12
- color: "black",
13
- length: 1
14
- }
15
- }
16
- ]
17
- }
18
-
19
-
20
- ## [Parser demo](http://nv.github.com/CSSOM/docs/parse.html)
21
-
22
- Works well in Google Chrome 6+, Safari 5+, Firefox 3.6+, Opera 10.63+.
23
- Doesn't work in IE < 9 because of unsupported getters/setters.
24
-
25
- To use CSSOM.js in the browser you might want to build a one-file version that exposes a single `CSSOM` global variable:
26
-
27
- ➤ git clone https://github.com/NV/CSSOM.git
28
- ➤ cd CSSOM
29
- ➤ node build.js
30
- build/CSSOM.js is done
31
-
32
- To use it with Node.js or any other CommonJS loader:
33
-
34
- ➤ npm install cssom
35
-
36
- ## Don’t use it if...
37
-
38
- You parse CSS to mungle, minify or reformat code like this:
39
-
40
- ```css
41
- div {
42
- background: gray;
43
- background: linear-gradient(to bottom, white 0%, black 100%);
44
- }
45
- ```
46
-
47
- This pattern is often used to give browsers that don’t understand linear gradients a fallback solution (e.g. gray color in the example).
48
- In CSSOM, `background: gray` [gets overwritten](http://nv.github.io/CSSOM/docs/parse.html#css=div%20%7B%0A%20%20%20%20%20%20background%3A%20gray%3B%0A%20%20%20%20background%3A%20linear-gradient(to%20bottom%2C%20white%200%25%2C%20black%20100%25)%3B%0A%7D).
49
- It doesn't get preserved.
50
-
51
- If you do CSS mungling, minification, image inlining, and such, CSSOM.js is no good for you, considere using one of the following:
52
-
53
- * [postcss](https://github.com/postcss/postcss)
54
- * [reworkcss/css](https://github.com/reworkcss/css)
55
- * [csso](https://github.com/css/csso)
56
- * [mensch](https://github.com/brettstimmerman/mensch)
57
-
58
-
59
- ## [Tests](http://nv.github.com/CSSOM/spec/)
60
-
61
- To run tests locally:
62
-
63
- ➤ git submodule init
64
- ➤ git submodule update
65
-
66
-
67
- ## [Who uses CSSOM.js](https://github.com/NV/CSSOM/wiki/Who-uses-CSSOM.js)
@@ -1,39 +0,0 @@
1
- //.CommonJS
2
- var CSSOM = {
3
- CSSRule: require("./CSSRule").CSSRule,
4
- MatcherList: require("./MatcherList").MatcherList
5
- };
6
- ///CommonJS
7
-
8
-
9
- /**
10
- * @constructor
11
- * @see https://developer.mozilla.org/en/CSS/@-moz-document
12
- */
13
- CSSOM.CSSDocumentRule = function CSSDocumentRule() {
14
- CSSOM.CSSRule.call(this);
15
- this.matcher = new CSSOM.MatcherList();
16
- this.cssRules = [];
17
- };
18
-
19
- CSSOM.CSSDocumentRule.prototype = new CSSOM.CSSRule();
20
- CSSOM.CSSDocumentRule.prototype.constructor = CSSOM.CSSDocumentRule;
21
- CSSOM.CSSDocumentRule.prototype.type = 10;
22
- //FIXME
23
- //CSSOM.CSSDocumentRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
24
- //CSSOM.CSSDocumentRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
25
-
26
- Object.defineProperty(CSSOM.CSSDocumentRule.prototype, "cssText", {
27
- get: function() {
28
- var cssTexts = [];
29
- for (var i=0, length=this.cssRules.length; i < length; i++) {
30
- cssTexts.push(this.cssRules[i].cssText);
31
- }
32
- return "@-moz-document " + this.matcher.matcherText + " {" + cssTexts.join("") + "}";
33
- }
34
- });
35
-
36
-
37
- //.CommonJS
38
- exports.CSSDocumentRule = CSSOM.CSSDocumentRule;
39
- ///CommonJS
@@ -1,36 +0,0 @@
1
- //.CommonJS
2
- var CSSOM = {
3
- CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration,
4
- CSSRule: require("./CSSRule").CSSRule
5
- };
6
- ///CommonJS
7
-
8
-
9
- /**
10
- * @constructor
11
- * @see http://dev.w3.org/csswg/cssom/#css-font-face-rule
12
- */
13
- CSSOM.CSSFontFaceRule = function CSSFontFaceRule() {
14
- CSSOM.CSSRule.call(this);
15
- this.style = new CSSOM.CSSStyleDeclaration();
16
- this.style.parentRule = this;
17
- };
18
-
19
- CSSOM.CSSFontFaceRule.prototype = new CSSOM.CSSRule();
20
- CSSOM.CSSFontFaceRule.prototype.constructor = CSSOM.CSSFontFaceRule;
21
- CSSOM.CSSFontFaceRule.prototype.type = 5;
22
- //FIXME
23
- //CSSOM.CSSFontFaceRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
24
- //CSSOM.CSSFontFaceRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
25
-
26
- // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSFontFaceRule.cpp
27
- Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "cssText", {
28
- get: function() {
29
- return "@font-face {" + this.style.cssText + "}";
30
- }
31
- });
32
-
33
-
34
- //.CommonJS
35
- exports.CSSFontFaceRule = CSSOM.CSSFontFaceRule;
36
- ///CommonJS
@@ -1,37 +0,0 @@
1
- //.CommonJS
2
- var CSSOM = {
3
- CSSRule: require("./CSSRule").CSSRule
4
- };
5
- ///CommonJS
6
-
7
-
8
- /**
9
- * @constructor
10
- * @see http://www.w3.org/TR/shadow-dom/#host-at-rule
11
- */
12
- CSSOM.CSSHostRule = function CSSHostRule() {
13
- CSSOM.CSSRule.call(this);
14
- this.cssRules = [];
15
- };
16
-
17
- CSSOM.CSSHostRule.prototype = new CSSOM.CSSRule();
18
- CSSOM.CSSHostRule.prototype.constructor = CSSOM.CSSHostRule;
19
- CSSOM.CSSHostRule.prototype.type = 1001;
20
- //FIXME
21
- //CSSOM.CSSHostRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
22
- //CSSOM.CSSHostRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
23
-
24
- Object.defineProperty(CSSOM.CSSHostRule.prototype, "cssText", {
25
- get: function() {
26
- var cssTexts = [];
27
- for (var i=0, length=this.cssRules.length; i < length; i++) {
28
- cssTexts.push(this.cssRules[i].cssText);
29
- }
30
- return "@host {" + cssTexts.join("") + "}";
31
- }
32
- });
33
-
34
-
35
- //.CommonJS
36
- exports.CSSHostRule = CSSOM.CSSHostRule;
37
- ///CommonJS
@@ -1,132 +0,0 @@
1
- //.CommonJS
2
- var CSSOM = {
3
- CSSRule: require("./CSSRule").CSSRule,
4
- CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet,
5
- MediaList: require("./MediaList").MediaList
6
- };
7
- ///CommonJS
8
-
9
-
10
- /**
11
- * @constructor
12
- * @see http://dev.w3.org/csswg/cssom/#cssimportrule
13
- * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSImportRule
14
- */
15
- CSSOM.CSSImportRule = function CSSImportRule() {
16
- CSSOM.CSSRule.call(this);
17
- this.href = "";
18
- this.media = new CSSOM.MediaList();
19
- this.styleSheet = new CSSOM.CSSStyleSheet();
20
- };
21
-
22
- CSSOM.CSSImportRule.prototype = new CSSOM.CSSRule();
23
- CSSOM.CSSImportRule.prototype.constructor = CSSOM.CSSImportRule;
24
- CSSOM.CSSImportRule.prototype.type = 3;
25
-
26
- Object.defineProperty(CSSOM.CSSImportRule.prototype, "cssText", {
27
- get: function() {
28
- var mediaText = this.media.mediaText;
29
- return "@import url(" + this.href + ")" + (mediaText ? " " + mediaText : "") + ";";
30
- },
31
- set: function(cssText) {
32
- var i = 0;
33
-
34
- /**
35
- * @import url(partial.css) screen, handheld;
36
- * || |
37
- * after-import media
38
- * |
39
- * url
40
- */
41
- var state = '';
42
-
43
- var buffer = '';
44
- var index;
45
- for (var character; (character = cssText.charAt(i)); i++) {
46
-
47
- switch (character) {
48
- case ' ':
49
- case '\t':
50
- case '\r':
51
- case '\n':
52
- case '\f':
53
- if (state === 'after-import') {
54
- state = 'url';
55
- } else {
56
- buffer += character;
57
- }
58
- break;
59
-
60
- case '@':
61
- if (!state && cssText.indexOf('@import', i) === i) {
62
- state = 'after-import';
63
- i += 'import'.length;
64
- buffer = '';
65
- }
66
- break;
67
-
68
- case 'u':
69
- if (state === 'url' && cssText.indexOf('url(', i) === i) {
70
- index = cssText.indexOf(')', i + 1);
71
- if (index === -1) {
72
- throw i + ': ")" not found';
73
- }
74
- i += 'url('.length;
75
- var url = cssText.slice(i, index);
76
- if (url[0] === url[url.length - 1]) {
77
- if (url[0] === '"' || url[0] === "'") {
78
- url = url.slice(1, -1);
79
- }
80
- }
81
- this.href = url;
82
- i = index;
83
- state = 'media';
84
- }
85
- break;
86
-
87
- case '"':
88
- if (state === 'url') {
89
- index = cssText.indexOf('"', i + 1);
90
- if (!index) {
91
- throw i + ": '\"' not found";
92
- }
93
- this.href = cssText.slice(i + 1, index);
94
- i = index;
95
- state = 'media';
96
- }
97
- break;
98
-
99
- case "'":
100
- if (state === 'url') {
101
- index = cssText.indexOf("'", i + 1);
102
- if (!index) {
103
- throw i + ': "\'" not found';
104
- }
105
- this.href = cssText.slice(i + 1, index);
106
- i = index;
107
- state = 'media';
108
- }
109
- break;
110
-
111
- case ';':
112
- if (state === 'media') {
113
- if (buffer) {
114
- this.media.mediaText = buffer.trim();
115
- }
116
- }
117
- break;
118
-
119
- default:
120
- if (state === 'media') {
121
- buffer += character;
122
- }
123
- break;
124
- }
125
- }
126
- }
127
- });
128
-
129
-
130
- //.CommonJS
131
- exports.CSSImportRule = CSSOM.CSSImportRule;
132
- ///CommonJS
@@ -1,37 +0,0 @@
1
- //.CommonJS
2
- var CSSOM = {
3
- CSSRule: require("./CSSRule").CSSRule,
4
- CSSStyleDeclaration: require('./CSSStyleDeclaration').CSSStyleDeclaration
5
- };
6
- ///CommonJS
7
-
8
-
9
- /**
10
- * @constructor
11
- * @see http://www.w3.org/TR/css3-animations/#DOM-CSSKeyframeRule
12
- */
13
- CSSOM.CSSKeyframeRule = function CSSKeyframeRule() {
14
- CSSOM.CSSRule.call(this);
15
- this.keyText = '';
16
- this.style = new CSSOM.CSSStyleDeclaration();
17
- this.style.parentRule = this;
18
- };
19
-
20
- CSSOM.CSSKeyframeRule.prototype = new CSSOM.CSSRule();
21
- CSSOM.CSSKeyframeRule.prototype.constructor = CSSOM.CSSKeyframeRule;
22
- CSSOM.CSSKeyframeRule.prototype.type = 9;
23
- //FIXME
24
- //CSSOM.CSSKeyframeRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
25
- //CSSOM.CSSKeyframeRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
26
-
27
- // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframeRule.cpp
28
- Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "cssText", {
29
- get: function() {
30
- return this.keyText + " {" + this.style.cssText + "} ";
31
- }
32
- });
33
-
34
-
35
- //.CommonJS
36
- exports.CSSKeyframeRule = CSSOM.CSSKeyframeRule;
37
- ///CommonJS
@@ -1,39 +0,0 @@
1
- //.CommonJS
2
- var CSSOM = {
3
- CSSRule: require("./CSSRule").CSSRule
4
- };
5
- ///CommonJS
6
-
7
-
8
- /**
9
- * @constructor
10
- * @see http://www.w3.org/TR/css3-animations/#DOM-CSSKeyframesRule
11
- */
12
- CSSOM.CSSKeyframesRule = function CSSKeyframesRule() {
13
- CSSOM.CSSRule.call(this);
14
- this.name = '';
15
- this.cssRules = [];
16
- };
17
-
18
- CSSOM.CSSKeyframesRule.prototype = new CSSOM.CSSRule();
19
- CSSOM.CSSKeyframesRule.prototype.constructor = CSSOM.CSSKeyframesRule;
20
- CSSOM.CSSKeyframesRule.prototype.type = 8;
21
- //FIXME
22
- //CSSOM.CSSKeyframesRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
23
- //CSSOM.CSSKeyframesRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
24
-
25
- // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframesRule.cpp
26
- Object.defineProperty(CSSOM.CSSKeyframesRule.prototype, "cssText", {
27
- get: function() {
28
- var cssTexts = [];
29
- for (var i=0, length=this.cssRules.length; i < length; i++) {
30
- cssTexts.push(" " + this.cssRules[i].cssText);
31
- }
32
- return "@" + (this._vendorPrefix || '') + "keyframes " + this.name + " { \n" + cssTexts.join("\n") + "\n}";
33
- }
34
- });
35
-
36
-
37
- //.CommonJS
38
- exports.CSSKeyframesRule = CSSOM.CSSKeyframesRule;
39
- ///CommonJS
@@ -1,41 +0,0 @@
1
- //.CommonJS
2
- var CSSOM = {
3
- CSSRule: require("./CSSRule").CSSRule,
4
- MediaList: require("./MediaList").MediaList
5
- };
6
- ///CommonJS
7
-
8
-
9
- /**
10
- * @constructor
11
- * @see http://dev.w3.org/csswg/cssom/#cssmediarule
12
- * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSMediaRule
13
- */
14
- CSSOM.CSSMediaRule = function CSSMediaRule() {
15
- CSSOM.CSSRule.call(this);
16
- this.media = new CSSOM.MediaList();
17
- this.cssRules = [];
18
- };
19
-
20
- CSSOM.CSSMediaRule.prototype = new CSSOM.CSSRule();
21
- CSSOM.CSSMediaRule.prototype.constructor = CSSOM.CSSMediaRule;
22
- CSSOM.CSSMediaRule.prototype.type = 4;
23
- //FIXME
24
- //CSSOM.CSSMediaRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
25
- //CSSOM.CSSMediaRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
26
-
27
- // http://opensource.apple.com/source/WebCore/WebCore-658.28/css/CSSMediaRule.cpp
28
- Object.defineProperty(CSSOM.CSSMediaRule.prototype, "cssText", {
29
- get: function() {
30
- var cssTexts = [];
31
- for (var i=0, length=this.cssRules.length; i < length; i++) {
32
- cssTexts.push(this.cssRules[i].cssText);
33
- }
34
- return "@media " + this.media.mediaText + " {" + cssTexts.join("") + "}";
35
- }
36
- });
37
-
38
-
39
- //.CommonJS
40
- exports.CSSMediaRule = CSSOM.CSSMediaRule;
41
- ///CommonJS
@@ -1,3 +0,0 @@
1
- var CSSOM = {};
2
-
3
-
@@ -1,43 +0,0 @@
1
- //.CommonJS
2
- var CSSOM = {};
3
- ///CommonJS
4
-
5
-
6
- /**
7
- * @constructor
8
- * @see http://dev.w3.org/csswg/cssom/#the-cssrule-interface
9
- * @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRule
10
- */
11
- CSSOM.CSSRule = function CSSRule() {
12
- this.parentRule = null;
13
- this.parentStyleSheet = null;
14
- };
15
-
16
- CSSOM.CSSRule.UNKNOWN_RULE = 0; // obsolete
17
- CSSOM.CSSRule.STYLE_RULE = 1;
18
- CSSOM.CSSRule.CHARSET_RULE = 2; // obsolete
19
- CSSOM.CSSRule.IMPORT_RULE = 3;
20
- CSSOM.CSSRule.MEDIA_RULE = 4;
21
- CSSOM.CSSRule.FONT_FACE_RULE = 5;
22
- CSSOM.CSSRule.PAGE_RULE = 6;
23
- CSSOM.CSSRule.KEYFRAMES_RULE = 7;
24
- CSSOM.CSSRule.KEYFRAME_RULE = 8;
25
- CSSOM.CSSRule.MARGIN_RULE = 9;
26
- CSSOM.CSSRule.NAMESPACE_RULE = 10;
27
- CSSOM.CSSRule.COUNTER_STYLE_RULE = 11;
28
- CSSOM.CSSRule.SUPPORTS_RULE = 12;
29
- CSSOM.CSSRule.DOCUMENT_RULE = 13;
30
- CSSOM.CSSRule.FONT_FEATURE_VALUES_RULE = 14;
31
- CSSOM.CSSRule.VIEWPORT_RULE = 15;
32
- CSSOM.CSSRule.REGION_STYLE_RULE = 16;
33
-
34
-
35
- CSSOM.CSSRule.prototype = {
36
- constructor: CSSOM.CSSRule
37
- //FIXME
38
- };
39
-
40
-
41
- //.CommonJS
42
- exports.CSSRule = CSSOM.CSSRule;
43
- ///CommonJS