mirror of
https://github.com/documize/community.git
synced 2025-08-04 21:15:24 +02:00
Update CodeMirror dep to v5.42.2
Affects Code and Markdown section types
This commit is contained in:
parent
c706edec47
commit
479a61a3ef
347 changed files with 21845 additions and 20770 deletions
141
gui/public/codemirror/mode/clike/clike.js
vendored
141
gui/public/codemirror/mode/clike/clike.js
vendored
|
@ -1,5 +1,5 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
|
@ -65,7 +65,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
numberStart = parserConfig.numberStart || /[\d\.]/,
|
||||
number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,
|
||||
isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,
|
||||
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/;
|
||||
isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/,
|
||||
// An optional function that takes a {string} token and returns true if it
|
||||
// should be treated as a builtin.
|
||||
isReservedIdentifier = parserConfig.isReservedIdentifier || false;
|
||||
|
||||
var curPunc, isDefKeyword;
|
||||
|
||||
|
@ -113,7 +116,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
return "keyword";
|
||||
}
|
||||
if (contains(types, cur)) return "type";
|
||||
if (contains(builtin, cur)) {
|
||||
if (contains(builtin, cur)
|
||||
|| (isReservedIdentifier && isReservedIdentifier(cur))) {
|
||||
if (contains(blockKeywords, cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
}
|
||||
|
@ -216,15 +220,15 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
if (parserConfig.dontIndentStatements)
|
||||
while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))
|
||||
ctx = ctx.prev
|
||||
if (hooks.indent) {
|
||||
var hook = hooks.indent(state, ctx, textAfter);
|
||||
var hook = hooks.indent(state, ctx, textAfter, indentUnit);
|
||||
if (typeof hook == "number") return hook
|
||||
}
|
||||
var closing = firstChar == ctx.type;
|
||||
var switchBlock = ctx.prev && ctx.prev.info == "switch";
|
||||
if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {
|
||||
while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev
|
||||
|
@ -263,8 +267,33 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
}
|
||||
}
|
||||
var cKeywords = "auto if break case register continue return default do sizeof " +
|
||||
"static else struct switch extern typedef union for goto while enum const volatile";
|
||||
var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t";
|
||||
"static else struct switch extern typedef union for goto while enum const " +
|
||||
"volatile inline restrict asm fortran";
|
||||
|
||||
// Do not use this. Use the cTypes function below. This is global just to avoid
|
||||
// excessive calls when cTypes is being called multiple times during a parse.
|
||||
var basicCTypes = words("int long char short double float unsigned signed " +
|
||||
"void bool");
|
||||
|
||||
// Do not use this. Use the objCTypes function below. This is global just to avoid
|
||||
// excessive calls when objCTypes is being called multiple times during a parse.
|
||||
var basicObjCTypes = words("SEL instancetype id Class Protocol BOOL");
|
||||
|
||||
// Returns true if identifier is a "C" type.
|
||||
// C type is defined as those that are reserved by the compiler (basicTypes),
|
||||
// and those that end in _t (Reserved by POSIX for types)
|
||||
// http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html
|
||||
function cTypes(identifier) {
|
||||
return contains(basicCTypes, identifier) || /.+_t/.test(identifier);
|
||||
}
|
||||
|
||||
// Returns true if identifier is a "Objective C" type.
|
||||
function objCTypes(identifier) {
|
||||
return cTypes(identifier) || contains(basicObjCTypes, identifier);
|
||||
}
|
||||
|
||||
var cBlockKeywords = "case do else for if switch while struct enum union";
|
||||
var cDefKeywords = "struct enum union";
|
||||
|
||||
function cppHook(stream, state) {
|
||||
if (!state.startOfLine) return false
|
||||
|
@ -286,6 +315,14 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// For C and C++ (and ObjC): identifiers starting with __
|
||||
// or _ followed by a capital letter are reserved for the compiler.
|
||||
function cIsReservedIdentifier(token) {
|
||||
if (!token || token.length < 2) return false;
|
||||
if (token[0] != '_') return false;
|
||||
return (token[1] == '_') || (token[1] !== token[1].toLowerCase());
|
||||
}
|
||||
|
||||
function cpp14Literal(stream) {
|
||||
stream.eatWhile(/[\w\.']/);
|
||||
return "number";
|
||||
|
@ -368,31 +405,36 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords),
|
||||
types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " +
|
||||
"int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " +
|
||||
"uint32_t uint64_t"),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
defKeywords: words("struct"),
|
||||
types: cTypes,
|
||||
blockKeywords: words(cBlockKeywords),
|
||||
defKeywords: words(cDefKeywords),
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("NULL true false"),
|
||||
hooks: {"#": cppHook, "*": pointerHook},
|
||||
isReservedIdentifier: cIsReservedIdentifier,
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"*": pointerHook,
|
||||
},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def(["text/x-c++src", "text/x-c++hdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " +
|
||||
"static_cast typeid catch operator template typename class friend private " +
|
||||
"this using const_cast inline public throw virtual delete mutable protected " +
|
||||
"alignas alignof constexpr decltype nullptr noexcept thread_local final " +
|
||||
"static_assert override"),
|
||||
types: words(cTypes + " bool wchar_t"),
|
||||
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
||||
defKeywords: words("class namespace struct enum union"),
|
||||
// Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.
|
||||
keywords: words(cKeywords + "alignas alignof and and_eq audit axiom bitand bitor catch " +
|
||||
"class compl concept constexpr const_cast decltype delete dynamic_cast " +
|
||||
"explicit export final friend import module mutable namespace new noexcept " +
|
||||
"not not_eq operator or or_eq override private protected public " +
|
||||
"reinterpret_cast requires static_assert static_cast template this " +
|
||||
"thread_local throw try typeid typename using virtual xor xor_eq"),
|
||||
types: cTypes,
|
||||
blockKeywords: words(cBlockKeywords + " class try catch"),
|
||||
defKeywords: words(cDefKeywords + " class namespace"),
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("true false NULL"),
|
||||
atoms: words("true false NULL nullptr"),
|
||||
dontIndentStatements: /^template$/,
|
||||
isIdentifierChar: /[\w\$_~\xa1-\uffff]/,
|
||||
isReservedIdentifier: cIsReservedIdentifier,
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"*": pointerHook,
|
||||
|
@ -513,7 +555,6 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
def("text/x-scala", {
|
||||
name: "clike",
|
||||
keywords: words(
|
||||
|
||||
/* scala */
|
||||
"abstract case catch class def do else extends final finally for forSome if " +
|
||||
"implicit import lazy match new null object override package private protected return " +
|
||||
|
@ -573,7 +614,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
return state.tokenize(stream, state)
|
||||
}
|
||||
},
|
||||
modeProps: {closeBrackets: {triples: '"'}}
|
||||
modeProps: {closeBrackets: {pairs: '()[]{}""', triples: '"'}}
|
||||
});
|
||||
|
||||
function tokenKotlinString(tripleString){
|
||||
|
@ -628,9 +669,23 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
},
|
||||
'*': function(_stream, state) {
|
||||
return state.prevToken == '.' ? 'variable' : 'operator';
|
||||
},
|
||||
'"': function(stream, state) {
|
||||
state.tokenize = tokenKotlinString(stream.match('""'));
|
||||
return state.tokenize(stream, state);
|
||||
},
|
||||
indent: function(state, ctx, textAfter, indentUnit) {
|
||||
var firstChar = textAfter && textAfter.charAt(0);
|
||||
if ((state.prevToken == "}" || state.prevToken == ")") && textAfter == "")
|
||||
return state.indented;
|
||||
if (state.prevToken == "operator" && textAfter != "}" ||
|
||||
state.prevToken == "variable" && firstChar == "." ||
|
||||
(state.prevToken == "}" || state.prevToken == ")") && firstChar == ".")
|
||||
return indentUnit * 2 + ctx.indented;
|
||||
if (ctx.align && ctx.type == "}")
|
||||
return ctx.indented + (state.context.type == (textAfter || "").charAt(0) ? 0 : indentUnit);
|
||||
}
|
||||
},
|
||||
modeProps: {closeBrackets: {triples: '"'}}
|
||||
|
@ -697,11 +752,11 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
|
||||
def("text/x-nesc", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
|
||||
keywords: words(cKeywords + " as atomic async call command component components configuration event generic " +
|
||||
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
||||
"signal task uses abstract extends"),
|
||||
types: words(cTypes),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
types: cTypes,
|
||||
blockKeywords: words(cBlockKeywords),
|
||||
atoms: words("null true false"),
|
||||
hooks: {"#": cppHook},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
|
@ -709,28 +764,34 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|||
|
||||
def("text/x-objectivec", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginary BOOL Class bycopy byref id IMP in " +
|
||||
"inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),
|
||||
types: words(cTypes),
|
||||
atoms: words("YES NO NULL NILL ON OFF true false"),
|
||||
keywords: words(cKeywords + " bycopy byref in inout oneway out self super atomic nonatomic retain copy " +
|
||||
"readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +
|
||||
"@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +
|
||||
"@public @package @private @protected @required @optional @try @catch @finally @import " +
|
||||
"@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available"),
|
||||
types: objCTypes,
|
||||
builtin: words("FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION NS_RETURNS_RETAINED " +
|
||||
"NS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER NS_DESIGNATED_INITIALIZER " +
|
||||
"NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION NS_ASSUME_NONNULL_BEGIN " +
|
||||
"NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"),
|
||||
blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized"),
|
||||
defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class"),
|
||||
dontIndentStatements: /^@.*$/,
|
||||
typeFirstDefinitions: true,
|
||||
atoms: words("YES NO NULL Nil nil true false nullptr"),
|
||||
isReservedIdentifier: cIsReservedIdentifier,
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$]/);
|
||||
return "keyword";
|
||||
},
|
||||
"#": cppHook,
|
||||
indent: function(_state, ctx, textAfter) {
|
||||
if (ctx.type == "statement" && /^@\w/.test(textAfter)) return ctx.indented
|
||||
}
|
||||
"*": pointerHook,
|
||||
},
|
||||
modeProps: {fold: "brace"}
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def("text/x-squirrel", {
|
||||
name: "clike",
|
||||
keywords: words("base break clone continue const default delete enum extends function in class" +
|
||||
" foreach local resume return this throw typeof yield constructor instanceof static"),
|
||||
types: words(cTypes),
|
||||
types: cTypes,
|
||||
blockKeywords: words("case catch class else for foreach if switch try while"),
|
||||
defKeywords: words("function local class"),
|
||||
typeFirstDefinitions: true,
|
||||
|
|
36
gui/public/codemirror/mode/clike/index.html
vendored
36
gui/public/codemirror/mode/clike/index.html
vendored
|
@ -12,7 +12,7 @@
|
|||
<script src="clike.js"></script>
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
@ -147,16 +147,36 @@ This is a longer comment
|
|||
That spans two lines
|
||||
*/
|
||||
|
||||
#import <Test/Test.h>
|
||||
#import "MyClass.h"
|
||||
#import <AFramework/AFrameork.h>
|
||||
@import BFrameworkModule;
|
||||
|
||||
NS_ENUM(SomeValues) {
|
||||
aValue = 1;
|
||||
};
|
||||
|
||||
// A Class Extension with some properties
|
||||
@interface MyClass ()<AProtocol>
|
||||
@property(atomic, readwrite, assign) NSInteger anInt;
|
||||
@property(nonatomic, strong, nullable) NSString *aString;
|
||||
@end
|
||||
|
||||
@implementation YourAppDelegate
|
||||
|
||||
// This is a one-line comment
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
||||
char myString[] = "This is a C character array";
|
||||
int test = 5;
|
||||
return YES;
|
||||
- (instancetype)initWithString:(NSString *)aStringVar {
|
||||
if ((self = [super init])) {
|
||||
aString = aStringVar;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)doSomething:(float)progress {
|
||||
NSString *myString = @"This is a ObjC string %f ";
|
||||
myString = [[NSString stringWithFormat:myString, progress] stringByAppendingString:self.aString];
|
||||
return myString.length > 100 ? NO : YES;
|
||||
}
|
||||
|
||||
@end
|
||||
</textarea></div>
|
||||
|
||||
<h2>Java example</h2>
|
||||
|
|
2
gui/public/codemirror/mode/clike/scala.html
vendored
2
gui/public/codemirror/mode/clike/scala.html
vendored
|
@ -10,7 +10,7 @@
|
|||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="clike.js"></script>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
|
|
72
gui/public/codemirror/mode/clike/test.js
vendored
72
gui/public/codemirror/mode/clike/test.js
vendored
|
@ -1,5 +1,5 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
|
||||
|
@ -23,6 +23,8 @@
|
|||
MT("def",
|
||||
"[type void] [def foo]() {}",
|
||||
"[keyword struct] [def bar]{}",
|
||||
"[keyword enum] [def zot]{}",
|
||||
"[keyword union] [def ugh]{}",
|
||||
"[type int] [type *][def baz]() {}");
|
||||
|
||||
MT("def_new_line",
|
||||
|
@ -43,6 +45,26 @@
|
|||
"[type unsigned] [type int] [variable bar] [operator =] [number 8];",
|
||||
"[meta #include <baz> ][comment // comment]")
|
||||
|
||||
MT("c_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
MT("c_types",
|
||||
"[type int];",
|
||||
"[type long];",
|
||||
"[type char];",
|
||||
"[type short];",
|
||||
"[type double];",
|
||||
"[type float];",
|
||||
"[type unsigned];",
|
||||
"[type signed];",
|
||||
"[type void];",
|
||||
"[type bool];",
|
||||
"[type foo_t];",
|
||||
"[variable foo_T];",
|
||||
"[variable _t];");
|
||||
|
||||
var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
|
||||
function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
@ -57,6 +79,54 @@
|
|||
"[def Foo::Foo]() {}",
|
||||
"[def Foo::~Foo]() {}");
|
||||
|
||||
MTCPP("cpp_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
var mode_objc = CodeMirror.getMode({indentUnit: 2}, "text/x-objectivec");
|
||||
function MTOBJC(name) { test.mode(name, mode_objc, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MTOBJC("objc_underscores",
|
||||
"[builtin __FOO];",
|
||||
"[builtin _Complex];",
|
||||
"[builtin __aName];",
|
||||
"[variable _aName];");
|
||||
|
||||
MTOBJC("objc_interface",
|
||||
"[keyword @interface] [def foo] {",
|
||||
" [type int] [variable bar];",
|
||||
"}",
|
||||
"[keyword @property] ([keyword atomic], [keyword nullable]) [variable NSString][operator *] [variable a];",
|
||||
"[keyword @property] ([keyword nonatomic], [keyword assign]) [type int] [variable b];",
|
||||
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] " +
|
||||
"[builtin NS_DESIGNATED_INITIALIZER];",
|
||||
"[keyword @end]");
|
||||
|
||||
MTOBJC("objc_implementation",
|
||||
"[keyword @implementation] [def foo] {",
|
||||
" [type int] [variable bar];",
|
||||
"}",
|
||||
"[keyword @property] ([keyword readwrite]) [type SEL] [variable a];",
|
||||
"[operator -]([type instancetype])[variable initWithFoo]:([type int])[variable a] {",
|
||||
" [keyword if](([keyword self] [operator =] [[[keyword super] [variable init] ]])) {}",
|
||||
" [keyword return] [keyword self];",
|
||||
"}",
|
||||
"[keyword @end]");
|
||||
|
||||
MTOBJC("objc_types",
|
||||
"[type int];",
|
||||
"[type foo_t];",
|
||||
"[variable foo_T];",
|
||||
"[type id];",
|
||||
"[type SEL];",
|
||||
"[type instancetype];",
|
||||
"[type Class];",
|
||||
"[type Protocol];",
|
||||
"[type BOOL];"
|
||||
);
|
||||
|
||||
var mode_scala = CodeMirror.getMode({indentUnit: 2}, "text/x-scala");
|
||||
function MTSCALA(name) { test.mode("scala_" + name, mode_scala, Array.prototype.slice.call(arguments, 1)); }
|
||||
MTSCALA("nested_comments",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue