@react-fabric/lexical 1.0.0-beta.0

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 (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/dist/cjs/_virtual/prism.js +5 -0
  4. package/dist/cjs/editor/Lexical.module.css +1 -0
  5. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +432 -0
  6. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +21 -0
  7. package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +27 -0
  8. package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +1139 -0
  9. package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +25 -0
  10. package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +50 -0
  11. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +245 -0
  12. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +19 -0
  13. package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +18 -0
  14. package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +471 -0
  15. package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +17 -0
  16. package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +24 -0
  17. package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +1275 -0
  18. package/dist/cjs/node_modules/@lexical/list/LexicalList.js +29 -0
  19. package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +29 -0
  20. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +789 -0
  21. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +29 -0
  22. package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +26 -0
  23. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +976 -0
  24. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +35 -0
  25. package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +35 -0
  26. package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +2792 -0
  27. package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +23 -0
  28. package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +55 -0
  29. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +888 -0
  30. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +35 -0
  31. package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +66 -0
  32. package/dist/cjs/node_modules/@mdi/js/mdi.js +8 -0
  33. package/dist/cjs/node_modules/prismjs/components/prism-c.js +82 -0
  34. package/dist/cjs/node_modules/prismjs/components/prism-clike.js +33 -0
  35. package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +101 -0
  36. package/dist/cjs/node_modules/prismjs/components/prism-css.js +66 -0
  37. package/dist/cjs/node_modules/prismjs/components/prism-java.js +126 -0
  38. package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +174 -0
  39. package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +417 -0
  40. package/dist/cjs/node_modules/prismjs/components/prism-markup.js +188 -0
  41. package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +14 -0
  42. package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +60 -0
  43. package/dist/cjs/node_modules/prismjs/components/prism-python.js +67 -0
  44. package/dist/cjs/node_modules/prismjs/components/prism-rust.js +130 -0
  45. package/dist/cjs/node_modules/prismjs/components/prism-sql.js +34 -0
  46. package/dist/cjs/node_modules/prismjs/components/prism-swift.js +150 -0
  47. package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +62 -0
  48. package/dist/cjs/node_modules/prismjs/prism.js +1951 -0
  49. package/dist/cjs/packages/lexical/src/components/StickyComponent.js +221 -0
  50. package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +156 -0
  51. package/dist/cjs/packages/lexical/src/editor/theme.js +97 -0
  52. package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +451 -0
  53. package/dist/cjs/packages/lexical/src/index.js +7 -0
  54. package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +218 -0
  55. package/dist/cjs/packages/lexical/src/plugins/DraggableBlockPlugin.js +314 -0
  56. package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +20 -0
  57. package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +258 -0
  58. package/dist/cjs/packages/lexical/src/utils/index.js +214 -0
  59. package/dist/esm/_virtual/prism.js +5 -0
  60. package/dist/esm/editor/Lexical.module.css +1 -0
  61. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +423 -0
  62. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +19 -0
  63. package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +18 -0
  64. package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +1121 -0
  65. package/dist/esm/node_modules/@lexical/code/LexicalCode.js +21 -0
  66. package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +32 -0
  67. package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +244 -0
  68. package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +18 -0
  69. package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +17 -0
  70. package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +463 -0
  71. package/dist/esm/node_modules/@lexical/link/LexicalLink.js +17 -0
  72. package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +16 -0
  73. package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +1262 -0
  74. package/dist/esm/node_modules/@lexical/list/LexicalList.js +23 -0
  75. package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +16 -0
  76. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +781 -0
  77. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +23 -0
  78. package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +18 -0
  79. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +957 -0
  80. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +26 -0
  81. package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +16 -0
  82. package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +2754 -0
  83. package/dist/esm/node_modules/@lexical/table/LexicalTable.js +20 -0
  84. package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +17 -0
  85. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +839 -0
  86. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +26 -0
  87. package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +17 -0
  88. package/dist/esm/node_modules/@mdi/js/mdi.js +7 -0
  89. package/dist/esm/node_modules/prismjs/components/prism-c.js +82 -0
  90. package/dist/esm/node_modules/prismjs/components/prism-clike.js +33 -0
  91. package/dist/esm/node_modules/prismjs/components/prism-cpp.js +101 -0
  92. package/dist/esm/node_modules/prismjs/components/prism-css.js +66 -0
  93. package/dist/esm/node_modules/prismjs/components/prism-java.js +126 -0
  94. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +174 -0
  95. package/dist/esm/node_modules/prismjs/components/prism-markdown.js +417 -0
  96. package/dist/esm/node_modules/prismjs/components/prism-markup.js +188 -0
  97. package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +14 -0
  98. package/dist/esm/node_modules/prismjs/components/prism-powershell.js +60 -0
  99. package/dist/esm/node_modules/prismjs/components/prism-python.js +67 -0
  100. package/dist/esm/node_modules/prismjs/components/prism-rust.js +130 -0
  101. package/dist/esm/node_modules/prismjs/components/prism-sql.js +34 -0
  102. package/dist/esm/node_modules/prismjs/components/prism-swift.js +150 -0
  103. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +62 -0
  104. package/dist/esm/node_modules/prismjs/prism.js +1951 -0
  105. package/dist/esm/packages/lexical/src/components/StickyComponent.js +221 -0
  106. package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +156 -0
  107. package/dist/esm/packages/lexical/src/editor/theme.js +97 -0
  108. package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +450 -0
  109. package/dist/esm/packages/lexical/src/index.js +3 -0
  110. package/dist/esm/packages/lexical/src/nodes/StickyNode.js +216 -0
  111. package/dist/esm/packages/lexical/src/plugins/DraggableBlockPlugin.js +314 -0
  112. package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +20 -0
  113. package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +258 -0
  114. package/dist/esm/packages/lexical/src/utils/index.js +211 -0
  115. package/dist/types/components/StickyComponent.d.ts +9 -0
  116. package/dist/types/editor/LexicalEditor.d.ts +13 -0
  117. package/dist/types/editor/theme.d.ts +70 -0
  118. package/dist/types/hooks/useFormatWatcher.d.ts +40 -0
  119. package/dist/types/index.d.ts +1 -0
  120. package/dist/types/nodes/StickyNode.d.ts +35 -0
  121. package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -0
  122. package/dist/types/plugins/StickyPlugin.d.ts +1 -0
  123. package/dist/types/plugins/ToolbarPlugin.d.ts +1 -0
  124. package/dist/types/utils/index.d.ts +57 -0
  125. package/package.json +55 -0
  126. package/src/components/StickyComponent.tsx +271 -0
  127. package/src/editor/Lexical.module.css +218 -0
  128. package/src/editor/LexicalEditor.tsx +222 -0
  129. package/src/editor/theme.ts +93 -0
  130. package/src/hooks/useFormatWatcher.ts +504 -0
  131. package/src/index.ts +24 -0
  132. package/src/nodes/StickyNode.tsx +249 -0
  133. package/src/plugins/DraggableBlockPlugin.tsx +418 -0
  134. package/src/plugins/StickyPlugin.ts +38 -0
  135. package/src/plugins/ToolbarPlugin.tsx +279 -0
  136. package/src/utils/index.ts +303 -0
@@ -0,0 +1,174 @@
1
+ 'use strict';
2
+
3
+ Prism.languages.javascript = Prism.languages.extend('clike', {
4
+ 'class-name': [
5
+ Prism.languages.clike['class-name'],
6
+ {
7
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
8
+ lookbehind: true
9
+ }
10
+ ],
11
+ 'keyword': [
12
+ {
13
+ pattern: /((?:^|\})\s*)catch\b/,
14
+ lookbehind: true
15
+ },
16
+ {
17
+ pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
18
+ lookbehind: true
19
+ },
20
+ ],
21
+ // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
22
+ 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
23
+ 'number': {
24
+ pattern: RegExp(
25
+ /(^|[^\w$])/.source +
26
+ '(?:' +
27
+ (
28
+ // constant
29
+ /NaN|Infinity/.source +
30
+ '|' +
31
+ // binary integer
32
+ /0[bB][01]+(?:_[01]+)*n?/.source +
33
+ '|' +
34
+ // octal integer
35
+ /0[oO][0-7]+(?:_[0-7]+)*n?/.source +
36
+ '|' +
37
+ // hexadecimal integer
38
+ /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
39
+ '|' +
40
+ // decimal bigint
41
+ /\d+(?:_\d+)*n/.source +
42
+ '|' +
43
+ // decimal number (integer or float) but no bigint
44
+ /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
45
+ ) +
46
+ ')' +
47
+ /(?![\w$])/.source
48
+ ),
49
+ lookbehind: true
50
+ },
51
+ 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
52
+ });
53
+
54
+ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
55
+
56
+ Prism.languages.insertBefore('javascript', 'keyword', {
57
+ 'regex': {
58
+ pattern: RegExp(
59
+ // lookbehind
60
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
61
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
62
+ // Regex pattern:
63
+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
64
+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
65
+ // with the only syntax, so we have to define 2 different regex patterns.
66
+ /\//.source +
67
+ '(?:' +
68
+ /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
69
+ '|' +
70
+ // `v` flag syntax. This supports 3 levels of nested character classes.
71
+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
72
+ ')' +
73
+ // lookahead
74
+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
75
+ ),
76
+ lookbehind: true,
77
+ greedy: true,
78
+ inside: {
79
+ 'regex-source': {
80
+ pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
81
+ lookbehind: true,
82
+ alias: 'language-regex',
83
+ inside: Prism.languages.regex
84
+ },
85
+ 'regex-delimiter': /^\/|\/$/,
86
+ 'regex-flags': /^[a-z]+$/,
87
+ }
88
+ },
89
+ // This must be declared before keyword because we use "function" inside the look-forward
90
+ 'function-variable': {
91
+ pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
92
+ alias: 'function'
93
+ },
94
+ 'parameter': [
95
+ {
96
+ pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
97
+ lookbehind: true,
98
+ inside: Prism.languages.javascript
99
+ },
100
+ {
101
+ pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
102
+ lookbehind: true,
103
+ inside: Prism.languages.javascript
104
+ },
105
+ {
106
+ pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
107
+ lookbehind: true,
108
+ inside: Prism.languages.javascript
109
+ },
110
+ {
111
+ pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
112
+ lookbehind: true,
113
+ inside: Prism.languages.javascript
114
+ }
115
+ ],
116
+ 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
117
+ });
118
+
119
+ Prism.languages.insertBefore('javascript', 'string', {
120
+ 'hashbang': {
121
+ pattern: /^#!.*/,
122
+ greedy: true,
123
+ alias: 'comment'
124
+ },
125
+ 'template-string': {
126
+ pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
127
+ greedy: true,
128
+ inside: {
129
+ 'template-punctuation': {
130
+ pattern: /^`|`$/,
131
+ alias: 'string'
132
+ },
133
+ 'interpolation': {
134
+ pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
135
+ lookbehind: true,
136
+ inside: {
137
+ 'interpolation-punctuation': {
138
+ pattern: /^\$\{|\}$/,
139
+ alias: 'punctuation'
140
+ },
141
+ rest: Prism.languages.javascript
142
+ }
143
+ },
144
+ 'string': /[\s\S]+/
145
+ }
146
+ },
147
+ 'string-property': {
148
+ pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
149
+ lookbehind: true,
150
+ greedy: true,
151
+ alias: 'property'
152
+ }
153
+ });
154
+
155
+ Prism.languages.insertBefore('javascript', 'operator', {
156
+ 'literal-property': {
157
+ pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
158
+ lookbehind: true,
159
+ alias: 'property'
160
+ },
161
+ });
162
+
163
+ if (Prism.languages.markup) {
164
+ Prism.languages.markup.tag.addInlined('script', 'javascript');
165
+
166
+ // add attribute support for all DOM events.
167
+ // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
168
+ Prism.languages.markup.tag.addAttribute(
169
+ /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
170
+ 'javascript'
171
+ );
172
+ }
173
+
174
+ Prism.languages.js = Prism.languages.javascript;
@@ -0,0 +1,417 @@
1
+ 'use strict';
2
+
3
+ (function (Prism) {
4
+
5
+ // Allow only one line break
6
+ var inner = /(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;
7
+
8
+ /**
9
+ * This function is intended for the creation of the bold or italic pattern.
10
+ *
11
+ * This also adds a lookbehind group to the given pattern to ensure that the pattern is not backslash-escaped.
12
+ *
13
+ * _Note:_ Keep in mind that this adds a capturing group.
14
+ *
15
+ * @param {string} pattern
16
+ * @returns {RegExp}
17
+ */
18
+ function createInline(pattern) {
19
+ pattern = pattern.replace(/<inner>/g, function () { return inner; });
20
+ return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + '(?:' + pattern + ')');
21
+ }
22
+
23
+
24
+ var tableCell = /(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source;
25
+ var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g, function () { return tableCell; });
26
+ var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;
27
+
28
+
29
+ Prism.languages.markdown = Prism.languages.extend('markup', {});
30
+ Prism.languages.insertBefore('markdown', 'prolog', {
31
+ 'front-matter-block': {
32
+ pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,
33
+ lookbehind: true,
34
+ greedy: true,
35
+ inside: {
36
+ 'punctuation': /^---|---$/,
37
+ 'front-matter': {
38
+ pattern: /\S+(?:\s+\S+)*/,
39
+ alias: ['yaml', 'language-yaml'],
40
+ inside: Prism.languages.yaml
41
+ }
42
+ }
43
+ },
44
+ 'blockquote': {
45
+ // > ...
46
+ pattern: /^>(?:[\t ]*>)*/m,
47
+ alias: 'punctuation'
48
+ },
49
+ 'table': {
50
+ pattern: RegExp('^' + tableRow + tableLine + '(?:' + tableRow + ')*', 'm'),
51
+ inside: {
52
+ 'table-data-rows': {
53
+ pattern: RegExp('^(' + tableRow + tableLine + ')(?:' + tableRow + ')*$'),
54
+ lookbehind: true,
55
+ inside: {
56
+ 'table-data': {
57
+ pattern: RegExp(tableCell),
58
+ inside: Prism.languages.markdown
59
+ },
60
+ 'punctuation': /\|/
61
+ }
62
+ },
63
+ 'table-line': {
64
+ pattern: RegExp('^(' + tableRow + ')' + tableLine + '$'),
65
+ lookbehind: true,
66
+ inside: {
67
+ 'punctuation': /\||:?-{3,}:?/
68
+ }
69
+ },
70
+ 'table-header-row': {
71
+ pattern: RegExp('^' + tableRow + '$'),
72
+ inside: {
73
+ 'table-header': {
74
+ pattern: RegExp(tableCell),
75
+ alias: 'important',
76
+ inside: Prism.languages.markdown
77
+ },
78
+ 'punctuation': /\|/
79
+ }
80
+ }
81
+ }
82
+ },
83
+ 'code': [
84
+ {
85
+ // Prefixed by 4 spaces or 1 tab and preceded by an empty line
86
+ pattern: /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,
87
+ lookbehind: true,
88
+ alias: 'keyword'
89
+ },
90
+ {
91
+ // ```optional language
92
+ // code block
93
+ // ```
94
+ pattern: /^```[\s\S]*?^```$/m,
95
+ greedy: true,
96
+ inside: {
97
+ 'code-block': {
98
+ pattern: /^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,
99
+ lookbehind: true
100
+ },
101
+ 'code-language': {
102
+ pattern: /^(```).+/,
103
+ lookbehind: true
104
+ },
105
+ 'punctuation': /```/
106
+ }
107
+ }
108
+ ],
109
+ 'title': [
110
+ {
111
+ // title 1
112
+ // =======
113
+
114
+ // title 2
115
+ // -------
116
+ pattern: /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,
117
+ alias: 'important',
118
+ inside: {
119
+ punctuation: /==+$|--+$/
120
+ }
121
+ },
122
+ {
123
+ // # title 1
124
+ // ###### title 6
125
+ pattern: /(^\s*)#.+/m,
126
+ lookbehind: true,
127
+ alias: 'important',
128
+ inside: {
129
+ punctuation: /^#+|#+$/
130
+ }
131
+ }
132
+ ],
133
+ 'hr': {
134
+ // ***
135
+ // ---
136
+ // * * *
137
+ // -----------
138
+ pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,
139
+ lookbehind: true,
140
+ alias: 'punctuation'
141
+ },
142
+ 'list': {
143
+ // * item
144
+ // + item
145
+ // - item
146
+ // 1. item
147
+ pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
148
+ lookbehind: true,
149
+ alias: 'punctuation'
150
+ },
151
+ 'url-reference': {
152
+ // [id]: http://example.com "Optional title"
153
+ // [id]: http://example.com 'Optional title'
154
+ // [id]: http://example.com (Optional title)
155
+ // [id]: <http://example.com> "Optional title"
156
+ pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
157
+ inside: {
158
+ 'variable': {
159
+ pattern: /^(!?\[)[^\]]+/,
160
+ lookbehind: true
161
+ },
162
+ 'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,
163
+ 'punctuation': /^[\[\]!:]|[<>]/
164
+ },
165
+ alias: 'url'
166
+ },
167
+ 'bold': {
168
+ // **strong**
169
+ // __strong__
170
+
171
+ // allow one nested instance of italic text using the same delimiter
172
+ pattern: createInline(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),
173
+ lookbehind: true,
174
+ greedy: true,
175
+ inside: {
176
+ 'content': {
177
+ pattern: /(^..)[\s\S]+(?=..$)/,
178
+ lookbehind: true,
179
+ inside: {} // see below
180
+ },
181
+ 'punctuation': /\*\*|__/
182
+ }
183
+ },
184
+ 'italic': {
185
+ // *em*
186
+ // _em_
187
+
188
+ // allow one nested instance of bold text using the same delimiter
189
+ pattern: createInline(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),
190
+ lookbehind: true,
191
+ greedy: true,
192
+ inside: {
193
+ 'content': {
194
+ pattern: /(^.)[\s\S]+(?=.$)/,
195
+ lookbehind: true,
196
+ inside: {} // see below
197
+ },
198
+ 'punctuation': /[*_]/
199
+ }
200
+ },
201
+ 'strike': {
202
+ // ~~strike through~~
203
+ // ~strike~
204
+ // eslint-disable-next-line regexp/strict
205
+ pattern: createInline(/(~~?)(?:(?!~)<inner>)+\2/.source),
206
+ lookbehind: true,
207
+ greedy: true,
208
+ inside: {
209
+ 'content': {
210
+ pattern: /(^~~?)[\s\S]+(?=\1$)/,
211
+ lookbehind: true,
212
+ inside: {} // see below
213
+ },
214
+ 'punctuation': /~~?/
215
+ }
216
+ },
217
+ 'code-snippet': {
218
+ // `code`
219
+ // ``code``
220
+ pattern: /(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,
221
+ lookbehind: true,
222
+ greedy: true,
223
+ alias: ['code', 'keyword']
224
+ },
225
+ 'url': {
226
+ // [example](http://example.com "Optional title")
227
+ // [example][id]
228
+ // [example] [id]
229
+ pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),
230
+ lookbehind: true,
231
+ greedy: true,
232
+ inside: {
233
+ 'operator': /^!/,
234
+ 'content': {
235
+ pattern: /(^\[)[^\]]+(?=\])/,
236
+ lookbehind: true,
237
+ inside: {} // see below
238
+ },
239
+ 'variable': {
240
+ pattern: /(^\][ \t]?\[)[^\]]+(?=\]$)/,
241
+ lookbehind: true
242
+ },
243
+ 'url': {
244
+ pattern: /(^\]\()[^\s)]+/,
245
+ lookbehind: true
246
+ },
247
+ 'string': {
248
+ pattern: /(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,
249
+ lookbehind: true
250
+ }
251
+ }
252
+ }
253
+ });
254
+
255
+ ['url', 'bold', 'italic', 'strike'].forEach(function (token) {
256
+ ['url', 'bold', 'italic', 'strike', 'code-snippet'].forEach(function (inside) {
257
+ if (token !== inside) {
258
+ Prism.languages.markdown[token].inside.content.inside[inside] = Prism.languages.markdown[inside];
259
+ }
260
+ });
261
+ });
262
+
263
+ Prism.hooks.add('after-tokenize', function (env) {
264
+ if (env.language !== 'markdown' && env.language !== 'md') {
265
+ return;
266
+ }
267
+
268
+ function walkTokens(tokens) {
269
+ if (!tokens || typeof tokens === 'string') {
270
+ return;
271
+ }
272
+
273
+ for (var i = 0, l = tokens.length; i < l; i++) {
274
+ var token = tokens[i];
275
+
276
+ if (token.type !== 'code') {
277
+ walkTokens(token.content);
278
+ continue;
279
+ }
280
+
281
+ /*
282
+ * Add the correct `language-xxxx` class to this code block. Keep in mind that the `code-language` token
283
+ * is optional. But the grammar is defined so that there is only one case we have to handle:
284
+ *
285
+ * token.content = [
286
+ * <span class="punctuation">```</span>,
287
+ * <span class="code-language">xxxx</span>,
288
+ * '\n', // exactly one new lines (\r or \n or \r\n)
289
+ * <span class="code-block">...</span>,
290
+ * '\n', // exactly one new lines again
291
+ * <span class="punctuation">```</span>
292
+ * ];
293
+ */
294
+
295
+ var codeLang = token.content[1];
296
+ var codeBlock = token.content[3];
297
+
298
+ if (codeLang && codeBlock &&
299
+ codeLang.type === 'code-language' && codeBlock.type === 'code-block' &&
300
+ typeof codeLang.content === 'string') {
301
+
302
+ // this might be a language that Prism does not support
303
+
304
+ // do some replacements to support C++, C#, and F#
305
+ var lang = codeLang.content.replace(/\b#/g, 'sharp').replace(/\b\+\+/g, 'pp');
306
+ // only use the first word
307
+ lang = (/[a-z][\w-]*/i.exec(lang) || [''])[0].toLowerCase();
308
+ var alias = 'language-' + lang;
309
+
310
+ // add alias
311
+ if (!codeBlock.alias) {
312
+ codeBlock.alias = [alias];
313
+ } else if (typeof codeBlock.alias === 'string') {
314
+ codeBlock.alias = [codeBlock.alias, alias];
315
+ } else {
316
+ codeBlock.alias.push(alias);
317
+ }
318
+ }
319
+ }
320
+ }
321
+
322
+ walkTokens(env.tokens);
323
+ });
324
+
325
+ Prism.hooks.add('wrap', function (env) {
326
+ if (env.type !== 'code-block') {
327
+ return;
328
+ }
329
+
330
+ var codeLang = '';
331
+ for (var i = 0, l = env.classes.length; i < l; i++) {
332
+ var cls = env.classes[i];
333
+ var match = /language-(.+)/.exec(cls);
334
+ if (match) {
335
+ codeLang = match[1];
336
+ break;
337
+ }
338
+ }
339
+
340
+ var grammar = Prism.languages[codeLang];
341
+
342
+ if (!grammar) {
343
+ if (codeLang && codeLang !== 'none' && Prism.plugins.autoloader) {
344
+ var id = 'md-' + new Date().valueOf() + '-' + Math.floor(Math.random() * 1e16);
345
+ env.attributes['id'] = id;
346
+
347
+ Prism.plugins.autoloader.loadLanguages(codeLang, function () {
348
+ var ele = document.getElementById(id);
349
+ if (ele) {
350
+ ele.innerHTML = Prism.highlight(ele.textContent, Prism.languages[codeLang], codeLang);
351
+ }
352
+ });
353
+ }
354
+ } else {
355
+ env.content = Prism.highlight(textContent(env.content), grammar, codeLang);
356
+ }
357
+ });
358
+
359
+ var tagPattern = RegExp(Prism.languages.markup.tag.pattern.source, 'gi');
360
+
361
+ /**
362
+ * A list of known entity names.
363
+ *
364
+ * This will always be incomplete to save space. The current list is the one used by lowdash's unescape function.
365
+ *
366
+ * @see {@link https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/unescape.js#L2}
367
+ */
368
+ var KNOWN_ENTITY_NAMES = {
369
+ 'amp': '&',
370
+ 'lt': '<',
371
+ 'gt': '>',
372
+ 'quot': '"',
373
+ };
374
+
375
+ // IE 11 doesn't support `String.fromCodePoint`
376
+ var fromCodePoint = String.fromCodePoint || String.fromCharCode;
377
+
378
+ /**
379
+ * Returns the text content of a given HTML source code string.
380
+ *
381
+ * @param {string} html
382
+ * @returns {string}
383
+ */
384
+ function textContent(html) {
385
+ // remove all tags
386
+ var text = html.replace(tagPattern, '');
387
+
388
+ // decode known entities
389
+ text = text.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi, function (m, code) {
390
+ code = code.toLowerCase();
391
+
392
+ if (code[0] === '#') {
393
+ var value;
394
+ if (code[1] === 'x') {
395
+ value = parseInt(code.slice(2), 16);
396
+ } else {
397
+ value = Number(code.slice(1));
398
+ }
399
+
400
+ return fromCodePoint(value);
401
+ } else {
402
+ var known = KNOWN_ENTITY_NAMES[code];
403
+ if (known) {
404
+ return known;
405
+ }
406
+
407
+ // unable to decode
408
+ return m;
409
+ }
410
+ });
411
+
412
+ return text;
413
+ }
414
+
415
+ Prism.languages.md = Prism.languages.markdown;
416
+
417
+ }(Prism));