This commit is contained in:
2025-01-04 00:34:03 +01:00
parent 41829408dc
commit 0ca14bbc19
18111 changed files with 1871397 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
{
"libs": ["browser"],
"plugins": {
"node": {},
"complete_strings": {},
"es_modules": {}
}
}

View File

@@ -0,0 +1,104 @@
# How to contribute
- [Getting help](#getting-help)
- [Submitting bug reports](#submitting-bug-reports)
- [Contributing code](#contributing-code)
## Getting help
Community discussion, questions, and informal bug reporting is done on the
[discuss.ProseMirror forum](http://discuss.prosemirror.net).
## Submitting bug reports
Report bugs on the
[GitHub issue tracker](http://github.com/prosemirror/prosemirror/issues).
Before reporting a bug, please read these pointers.
- The issue tracker is for *bugs*, not requests for help. Questions
should be asked on the [forum](http://discuss.prosemirror.net).
- Include information about the version of the code that exhibits the
problem. For browser-related issues, include the browser and browser
version on which the problem occurred.
- Mention very precisely what went wrong. "X is broken" is not a good
bug report. What did you expect to happen? What happened instead?
Describe the exact steps a maintainer has to take to make the
problem occur. A screencast can be useful, but is no substitute for
a textual description.
- A great way to make it easy to reproduce your problem, if it can not
be trivially reproduced on the website demos, is to submit a script
that triggers the issue.
## Contributing code
If you want to make a change that involves a significant overhaul of
the code or introduces a user-visible new feature, create an
[RFC](https://github.com/ProseMirror/rfcs/) first with your proposal.
- Make sure you have a [GitHub Account](https://github.com/signup/free)
- Fork the relevant repository
([how to fork a repo](https://help.github.com/articles/fork-a-repo))
- Create a local checkout of the code. You can use the
[main repository](https://github.com/prosemirror/prosemirror) to
easily check out all core modules.
- Make your changes, and commit them
- Follow the code style of the rest of the project (see below). Run
`npm run lint` (in the main repository checkout) to make sure that
the linter is happy.
- If your changes are easy to test or likely to regress, add tests in
the relevant `test/` directory. Either put them in an existing
`test-*.js` file, if they fit there, or add a new file.
- Make sure all tests pass. Run `npm run test` to verify tests pass
(you will need Node.js v6+).
- Submit a pull request ([how to create a pull request](https://help.github.com/articles/fork-a-repo)).
Don't put more than one feature/fix in a single pull request.
By contributing code to ProseMirror you
- Agree to license the contributed code under the project's [MIT
license](https://github.com/ProseMirror/prosemirror/blob/master/LICENSE).
- Confirm that you have the right to contribute and license the code
in question. (Either you hold all rights on the code, or the rights
holder has explicitly granted the right to use it like this,
through a compatible open source license or through a direct
agreement with you.)
### Coding standards
- ES6 syntax, targeting an ES5 runtime (i.e. don't use library
elements added by ES6, don't use ES7/ES.next syntax).
- 2 spaces per indentation level, no tabs.
- No semicolons except when necessary.
- Follow the surrounding code when it comes to spacing, brace
placement, etc.
- Brace-less single-statement bodies are encouraged (whenever they
don't impact readability).
- [getdocs](https://github.com/marijnh/getdocs)-style doc comments
above items that are part of the public API.
- When documenting non-public items, you can put the type after a
single colon, so that getdocs doesn't pick it up and add it to the
API reference.
- The linter (`npm run lint`) complains about unused variables and
functions. Prefix their names with an underscore to muffle it.
- ProseMirror does *not* follow JSHint or JSLint prescribed style.
Patches that try to 'fix' code to pass one of these linters will not
be accepted.

19
resources/app/node_modules/prosemirror-keymap/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (C) 2015-2017 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,85 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var w3cKeyname = require('w3c-keyname');
var prosemirrorState = require('prosemirror-state');
var mac = typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : false;
function normalizeKeyName(name) {
var parts = name.split(/-(?!$)/),
result = parts[parts.length - 1];
if (result == "Space") result = " ";
var alt, ctrl, shift, meta;
for (var i = 0; i < parts.length - 1; i++) {
var mod = parts[i];
if (/^(cmd|meta|m)$/i.test(mod)) meta = true;else if (/^a(lt)?$/i.test(mod)) alt = true;else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;else if (/^s(hift)?$/i.test(mod)) shift = true;else if (/^mod$/i.test(mod)) {
if (mac) meta = true;else ctrl = true;
} else throw new Error("Unrecognized modifier name: " + mod);
}
if (alt) result = "Alt-" + result;
if (ctrl) result = "Ctrl-" + result;
if (meta) result = "Meta-" + result;
if (shift) result = "Shift-" + result;
return result;
}
function normalize(map) {
var copy = Object.create(null);
for (var prop in map) {
copy[normalizeKeyName(prop)] = map[prop];
}
return copy;
}
function modifiers(name, event) {
var shift = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
if (event.altKey) name = "Alt-" + name;
if (event.ctrlKey) name = "Ctrl-" + name;
if (event.metaKey) name = "Meta-" + name;
if (shift && event.shiftKey) name = "Shift-" + name;
return name;
}
function keymap(bindings) {
return new prosemirrorState.Plugin({
props: {
handleKeyDown: keydownHandler(bindings)
}
});
}
function keydownHandler(bindings) {
var map = normalize(bindings);
return function (view, event) {
var name = w3cKeyname.keyName(event),
baseName,
direct = map[modifiers(name, event)];
if (direct && direct(view.state, view.dispatch, view)) return true;
if (name.length == 1 && name != " ") {
if (event.shiftKey) {
var noShift = map[modifiers(name, event, false)];
if (noShift && noShift(view.state, view.dispatch, view)) return true;
}
if ((event.shiftKey || event.altKey || event.metaKey || name.charCodeAt(0) > 127) && (baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {
var fromCode = map[modifiers(baseName, event)];
if (fromCode && fromCode(view.state, view.dispatch, view)) return true;
}
}
return false;
};
}
exports.keydownHandler = keydownHandler;
exports.keymap = keymap;

View File

@@ -0,0 +1,47 @@
import { Command, Plugin } from 'prosemirror-state';
import { EditorView } from 'prosemirror-view';
/**
Create a keymap plugin for the given set of bindings.
Bindings should map key names to [command](https://prosemirror.net/docs/ref/#commands)-style
functions, which will be called with `(EditorState, dispatch,
EditorView)` arguments, and should return true when they've handled
the key. Note that the view argument isn't part of the command
protocol, but can be used as an escape hatch if a binding needs to
directly interact with the UI.
Key names may be strings like `"Shift-Ctrl-Enter"`—a key
identifier prefixed with zero or more modifiers. Key identifiers
are based on the strings that can appear in
[`KeyEvent.key`](https:developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
Use lowercase letters to refer to letter keys (or uppercase letters
if you want shift to be held). You may use `"Space"` as an alias
for the `" "` name.
Modifiers can be given in any order. `Shift-` (or `s-`), `Alt-` (or
`a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or
`Meta-`) are recognized. For characters that are created by holding
shift, the `Shift-` prefix is implied, and should not be added
explicitly.
You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Ctrl-` on
other platforms.
You can add multiple keymap plugins to an editor. The order in
which they appear determines their precedence (the ones early in
the array get to dispatch first).
*/
declare function keymap(bindings: {
[key: string]: Command;
}): Plugin;
/**
Given a set of bindings (using the same format as
[`keymap`](https://prosemirror.net/docs/ref/#keymap.keymap)), return a [keydown
handler](https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown) that handles them.
*/
declare function keydownHandler(bindings: {
[key: string]: Command;
}): (view: EditorView, event: KeyboardEvent) => boolean;
export { keydownHandler, keymap };

View File

@@ -0,0 +1,125 @@
import { keyName, base } from 'w3c-keyname';
import { Plugin } from 'prosemirror-state';
const mac = typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : false;
function normalizeKeyName(name) {
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
if (result == "Space")
result = " ";
let alt, ctrl, shift, meta;
for (let i = 0; i < parts.length - 1; i++) {
let mod = parts[i];
if (/^(cmd|meta|m)$/i.test(mod))
meta = true;
else if (/^a(lt)?$/i.test(mod))
alt = true;
else if (/^(c|ctrl|control)$/i.test(mod))
ctrl = true;
else if (/^s(hift)?$/i.test(mod))
shift = true;
else if (/^mod$/i.test(mod)) {
if (mac)
meta = true;
else
ctrl = true;
}
else
throw new Error("Unrecognized modifier name: " + mod);
}
if (alt)
result = "Alt-" + result;
if (ctrl)
result = "Ctrl-" + result;
if (meta)
result = "Meta-" + result;
if (shift)
result = "Shift-" + result;
return result;
}
function normalize(map) {
let copy = Object.create(null);
for (let prop in map)
copy[normalizeKeyName(prop)] = map[prop];
return copy;
}
function modifiers(name, event, shift = true) {
if (event.altKey)
name = "Alt-" + name;
if (event.ctrlKey)
name = "Ctrl-" + name;
if (event.metaKey)
name = "Meta-" + name;
if (shift && event.shiftKey)
name = "Shift-" + name;
return name;
}
/**
Create a keymap plugin for the given set of bindings.
Bindings should map key names to [command](https://prosemirror.net/docs/ref/#commands)-style
functions, which will be called with `(EditorState, dispatch,
EditorView)` arguments, and should return true when they've handled
the key. Note that the view argument isn't part of the command
protocol, but can be used as an escape hatch if a binding needs to
directly interact with the UI.
Key names may be strings like `"Shift-Ctrl-Enter"`—a key
identifier prefixed with zero or more modifiers. Key identifiers
are based on the strings that can appear in
[`KeyEvent.key`](https:developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
Use lowercase letters to refer to letter keys (or uppercase letters
if you want shift to be held). You may use `"Space"` as an alias
for the `" "` name.
Modifiers can be given in any order. `Shift-` (or `s-`), `Alt-` (or
`a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or
`Meta-`) are recognized. For characters that are created by holding
shift, the `Shift-` prefix is implied, and should not be added
explicitly.
You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Ctrl-` on
other platforms.
You can add multiple keymap plugins to an editor. The order in
which they appear determines their precedence (the ones early in
the array get to dispatch first).
*/
function keymap(bindings) {
return new Plugin({ props: { handleKeyDown: keydownHandler(bindings) } });
}
/**
Given a set of bindings (using the same format as
[`keymap`](https://prosemirror.net/docs/ref/#keymap.keymap)), return a [keydown
handler](https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown) that handles them.
*/
function keydownHandler(bindings) {
let map = normalize(bindings);
return function (view, event) {
let name = keyName(event), baseName, direct = map[modifiers(name, event)];
if (direct && direct(view.state, view.dispatch, view))
return true;
// A character key
if (name.length == 1 && name != " ") {
if (event.shiftKey) {
// In case the name was already modified by shift, try looking
// it up without its shift modifier
let noShift = map[modifiers(name, event, false)];
if (noShift && noShift(view.state, view.dispatch, view))
return true;
}
if ((event.shiftKey || event.altKey || event.metaKey || name.charCodeAt(0) > 127) &&
(baseName = base[event.keyCode]) && baseName != name) {
// Try falling back to the keyCode when there's a modifier
// active or the character produced isn't ASCII, and our table
// produces a different name from the the keyCode. See #668,
// #1060
let fromCode = map[modifiers(baseName, event)];
if (fromCode && fromCode(view.state, view.dispatch, view))
return true;
}
}
return false;
};
}
export { keydownHandler, keymap };

View File

@@ -0,0 +1,34 @@
{
"name": "prosemirror-keymap",
"version": "1.2.2",
"description": "Keymap plugin for ProseMirror",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"sideEffects": false,
"license": "MIT",
"maintainers": [
{
"name": "Marijn Haverbeke",
"email": "marijn@haverbeke.berlin",
"web": "http://marijnhaverbeke.nl"
}
],
"repository": {
"type": "git",
"url": "git://github.com/prosemirror/prosemirror-keymap.git"
},
"dependencies": {
"w3c-keyname": "^2.2.0",
"prosemirror-state": "^1.0.0"
},
"devDependencies": {
"@prosemirror/buildhelper": "^0.1.5",
"prosemirror-test-builder": "^1.0.0"
}
}

View File

@@ -0,0 +1,5 @@
A plugin for conveniently defining key bindings.
@keymap
@keydownHandler

View File

@@ -0,0 +1,102 @@
import {base, keyName} from "w3c-keyname"
import {Plugin, Command} from "prosemirror-state"
import {EditorView} from "prosemirror-view"
const mac = typeof navigator != "undefined" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : false
function normalizeKeyName(name: string) {
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1]
if (result == "Space") result = " "
let alt, ctrl, shift, meta
for (let i = 0; i < parts.length - 1; i++) {
let mod = parts[i]
if (/^(cmd|meta|m)$/i.test(mod)) meta = true
else if (/^a(lt)?$/i.test(mod)) alt = true
else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true
else if (/^s(hift)?$/i.test(mod)) shift = true
else if (/^mod$/i.test(mod)) { if (mac) meta = true; else ctrl = true }
else throw new Error("Unrecognized modifier name: " + mod)
}
if (alt) result = "Alt-" + result
if (ctrl) result = "Ctrl-" + result
if (meta) result = "Meta-" + result
if (shift) result = "Shift-" + result
return result
}
function normalize(map: {[key: string]: Command}) {
let copy: {[key: string]: Command} = Object.create(null)
for (let prop in map) copy[normalizeKeyName(prop)] = map[prop]
return copy
}
function modifiers(name: string, event: KeyboardEvent, shift = true) {
if (event.altKey) name = "Alt-" + name
if (event.ctrlKey) name = "Ctrl-" + name
if (event.metaKey) name = "Meta-" + name
if (shift && event.shiftKey) name = "Shift-" + name
return name
}
/// Create a keymap plugin for the given set of bindings.
///
/// Bindings should map key names to [command](#commands)-style
/// functions, which will be called with `(EditorState, dispatch,
/// EditorView)` arguments, and should return true when they've handled
/// the key. Note that the view argument isn't part of the command
/// protocol, but can be used as an escape hatch if a binding needs to
/// directly interact with the UI.
///
/// Key names may be strings like `"Shift-Ctrl-Enter"`—a key
/// identifier prefixed with zero or more modifiers. Key identifiers
/// are based on the strings that can appear in
/// [`KeyEvent.key`](https:///developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
/// Use lowercase letters to refer to letter keys (or uppercase letters
/// if you want shift to be held). You may use `"Space"` as an alias
/// for the `" "` name.
///
/// Modifiers can be given in any order. `Shift-` (or `s-`), `Alt-` (or
/// `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or
/// `Meta-`) are recognized. For characters that are created by holding
/// shift, the `Shift-` prefix is implied, and should not be added
/// explicitly.
///
/// You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Ctrl-` on
/// other platforms.
///
/// You can add multiple keymap plugins to an editor. The order in
/// which they appear determines their precedence (the ones early in
/// the array get to dispatch first).
export function keymap(bindings: {[key: string]: Command}): Plugin {
return new Plugin({props: {handleKeyDown: keydownHandler(bindings)}})
}
/// Given a set of bindings (using the same format as
/// [`keymap`](#keymap.keymap)), return a [keydown
/// handler](#view.EditorProps.handleKeyDown) that handles them.
export function keydownHandler(bindings: {[key: string]: Command}): (view: EditorView, event: KeyboardEvent) => boolean {
let map = normalize(bindings)
return function(view, event) {
let name = keyName(event), baseName, direct = map[modifiers(name, event)]
if (direct && direct(view.state, view.dispatch, view)) return true
// A character key
if (name.length == 1 && name != " ") {
if (event.shiftKey) {
// In case the name was already modified by shift, try looking
// it up without its shift modifier
let noShift = map[modifiers(name, event, false)]
if (noShift && noShift(view.state, view.dispatch, view)) return true
}
if ((event.shiftKey || event.altKey || event.metaKey || name.charCodeAt(0) > 127) &&
(baseName = base[event.keyCode]) && baseName != name) {
// Try falling back to the keyCode when there's a modifier
// active or the character produced isn't ASCII, and our table
// produces a different name from the the keyCode. See #668,
// #1060
let fromCode = map[modifiers(baseName, event)]
if (fromCode && fromCode(view.state, view.dispatch, view)) return true
}
}
return false
}
}