node-prosemirror-model-1.16.1+~cs1.1.5/ 0000775 0000000 0000000 00000000000 14207620105 0017363 5 ustar 00root root 0000000 0000000 node-prosemirror-model-1.16.1+~cs1.1.5/.gitignore 0000664 0000000 0000000 00000000037 14207620105 0021353 0 ustar 00root root 0000000 0000000 /node_modules
.tern-port
/dist
node-prosemirror-model-1.16.1+~cs1.1.5/.npmignore 0000664 0000000 0000000 00000000037 14207620105 0021362 0 ustar 00root root 0000000 0000000 /node_modules
.tern-port
/test
node-prosemirror-model-1.16.1+~cs1.1.5/.npmrc 0000664 0000000 0000000 00000000023 14207620105 0020476 0 ustar 00root root 0000000 0000000 package-lock=false
node-prosemirror-model-1.16.1+~cs1.1.5/.tern-project 0000664 0000000 0000000 00000000157 14207620105 0022003 0 ustar 00root root 0000000 0000000 {
"libs": ["browser"],
"plugins": {
"node": {},
"complete_strings": {},
"es_modules": {}
}
}
node-prosemirror-model-1.16.1+~cs1.1.5/CHANGELOG.md 0000664 0000000 0000000 00000056741 14207620105 0021211 0 ustar 00root root 0000000 0000000 ## 1.16.1 (2021-12-29)
### Bug fixes
Fix a bug in the way whitespace-preservation options were handled in `DOMParser`.
## 1.16.0 (2021-12-27)
### New features
A new `NodeSpec` property, `whitespace`, allows more control over the way whitespace in the content of the node is parsed.
## 1.15.0 (2021-10-25)
### New features
`textBetween` now allows its leaf text argument to be a function.
## 1.14.3 (2021-07-22)
### Bug fixes
`DOMSerializer.serializeNode` will no longer ignore the node's marks.
## 1.14.2 (2021-06-16)
### Bug fixes
Be less agressive about dropping whitespace when the context isn't know in `DOMParser.parseSlice`.
## 1.14.1 (2021-04-26)
### Bug fixes
DOM parsing with `preserveWhitespace: "full"` will no longer ignore whitespace-only nodes.
## 1.14.0 (2021-04-06)
### Bug fixes
`Node.check` will now error if a node has an invalid combination of marks.
Don't leave carriage return characters in parsed DOM content, since they confuse Chrome's cursor motion.
### New features
`Fragment.textBetween` is now public.
## 1.13.3 (2021-02-04)
### Bug fixes
Fix an issue where nested tags that match mark parser rules could cause the parser to apply marks in invalid places.
## 1.13.2 (2021-02-04)
### Bug fixes
`MarkType.removeFromSet` now removes all instances of the mark, not just the first one.
## 1.13.1 (2020-12-20)
### Bug fixes
Fix a bug where nested marks of the same type would be applied to the wrong node when parsing from DOM.
## 1.13.0 (2020-12-11)
### New features
Parse rules can now have a `consuming: false` property which allows other rules to match their tag or style even when they apply.
## 1.12.0 (2020-10-11)
### New features
The output of `toDOM` functions can now be a `{dom, contentDOM}` object specifying the precise parent and content DOM elements.
## 1.11.2 (2020-09-12)
### Bug fixes
Fix issue where 1.11.1 uses an array method not available on Internet Explorer.
## 1.11.1 (2020-09-11)
### Bug fixes
Fix an issue where an inner node's mark information could reset the same mark provided by an outer node in the DOM parser.
## 1.11.0 (2020-07-08)
### New features
Resolved positions have a new convenience method, `posAtIndex`, which can resolve a depth and index to a position.
## 1.10.1 (2020-07-08)
### Bug fixes
Fix a bug that prevented non-canonical list structure from being normalized.
## 1.10.0 (2020-05-25)
### Bug fixes
Avoid fixing directly nested list nodes during DOM parsing when it looks like the schema allows those.
### New features
DOM parser rules can now specify `closeParent: true` to have the effect of closing their parent node when matched.
## 1.9.1 (2020-01-17)
### Bug fixes
Marks found in the DOM at the wrong level (for example, a bold style on a block node) are now properly moved to the node content.
## 1.9.0 (2020-01-07)
### New features
The `NodeType` method [`hasRequiredAttrs`](https://prosemirror.net/docs/ref/#model.NodeType.hasRequiredAttrs) is now public.
Element and attribute names in [`DOMOutputSpec`](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) structures can now contain namespaces.
## 1.8.2 (2019-11-20)
### Bug fixes
Rename ES module files to use a .js extension, since Webpack gets confused by .mjs
## 1.8.1 (2019-11-19)
### Bug fixes
The file referred to in the package's `module` field now is compiled down to ES5.
## 1.8.0 (2019-11-08)
### New features
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
Add a `module` field to package json file.
## 1.7.5 (2019-11-07)
### Bug fixes
`ContentMatch.edge` now throws, as it is supposed to, when you try to access the edge past the last one.
## 1.7.4 (2019-10-10)
### Bug fixes
Fix an issue where `fillBefore` would in some cases insert unneccesary optional child nodes in the generated content.
## 1.7.3 (2019-10-03)
### Bug fixes
Fix an issue where _any_ whitespace (not just the characters that HTML collapses) was collapsed by the parser in non-whitespace-preserving mode.
## 1.7.2 (2019-09-04)
### Bug fixes
When ` ` DOM nodes can't be parsed normally, the parser now converts them to newlines. This should improve parsing of some forms of source code HTML.
## 1.7.1 (2019-05-31)
### Bug fixes
Using `Fragment.from` on an invalid value, including a `Fragment` instance from a different version/instance of the library, now raises a meaningful error rather than getting confused.
Fix a bug in parsing overlapping marks of the same non-self-exclusive type.
## 1.7.0 (2019-01-29)
### New features
Mark specs now support a property [`spanning`](https://prosemirror.net/docs/ref/#model.MarkSpec.spanning) which, when set to `false`, prevents the mark's DOM markup from spanning multiple nodes, so that a separate wrapper is created for each adjacent marked node.
## 1.6.4 (2019-01-05)
### Bug fixes
Don't output empty style attributes when a style property with a null value is present in `renderSpec`.
## 1.6.3 (2018-10-26)
### Bug fixes
The DOM parser now drops whitespace after BR nodes when not in whitespace-preserving mode.
## 1.6.2 (2018-10-01)
### Bug fixes
Prevent [`ContentMatch.findWrapping`](https://prosemirror.net/docs/ref/#model.ContentMatch.findWrapping) from returning node types with required attributes.
## 1.6.1 (2018-07-24)
### Bug fixes
Fix a bug where marks were sometimes parsed incorrectly.
## 1.6.0 (2018-07-20)
### Bug fixes
Fix issue where marks would be applied to the wrong node when parsing a slice from DOM.
### New features
Adds a new node spec property, [`toDebugString`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDebugString), making it possible to customize your nodes' `toString` behavior.
## 1.5.0 (2018-05-31)
### New features
[`ParseRule.getContent`](https://prosemirror.net/docs/ref/#model.ParseRule.getContent) is now passed the parser schema as second argument.
## 1.4.4 (2018-05-03)
### Bug fixes
Fix a regression where `DOMParser.parse` would fail to apply mark nodes directly at the start of the input.
## 1.4.3 (2018-04-27)
### Bug fixes
[`DOMParser.parseSlice`](https://prosemirror.net/docs/ref/#model.DOMParser.parseSlice) can now correctly parses marks at the top level again.
## 1.4.2 (2018-04-15)
### Bug fixes
Remove a `console.log` that was accidentally left in the previous release.
## 1.4.1 (2018-04-13)
### Bug fixes
`DOMParser` can now parse marks on block nodes.
## 1.4.0 (2018-03-22)
### New features
[`ContentMatch.defaultType`](https://prosemirror.net/docs/ref/#model.ContentMatch.defaultType), a way to get a matching node type at a content match position, is now public.
## 1.3.0 (2018-03-22)
### New features
`ContentMatch` objects now have an [`edgeCount`](https://prosemirror.net/docs/ref/#model.ContentMatch.edgeCount) property and an [`edge`](https://prosemirror.net/docs/ref/#model.ContentMatch.edge) method, providing direct access to the finite automaton structure.
## 1.2.2 (2018-03-15)
### Bug fixes
Throw errors, rather than constructing invalid objects, when deserializing from invalid JSON data.
## 1.2.1 (2018-03-15)
### Bug fixes
Content expressions with text nodes in required positions now raise the appropriate error about being unable to generate such nodes.
## 1.2.0 (2018-03-14)
### Bug fixes
[`rangeHasMark`](https://prosemirror.net/docs/ref/#model.Node.rangeHasMark) now always returns false for empty ranges.
The DOM renderer no longer needlessly splits mark nodes when starting a non-rendered mark.
### New features
[`DOMSerializer`](https://prosemirror.net/docs/ref/#model.DOMSerializer) now allows [DOM specs](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) for marks to have holes in them, to specify the precise position where their content should be rendered.
The base position parameter to [`Node.nodesBetween`](https://prosemirror.net/docs/ref/#model.Node.nodesBetween) and [`Fragment.nodesBetween`](https://prosemirror.net/docs/ref/#model.Fragment.nodesBetween) is now part of the public interface.
## 1.1.0 (2018-01-05)
### New features
[`Slice.maxOpen`](https://prosemirror.net/docs/ref/#model.Slice^maxOpen) now has a second argument that can be used to prevent it from opening isolating nodes.
## 1.0.1 (2017-11-10)
### Bug fixes
[`ReplaceError`](https://prosemirror.net/docs/ref/#model.ReplaceError) instances now properly inherit from `Error`.
## 1.0.0 (2017-10-13)
### New features
[`ParseRule.context`](https://prosemirror.net/docs/ref/#model.ParseRule.context) may now include multiple, pipe-separated context expressions.
## 0.23.1 (2017-09-21)
### Bug fixes
`NodeType.allowsMarks` and `allowedMarks` now actually work for nodes that allow only specific marks.
## 0.23.0 (2017-09-13)
### Breaking changes
[`ResolvedPos.marks`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.ResolvedPos.marks) no longer takes a parameter (you probably want [`marksAcross`](https://prosemirror.net/doc/ref/version/0.23.0.html#model.ResolvedPos.marksAcross) if you were passing true there).
Attribute and mark constraints in [content expressions](https://prosemirror.net/docs/ref/version/0.23.0.html#model.NodeSpec.content) are no longer supported (this also means the `prosemirror-schema-table` package, which relied on them, is no longer supported). In this release, mark constraints are still (approximately) recognized with a warning, when present.
[`ContentMatch`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.ContentMatch) objects lost a number of methods: `matchNode`, `matchToEnd`, `findWrappingFor` (which can be easily emulated using the remaining API), and `allowsMark`, which is now the responsibility of [node types](https://prosemirror.net/docs/ref/version/0.23.0.html#model.NodeType.allowsMarkType) instead.
[`ContentMatch.validEnd`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.ContentMatch.validEnd) is now a property rather than a method.
[`ContentMatch.findWrapping`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.ContentMatch.findWrapping) now returns an array of plain node types, with no attribute information (since this is no longer necessary).
The `compute` method for attributes is no longer supported.
Fragments no longer have an `offsetAt` method.
`DOMParser.schemaRules` is no longer public (use [`fromSchema`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.DOMParser^fromSchema) and get the resulting parser's `rules` property instead).
The DOM parser option `topStart` has been replaced by [`topMatch`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.ParseOptions.topMatch).
The `DOMSerializer` methods `nodesFromSchema` and `marksFromSchema` are no longer public (construct a serializer with [`fromSchema`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.DOMSerializer^fromSchema) and read its `nodes` and `marks` properties instead).
### Bug fixes
Fix issue where whitespace at node boundaries was sometimes dropped during content parsing.
Attribute default values of `undefined` are now allowed.
### New features
[`contentElement`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.ParseRule.contentElement) in parse rules may now be a function.
The new method [`ResolvedPos.marksAcross`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.ResolvedPos.marksAcross) can be used to find the set of marks that should be preserved after a deletion.
[Content expressions](https://prosemirror.net/docs/ref/version/0.23.0.html#model.NodeSpec.content) are now a regular language, meaning all the operators can be nested and composed as desired, and a bunch of constraints on what could appear next to what have been lifted.
The starting content match for a node type now lives in [`NodeType.contentMatch`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.NodeType.contentMatch).
Allowed marks are now specified per node, rather than in content expressions, using the [`marks`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.NodeSpec.marks) property on the node spec.
Node types received new methods [`allowsMarkType`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.NodeType.allowsMarkType), [`allowsMarks`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.NodeType.allowsMarks), and [`allowedMarks`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.NodeType.allowedMarks), which tell you about the marks that node supports.
The [`style`](https://prosemirror.net/docs/ref/version/0.23.0.html#model.ParseRule.style) property on parse rules may now have the form `"font-style=italic"` to only match styles that have the value after the equals sign.
## 0.22.0 (2017-06-29)
### Bug fixes
When using [`parseSlice`](https://prosemirror.net/docs/ref/version/0.22.0.html#model.DOMParser.parseSlice), inline DOM content wrapped in block elements for which no parse rule is defined will now be properly wrapped in a textblock node.
### New features
[Resolved positions](https://prosemirror.net/docs/ref/version/0.22.0.html#model.ResolvedPos) now have a [`doc`](https://prosemirror.net/docs/ref/version/0.22.0.html#model.ResolvedPos.doc) accessor to easily get their root node.
Parse rules now support a [`namespace` property](https://prosemirror.net/docs/ref/version/0.22.0.html#model.ParseRule.namespace) to match XML namespaces.
The [`NodeRange`](https://prosemirror.net/docs/ref/version/0.22.0.html#model.NodeRange) constructor is now public (whereas before you could only construct these through [`blockRange`](https://prosemirror.net/docs/ref/version/0.22.0.html#model.ResolvedPos.blockRange)).
## 0.21.0 (2017-05-03)
### Breaking changes
The `openLeft` and `openRight` properties of `Slice` objects have been renamed to [`openStart`](https://prosemirror.net/docs/ref/version/0.21.0.html#model.Slice.openStart) and [`openEnd`](https://prosemirror.net/docs/ref/version/0.21.0.html#model.Slice.openEnd) to avoid confusion in right-to-left text. The old names will continue to work with a warning until the next release.
### New features
Mark [serializing functions](https://prosemirror.net/docs/ref/version/0.21.0.html#model.MarkSpec.toDOM) now get a second parameter that indicates whether the mark's content is inline or block nodes.
Setting a mark serializer to `null` in a [`DOMSerializer`](https://prosemirror.net/docs/ref/version/0.21.0.html#model.DOMSerializer) can now be used to omit that mark when serializing.
Node specs support a new property [`isolating`](https://prosemirror.net/docs/ref/version/0.21.0.html#model.NodeSpec.isolating), which is used to disable editing actions like backspacing and lifting across such a node's boundaries.
## 0.20.0 (2017-04-03)
### Breaking changes
Newlines in the text are now normalized to spaces when parsing except when you set `preserveWhitespace` to `"full"` in your [options](https://prosemirror.net/docs/ref/version/0.20.0.html#model.DOMParser.parse) or in a [parse rule](https://prosemirror.net/docs/ref/version/0.20.0.html#model.ParseRule.preserveWhitespace).
### Bug fixes
Fix crash in IE when parsing DOM content.
### New features
Fragments now have [`nodesBetween`](https://prosemirror.net/docs/ref/version/0.20.0.html#model.Fragment.nodesBetween) and [`descendants`](https://prosemirror.net/docs/ref/version/0.20.0.html#model.Fragments.descendants) methods, providing the same functionality as the methods by the same name on nodes.
Resolved positions now have [`max`](https://prosemirror.net/docs/ref/version/0.20.0.html#model.ResolvedPos.max) and [`min`](https://prosemirror.net/docs/ref/version/0.20.0.html#model.ResolvedPos.min) methods to easily find a maximum or minimum position.
## 0.19.0 (2017-03-16)
### Breaking changes
`MarkSpec.inclusiveRight` was replaced by [`inclusive`](https://prosemirror.net/docs/ref/version/0.19.0.html#model.MarkSpec.inclusive), which behaves slightly differently. `inclusiveRight` will be interpreted as `inclusive` (with a warning) until the next release.
### New features
The new [`inlineContent`](https://prosemirror.net/docs/ref/version/0.19.0.html#model.Node.inlineContent) property on nodes and node types tells you whether a node type supports inline content.
[`MarkSpec.inclusive`](https://prosemirror.net/docs/ref/version/0.19.0.html#model.MarkSpec.inclusive) can now be used to control whether content inserted at the boundary of a mark receives that mark.
Parse rule [`context`](https://prosemirror.net/docs/ref/version/0.19.0.html#model.ParseRule.context) restrictions can now use node [groups](https://prosemirror.net/docs/ref/version/0.19.0.html#model.NodeSpec.group), not just node names, to specify valid context.
## 0.18.0 (2017-02-24)
### Breaking changes
`schema.nodeSpec` and `schema.markSpec` have been deprecated in favor of [`schema.spec`](https://prosemirror.net/docs/ref/version/0.18.0.html#model.Schema.spec). The properties still work with a warning in this release, but will be dropped in the next.
### New features
`Node` objects now have a [`check`](https://prosemirror.net/docs/ref/version/0.18.0.html#model.Node.check) method which can be used to assert that they conform to the schema.
Node specs now support an [`atom` property](https://prosemirror.net/docs/ref/version/0.18.0.html#model.NodeSpec.atom), and nodes an [`isAtom` accessor](https://prosemirror.net/docs/ref/version/0.18.0.html#model.Node.isAtom), which is currently only used to determine whether such nodes should be directly selectable (for example when they are rendered as an uneditable node view).
The new [`excludes`](https://prosemirror.net/docs/ref/version/0.18.0.html#model.MarkSpec.excludes) field on mark specs can be used to control the marks that this mark may coexist with. Mark type objects also gained an [`excludes` _method_](https://prosemirror.net/docs/ref/version/0.18.0.html#model.MarkType.excludes) to querty this relation.
Mark specs now support a [`group`](https://prosemirror.net/docs/ref/version/0.18.0.html#model.MarkSpec.group) property, and marks can be referred to by group name in content specs.
The `Schema` class now provides its whole [spec](https://prosemirror.net/docs/ref/version/0.18.0.html#model.SchemaSpec) under its [`spec`](https://prosemirror.net/docs/ref/version/0.18.0.html#model.Schema.spec) property.
The name of a schema's default top-level node is now [configurable](https://prosemirror.net/docs/ref/version/0.18.0.html#model.SchemaSpec.topNode). You can use [`schema.topNodeType`](https://prosemirror.net/docs/ref/version/0.18.0.html#model.Schema.topNodeType) to retrieve the top node type.
[Parse rules](https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule) now support a [`context` field](https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.context) that can be used to only make the rule match inside certain ancestor nodes.
## 0.17.0 (2017-01-05)
### Breaking changes
`Node.marksAt` was replaced with [`ResolvedPos.marks`](https://prosemirror.net/docs/ref/version/0.17.0.html#model.ResolvedPos.marks). It still works (with a warning) in this release, but will be removed in the next one.
## 0.15.0 (2016-12-10)
### Breaking changes
`ResolvedPos.atNodeBoundary` is deprecated and will be removed in the next release. Use `textOffset > 0` instead.
### New features
Parse rules associated with a schema can now specify a [`priority`](https://prosemirror.net/docs/ref/version/0.15.0.html#model.ParseRule.priority) to influence the order in which they are applied.
Resolved positions have a new getter [`textOffset`](https://prosemirror.net/docs/ref/version/0.15.0.html#model.ResolvedPos.textOffset) to find their position within a text node (if any).
## 0.14.1 (2016-11-30)
### Bug fixes
[`DOMParser.parseSlice`](https://prosemirror.net/docs/ref/version/0.14.0.html#model.DOMParser.parseSlice) will now ignore whitespace-only text nodes at the top of the slice.
## 0.14.0 (2016-11-28)
### New features
Parse rules now support [`skip`](https://prosemirror.net/docs/ref/version/0.14.0.html#model.ParseRule.skip) (skip outer element, parse content) and [`getContent`](https://prosemirror.net/docs/ref/version/0.14.0.html#model.ParseRule.getContent) (compute content using custom code) properties.
The `DOMSerializer` class now exports a static [`renderSpec`](https://prosemirror.net/docs/ref/version/0.14.0.html#model.DOMSerializer^renderSpec) method that can help render DOM spec arrays.
## 0.13.0 (2016-11-11)
### Breaking changes
`ResolvedPos.sameDepth` is now called [`ResolvedPos.sharedDepth`](https://prosemirror.net/docs/ref/version/0.13.0.html#model.ResolvedPos.sharedDepth), and takes a raw, unresolved position as argument.
### New features
[`DOMSerializer`](https://prosemirror.net/docs/ref/version/0.13.0.html#model.DOMSerializer)'s `nodes` and `marks` properties are now public.
[`ContentMatch.findWrapping`](https://prosemirror.net/docs/ref/version/0.13.0.html#model.ContentMatch.findWrapping) now takes a third argument, `marks`. There's a new method [`findWrappingFor`](https://prosemirror.net/docs/ref/version/0.13.0.html#model.ContentMatch.findWrappingFor) that accepts a whole node.
Adds [`Slice.maxOpen`](https://prosemirror.net/docs/ref/version/0.13.0.html#model.Slice^maxOpen) static method to create maximally open slices.
DOM parser objects now have a [`parseSlice`](https://prosemirror.net/docs/ref/version/0.13.0.html#model.DOMParser.parseSlice) method which parses an HTML fragment into a [`Slice`](https://prosemirror.net/docs/ref/version/0.13.0.html#model.Slice), rather than trying to create a whole document from it.
## 0.12.0 (2016-10-21)
### Breaking changes
Drops support for some undocumented options to the DOM
serializer that were used by the view.
### Bug fixes
When rendering DOM attributes, only ignore null values, not all
falsy values.
## 0.11.0 (2016-09-21)
### Breaking changes
Moved into a separate module.
The JSON representation of [marks](https://prosemirror.net/docs/ref/version/0.11.0.html#model.Mark) has changed from
`{"_": "type", "attr1": "value"}` to `{"type": "type", "attrs":
{"attr1": "value"}}`, where `attrs` may be omitted when the mark has
no attributes.
Mark-related JSON methods now live on the
[`Mark` class](https://prosemirror.net/docs/ref/version/0.11.0.html#model.Mark^fromJSON).
The way node and mark types in a schema are defined was changed from
defining subclasses to passing plain objects
([`NodeSpec`](https://prosemirror.net/docs/ref/version/0.11.0.html#model.NodeSpec) and [`MarkSpec`](https://prosemirror.net/docs/ref/version/0.11.0.html#model.MarkSpec)).
DOM serialization and parsing logic is now done through dedicated
objects ([`DOMSerializer`](https://prosemirror.net/docs/ref/version/0.11.0.html#model.DOMSerializer) and
[`DOMParser`](https://prosemirror.net/docs/ref/version/0.11.0.html#model.DOMParser)), rather than through the schema. It
is now possible to define alternative parsing and serializing
strategies without touching the schema.
### New features
The [`Slice`](https://prosemirror.net/docs/ref/version/0.11.0.html#model.Slice) class now has an [`eq` method](https://prosemirror.net/docs/ref/version/0.11.0.html#model.Slice.eq).
The [`Node.marksAt`](https://prosemirror.net/docs/ref/version/0.11.0.html#model.Node.marksAt) method got a second
parameter to indicate you're interested in the marks _after_ the
position.
node-prosemirror-model-1.16.1+~cs1.1.5/CONTRIBUTING.md 0000664 0000000 0000000 00000007516 14207620105 0021625 0 ustar 00root root 0000000 0000000 # 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.
node-prosemirror-model-1.16.1+~cs1.1.5/LICENSE 0000664 0000000 0000000 00000002113 14207620105 0020365 0 ustar 00root root 0000000 0000000 Copyright (C) 2015-2017 by Marijn Haverbeke 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.
node-prosemirror-model-1.16.1+~cs1.1.5/README.md 0000664 0000000 0000000 00000002765 14207620105 0020654 0 ustar 00root root 0000000 0000000 # prosemirror-model
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://github.com/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**GITTER**](https://gitter.im/ProseMirror/prosemirror) | [**CHANGELOG**](https://github.com/ProseMirror/prosemirror-model/blob/master/CHANGELOG.md) ]
This is a [core module](https://prosemirror.net/docs/ref/#model) of [ProseMirror](https://prosemirror.net).
ProseMirror is a well-behaved rich semantic content editor based on
contentEditable, with support for collaborative editing and custom
document schemas.
This [module](https://prosemirror.net/docs/ref/#model) implements
ProseMirror's [document model](https://prosemirror.net/docs/guide/#doc),
along with the mechanisms needed to support
[schemas](https://prosemirror.net/docs/guide/#schema).
The [project page](https://prosemirror.net) has more information, a
number of [examples](https://prosemirror.net/examples/) and the
[documentation](https://prosemirror.net/docs/).
This code is released under an
[MIT license](https://github.com/prosemirror/prosemirror/tree/master/LICENSE).
There's a [forum](http://discuss.prosemirror.net) for general
discussion and support requests, and the
[Github bug tracker](https://github.com/prosemirror/prosemirror/issues)
is the place to report issues.
We aim to be an inclusive, welcoming community. To make that explicit,
we have a [code of
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
to communication around the project.
node-prosemirror-model-1.16.1+~cs1.1.5/etc/ 0000775 0000000 0000000 00000000000 14207620105 0020136 5 ustar 00root root 0000000 0000000 node-prosemirror-model-1.16.1+~cs1.1.5/etc/link-self.js 0000664 0000000 0000000 00000000523 14207620105 0022360 0 ustar 00root root 0000000 0000000 const {lstatSync, symlinkSync, renameSync} = require("fs")
let stats
try {
stats = lstatSync("node_modules/prosemirror-model")
} catch(_) {
return
}
if (!stats.isSymbolicLink()) {
renameSync("node_modules/prosemirror-model", "node_modules/prosemirror-model.disabled")
symlinkSync("..", "node_modules/prosemirror-model", "dir")
}
node-prosemirror-model-1.16.1+~cs1.1.5/package.json 0000664 0000000 0000000 00000001532 14207620105 0021652 0 ustar 00root root 0000000 0000000 {
"name": "prosemirror-model",
"version": "1.16.1",
"description": "ProseMirror's document model",
"main": "dist/index.js",
"module": "dist/index.es.js",
"license": "MIT",
"maintainers": [
{
"name": "Marijn Haverbeke",
"email": "marijnh@gmail.com",
"web": "http://marijnhaverbeke.nl"
}
],
"repository": {
"type": "git",
"url": "git://github.com/prosemirror/prosemirror-model.git"
},
"dependencies": {
"orderedmap": "^1.1.0"
},
"devDependencies": {
"mocha": "^9.1.2",
"ist": "^1.0.0",
"jsdom": "^10.1.0",
"prosemirror-test-builder": "^1.0.0",
"rollup": "^2.26.3",
"@rollup/plugin-buble": "^0.21.3"
},
"scripts": {
"test": "node etc/link-self.js && mocha test/test-*.js",
"build": "rollup -c",
"watch": "rollup -c -w",
"prepare": "npm run build"
}
}
node-prosemirror-model-1.16.1+~cs1.1.5/rollup.config.js 0000664 0000000 0000000 00000000512 14207620105 0022500 0 ustar 00root root 0000000 0000000 module.exports = {
input: './src/index.js',
output: [{
file: 'dist/index.js',
format: 'cjs',
sourcemap: true
}, {
file: 'dist/index.es.js',
format: 'es',
sourcemap: true
}],
plugins: [require('@rollup/plugin-buble')()],
external(id) { return id[0] != "." && !require("path").isAbsolute(id) }
}
node-prosemirror-model-1.16.1+~cs1.1.5/src/ 0000775 0000000 0000000 00000000000 14207620105 0020152 5 ustar 00root root 0000000 0000000 node-prosemirror-model-1.16.1+~cs1.1.5/src/README.md 0000664 0000000 0000000 00000002427 14207620105 0021436 0 ustar 00root root 0000000 0000000 This module defines ProseMirror's content model, the data structures
used to represent and work with documents.
### Document Structure
A ProseMirror document is a tree. At each level, a [node](#model.Node)
describes the type of the content, and holds a
[fragment](#model.Fragment) containing its children.
@Node
@Fragment
@Mark
@Slice
@ReplaceError
### Resolved Positions
Positions in a document can be represented as integer
[offsets](/docs/guide/#doc.indexing). But you'll often want to use a
more convenient representation.
@ResolvedPos
@NodeRange
### Document Schema
Every ProseMirror document conforms to a
[schema](/docs/guide/#schema), which describes the set of nodes and
marks that it is made out of, along with the relations between those,
such as which node may occur as a child node of which other nodes.
@Schema
@SchemaSpec
@NodeSpec
@MarkSpec
@AttributeSpec
@NodeType
@MarkType
@ContentMatch
### DOM Representation
Because representing a document as a tree of DOM nodes is central to
the way ProseMirror operates, DOM [parsing](#model.DOMParser) and
[serializing](#model.DOMSerializer) is integrated with the model.
(But note that you do _not_ need to have a DOM implementation loaded
to use this module.)
@DOMParser
@ParseOptions
@ParseRule
@DOMSerializer
@DOMOutputSpec
node-prosemirror-model-1.16.1+~cs1.1.5/src/comparedeep.js 0000664 0000000 0000000 00000001014 14207620105 0022770 0 ustar 00root root 0000000 0000000 export function compareDeep(a, b) {
if (a === b) return true
if (!(a && typeof a == "object") ||
!(b && typeof b == "object")) return false
let array = Array.isArray(a)
if (Array.isArray(b) != array) return false
if (array) {
if (a.length != b.length) return false
for (let i = 0; i < a.length; i++) if (!compareDeep(a[i], b[i])) return false
} else {
for (let p in a) if (!(p in b) || !compareDeep(a[p], b[p])) return false
for (let p in b) if (!(p in a)) return false
}
return true
}
node-prosemirror-model-1.16.1+~cs1.1.5/src/content.js 0000664 0000000 0000000 00000030627 14207620105 0022172 0 ustar 00root root 0000000 0000000 import {Fragment} from "./fragment"
// ::- Instances of this class represent a match state of a node
// type's [content expression](#model.NodeSpec.content), and can be
// used to find out whether further content matches here, and whether
// a given position is a valid end of the node.
export class ContentMatch {
constructor(validEnd) {
// :: bool
// True when this match state represents a valid end of the node.
this.validEnd = validEnd
this.next = []
this.wrapCache = []
}
static parse(string, nodeTypes) {
let stream = new TokenStream(string, nodeTypes)
if (stream.next == null) return ContentMatch.empty
let expr = parseExpr(stream)
if (stream.next) stream.err("Unexpected trailing text")
let match = dfa(nfa(expr))
checkForDeadEnds(match, stream)
return match
}
// :: (NodeType) → ?ContentMatch
// Match a node type, returning a match after that node if
// successful.
matchType(type) {
for (let i = 0; i < this.next.length; i += 2)
if (this.next[i] == type) return this.next[i + 1]
return null
}
// :: (Fragment, ?number, ?number) → ?ContentMatch
// Try to match a fragment. Returns the resulting match when
// successful.
matchFragment(frag, start = 0, end = frag.childCount) {
let cur = this
for (let i = start; cur && i < end; i++)
cur = cur.matchType(frag.child(i).type)
return cur
}
get inlineContent() {
let first = this.next[0]
return first ? first.isInline : false
}
// :: ?NodeType
// Get the first matching node type at this match position that can
// be generated.
get defaultType() {
for (let i = 0; i < this.next.length; i += 2) {
let type = this.next[i]
if (!(type.isText || type.hasRequiredAttrs())) return type
}
}
compatible(other) {
for (let i = 0; i < this.next.length; i += 2)
for (let j = 0; j < other.next.length; j += 2)
if (this.next[i] == other.next[j]) return true
return false
}
// :: (Fragment, bool, ?number) → ?Fragment
// Try to match the given fragment, and if that fails, see if it can
// be made to match by inserting nodes in front of it. When
// successful, return a fragment of inserted nodes (which may be
// empty if nothing had to be inserted). When `toEnd` is true, only
// return a fragment if the resulting match goes to the end of the
// content expression.
fillBefore(after, toEnd = false, startIndex = 0) {
let seen = [this]
function search(match, types) {
let finished = match.matchFragment(after, startIndex)
if (finished && (!toEnd || finished.validEnd))
return Fragment.from(types.map(tp => tp.createAndFill()))
for (let i = 0; i < match.next.length; i += 2) {
let type = match.next[i], next = match.next[i + 1]
if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next) == -1) {
seen.push(next)
let found = search(next, types.concat(type))
if (found) return found
}
}
}
return search(this, [])
}
// :: (NodeType) → ?[NodeType]
// Find a set of wrapping node types that would allow a node of the
// given type to appear at this position. The result may be empty
// (when it fits directly) and will be null when no such wrapping
// exists.
findWrapping(target) {
for (let i = 0; i < this.wrapCache.length; i += 2)
if (this.wrapCache[i] == target) return this.wrapCache[i + 1]
let computed = this.computeWrapping(target)
this.wrapCache.push(target, computed)
return computed
}
computeWrapping(target) {
let seen = Object.create(null), active = [{match: this, type: null, via: null}]
while (active.length) {
let current = active.shift(), match = current.match
if (match.matchType(target)) {
let result = []
for (let obj = current; obj.type; obj = obj.via)
result.push(obj.type)
return result.reverse()
}
for (let i = 0; i < match.next.length; i += 2) {
let type = match.next[i]
if (!type.isLeaf && !type.hasRequiredAttrs() && !(type.name in seen) && (!current.type || match.next[i + 1].validEnd)) {
active.push({match: type.contentMatch, type, via: current})
seen[type.name] = true
}
}
}
}
// :: number
// The number of outgoing edges this node has in the finite
// automaton that describes the content expression.
get edgeCount() {
return this.next.length >> 1
}
// :: (number) → {type: NodeType, next: ContentMatch}
// Get the _n_th outgoing edge from this node in the finite
// automaton that describes the content expression.
edge(n) {
let i = n << 1
if (i >= this.next.length) throw new RangeError(`There's no ${n}th edge in this content match`)
return {type: this.next[i], next: this.next[i + 1]}
}
toString() {
let seen = []
function scan(m) {
seen.push(m)
for (let i = 1; i < m.next.length; i += 2)
if (seen.indexOf(m.next[i]) == -1) scan(m.next[i])
}
scan(this)
return seen.map((m, i) => {
let out = i + (m.validEnd ? "*" : " ") + " "
for (let i = 0; i < m.next.length; i += 2)
out += (i ? ", " : "") + m.next[i].name + "->" + seen.indexOf(m.next[i + 1])
return out
}).join("\n")
}
}
ContentMatch.empty = new ContentMatch(true)
class TokenStream {
constructor(string, nodeTypes) {
this.string = string
this.nodeTypes = nodeTypes
this.inline = null
this.pos = 0
this.tokens = string.split(/\s*(?=\b|\W|$)/)
if (this.tokens[this.tokens.length - 1] == "") this.tokens.pop()
if (this.tokens[0] == "") this.tokens.shift()
}
get next() { return this.tokens[this.pos] }
eat(tok) { return this.next == tok && (this.pos++ || true) }
err(str) { throw new SyntaxError(str + " (in content expression '" + this.string + "')") }
}
function parseExpr(stream) {
let exprs = []
do { exprs.push(parseExprSeq(stream)) }
while (stream.eat("|"))
return exprs.length == 1 ? exprs[0] : {type: "choice", exprs}
}
function parseExprSeq(stream) {
let exprs = []
do { exprs.push(parseExprSubscript(stream)) }
while (stream.next && stream.next != ")" && stream.next != "|")
return exprs.length == 1 ? exprs[0] : {type: "seq", exprs}
}
function parseExprSubscript(stream) {
let expr = parseExprAtom(stream)
for (;;) {
if (stream.eat("+"))
expr = {type: "plus", expr}
else if (stream.eat("*"))
expr = {type: "star", expr}
else if (stream.eat("?"))
expr = {type: "opt", expr}
else if (stream.eat("{"))
expr = parseExprRange(stream, expr)
else break
}
return expr
}
function parseNum(stream) {
if (/\D/.test(stream.next)) stream.err("Expected number, got '" + stream.next + "'")
let result = Number(stream.next)
stream.pos++
return result
}
function parseExprRange(stream, expr) {
let min = parseNum(stream), max = min
if (stream.eat(",")) {
if (stream.next != "}") max = parseNum(stream)
else max = -1
}
if (!stream.eat("}")) stream.err("Unclosed braced range")
return {type: "range", min, max, expr}
}
function resolveName(stream, name) {
let types = stream.nodeTypes, type = types[name]
if (type) return [type]
let result = []
for (let typeName in types) {
let type = types[typeName]
if (type.groups.indexOf(name) > -1) result.push(type)
}
if (result.length == 0) stream.err("No node type or group '" + name + "' found")
return result
}
function parseExprAtom(stream) {
if (stream.eat("(")) {
let expr = parseExpr(stream)
if (!stream.eat(")")) stream.err("Missing closing paren")
return expr
} else if (!/\W/.test(stream.next)) {
let exprs = resolveName(stream, stream.next).map(type => {
if (stream.inline == null) stream.inline = type.isInline
else if (stream.inline != type.isInline) stream.err("Mixing inline and block content")
return {type: "name", value: type}
})
stream.pos++
return exprs.length == 1 ? exprs[0] : {type: "choice", exprs}
} else {
stream.err("Unexpected token '" + stream.next + "'")
}
}
// The code below helps compile a regular-expression-like language
// into a deterministic finite automaton. For a good introduction to
// these concepts, see https://swtch.com/~rsc/regexp/regexp1.html
// : (Object) → [[{term: ?any, to: number}]]
// Construct an NFA from an expression as returned by the parser. The
// NFA is represented as an array of states, which are themselves
// arrays of edges, which are `{term, to}` objects. The first state is
// the entry state and the last node is the success state.
//
// Note that unlike typical NFAs, the edge ordering in this one is
// significant, in that it is used to contruct filler content when
// necessary.
function nfa(expr) {
let nfa = [[]]
connect(compile(expr, 0), node())
return nfa
function node() { return nfa.push([]) - 1 }
function edge(from, to, term) {
let edge = {term, to}
nfa[from].push(edge)
return edge
}
function connect(edges, to) { edges.forEach(edge => edge.to = to) }
function compile(expr, from) {
if (expr.type == "choice") {
return expr.exprs.reduce((out, expr) => out.concat(compile(expr, from)), [])
} else if (expr.type == "seq") {
for (let i = 0;; i++) {
let next = compile(expr.exprs[i], from)
if (i == expr.exprs.length - 1) return next
connect(next, from = node())
}
} else if (expr.type == "star") {
let loop = node()
edge(from, loop)
connect(compile(expr.expr, loop), loop)
return [edge(loop)]
} else if (expr.type == "plus") {
let loop = node()
connect(compile(expr.expr, from), loop)
connect(compile(expr.expr, loop), loop)
return [edge(loop)]
} else if (expr.type == "opt") {
return [edge(from)].concat(compile(expr.expr, from))
} else if (expr.type == "range") {
let cur = from
for (let i = 0; i < expr.min; i++) {
let next = node()
connect(compile(expr.expr, cur), next)
cur = next
}
if (expr.max == -1) {
connect(compile(expr.expr, cur), cur)
} else {
for (let i = expr.min; i < expr.max; i++) {
let next = node()
edge(cur, next)
connect(compile(expr.expr, cur), next)
cur = next
}
}
return [edge(cur)]
} else if (expr.type == "name") {
return [edge(from, null, expr.value)]
}
}
}
function cmp(a, b) { return b - a }
// Get the set of nodes reachable by null edges from `node`. Omit
// nodes with only a single null-out-edge, since they may lead to
// needless duplicated nodes.
function nullFrom(nfa, node) {
let result = []
scan(node)
return result.sort(cmp)
function scan(node) {
let edges = nfa[node]
if (edges.length == 1 && !edges[0].term) return scan(edges[0].to)
result.push(node)
for (let i = 0; i < edges.length; i++) {
let {term, to} = edges[i]
if (!term && result.indexOf(to) == -1) scan(to)
}
}
}
// : ([[{term: ?any, to: number}]]) → ContentMatch
// Compiles an NFA as produced by `nfa` into a DFA, modeled as a set
// of state objects (`ContentMatch` instances) with transitions
// between them.
function dfa(nfa) {
let labeled = Object.create(null)
return explore(nullFrom(nfa, 0))
function explore(states) {
let out = []
states.forEach(node => {
nfa[node].forEach(({term, to}) => {
if (!term) return
let known = out.indexOf(term), set = known > -1 && out[known + 1]
nullFrom(nfa, to).forEach(node => {
if (!set) out.push(term, set = [])
if (set.indexOf(node) == -1) set.push(node)
})
})
})
let state = labeled[states.join(",")] = new ContentMatch(states.indexOf(nfa.length - 1) > -1)
for (let i = 0; i < out.length; i += 2) {
let states = out[i + 1].sort(cmp)
state.next.push(out[i], labeled[states.join(",")] || explore(states))
}
return state
}
}
function checkForDeadEnds(match, stream) {
for (let i = 0, work = [match]; i < work.length; i++) {
let state = work[i], dead = !state.validEnd, nodes = []
for (let j = 0; j < state.next.length; j += 2) {
let node = state.next[j], next = state.next[j + 1]
nodes.push(node.name)
if (dead && !(node.isText || node.hasRequiredAttrs())) dead = false
if (work.indexOf(next) == -1) work.push(next)
}
if (dead) stream.err("Only non-generatable nodes (" + nodes.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)")
}
}
node-prosemirror-model-1.16.1+~cs1.1.5/src/diff.js 0000664 0000000 0000000 00000003150 14207620105 0021417 0 ustar 00root root 0000000 0000000 export function findDiffStart(a, b, pos) {
for (let i = 0;; i++) {
if (i == a.childCount || i == b.childCount)
return a.childCount == b.childCount ? null : pos
let childA = a.child(i), childB = b.child(i)
if (childA == childB) { pos += childA.nodeSize; continue }
if (!childA.sameMarkup(childB)) return pos
if (childA.isText && childA.text != childB.text) {
for (let j = 0; childA.text[j] == childB.text[j]; j++)
pos++
return pos
}
if (childA.content.size || childB.content.size) {
let inner = findDiffStart(childA.content, childB.content, pos + 1)
if (inner != null) return inner
}
pos += childA.nodeSize
}
}
export function findDiffEnd(a, b, posA, posB) {
for (let iA = a.childCount, iB = b.childCount;;) {
if (iA == 0 || iB == 0)
return iA == iB ? null : {a: posA, b: posB}
let childA = a.child(--iA), childB = b.child(--iB), size = childA.nodeSize
if (childA == childB) {
posA -= size; posB -= size
continue
}
if (!childA.sameMarkup(childB)) return {a: posA, b: posB}
if (childA.isText && childA.text != childB.text) {
let same = 0, minSize = Math.min(childA.text.length, childB.text.length)
while (same < minSize && childA.text[childA.text.length - same - 1] == childB.text[childB.text.length - same - 1]) {
same++; posA--; posB--
}
return {a: posA, b: posB}
}
if (childA.content.size || childB.content.size) {
let inner = findDiffEnd(childA.content, childB.content, posA - 1, posB - 1)
if (inner) return inner
}
posA -= size; posB -= size
}
}
node-prosemirror-model-1.16.1+~cs1.1.5/src/fragment.js 0000664 0000000 0000000 00000023735 14207620105 0022325 0 ustar 00root root 0000000 0000000 import {findDiffStart, findDiffEnd} from "./diff"
// ::- A fragment represents a node's collection of child nodes.
//
// Like nodes, fragments are persistent data structures, and you
// should not mutate them or their content. Rather, you create new
// instances whenever needed. The API tries to make this easy.
export class Fragment {
constructor(content, size) {
this.content = content
// :: number
// The size of the fragment, which is the total of the size of its
// content nodes.
this.size = size || 0
if (size == null) for (let i = 0; i < content.length; i++)
this.size += content[i].nodeSize
}
// :: (number, number, (node: Node, start: number, parent: Node, index: number) → ?bool, ?number)
// Invoke a callback for all descendant nodes between the given two
// positions (relative to start of this fragment). Doesn't descend
// into a node when the callback returns `false`.
nodesBetween(from, to, f, nodeStart = 0, parent) {
for (let i = 0, pos = 0; pos < to; i++) {
let child = this.content[i], end = pos + child.nodeSize
if (end > from && f(child, nodeStart + pos, parent, i) !== false && child.content.size) {
let start = pos + 1
child.nodesBetween(Math.max(0, from - start),
Math.min(child.content.size, to - start),
f, nodeStart + start)
}
pos = end
}
}
// :: ((node: Node, pos: number, parent: Node) → ?bool)
// Call the given callback for every descendant node. The callback
// may return `false` to prevent traversal of a given node's children.
descendants(f) {
this.nodesBetween(0, this.size, f)
}
// :: (number, number, ?string, ?union) → string
// Extract the text between `from` and `to`. See the same method on
// [`Node`](#model.Node.textBetween).
textBetween(from, to, blockSeparator, leafText) {
let text = "", separated = true
this.nodesBetween(from, to, (node, pos) => {
if (node.isText) {
text += node.text.slice(Math.max(from, pos) - pos, to - pos)
separated = !blockSeparator
} else if (node.isLeaf && leafText) {
text += typeof leafText === 'function' ? leafText(node): leafText
separated = !blockSeparator
} else if (!separated && node.isBlock) {
text += blockSeparator
separated = true
}
}, 0)
return text
}
// :: (Fragment) → Fragment
// Create a new fragment containing the combined content of this
// fragment and the other.
append(other) {
if (!other.size) return this
if (!this.size) return other
let last = this.lastChild, first = other.firstChild, content = this.content.slice(), i = 0
if (last.isText && last.sameMarkup(first)) {
content[content.length - 1] = last.withText(last.text + first.text)
i = 1
}
for (; i < other.content.length; i++) content.push(other.content[i])
return new Fragment(content, this.size + other.size)
}
// :: (number, ?number) → Fragment
// Cut out the sub-fragment between the two given positions.
cut(from, to) {
if (to == null) to = this.size
if (from == 0 && to == this.size) return this
let result = [], size = 0
if (to > from) for (let i = 0, pos = 0; pos < to; i++) {
let child = this.content[i], end = pos + child.nodeSize
if (end > from) {
if (pos < from || end > to) {
if (child.isText)
child = child.cut(Math.max(0, from - pos), Math.min(child.text.length, to - pos))
else
child = child.cut(Math.max(0, from - pos - 1), Math.min(child.content.size, to - pos - 1))
}
result.push(child)
size += child.nodeSize
}
pos = end
}
return new Fragment(result, size)
}
cutByIndex(from, to) {
if (from == to) return Fragment.empty
if (from == 0 && to == this.content.length) return this
return new Fragment(this.content.slice(from, to))
}
// :: (number, Node) → Fragment
// Create a new fragment in which the node at the given index is
// replaced by the given node.
replaceChild(index, node) {
let current = this.content[index]
if (current == node) return this
let copy = this.content.slice()
let size = this.size + node.nodeSize - current.nodeSize
copy[index] = node
return new Fragment(copy, size)
}
// : (Node) → Fragment
// Create a new fragment by prepending the given node to this
// fragment.
addToStart(node) {
return new Fragment([node].concat(this.content), this.size + node.nodeSize)
}
// : (Node) → Fragment
// Create a new fragment by appending the given node to this
// fragment.
addToEnd(node) {
return new Fragment(this.content.concat(node), this.size + node.nodeSize)
}
// :: (Fragment) → bool
// Compare this fragment to another one.
eq(other) {
if (this.content.length != other.content.length) return false
for (let i = 0; i < this.content.length; i++)
if (!this.content[i].eq(other.content[i])) return false
return true
}
// :: ?Node
// The first child of the fragment, or `null` if it is empty.
get firstChild() { return this.content.length ? this.content[0] : null }
// :: ?Node
// The last child of the fragment, or `null` if it is empty.
get lastChild() { return this.content.length ? this.content[this.content.length - 1] : null }
// :: number
// The number of child nodes in this fragment.
get childCount() { return this.content.length }
// :: (number) → Node
// Get the child node at the given index. Raise an error when the
// index is out of range.
child(index) {
let found = this.content[index]
if (!found) throw new RangeError("Index " + index + " out of range for " + this)
return found
}
// :: (number) → ?Node
// Get the child node at the given index, if it exists.
maybeChild(index) {
return this.content[index]
}
// :: ((node: Node, offset: number, index: number))
// Call `f` for every child node, passing the node, its offset
// into this parent node, and its index.
forEach(f) {
for (let i = 0, p = 0; i < this.content.length; i++) {
let child = this.content[i]
f(child, p, i)
p += child.nodeSize
}
}
// :: (Fragment) → ?number
// Find the first position at which this fragment and another
// fragment differ, or `null` if they are the same.
findDiffStart(other, pos = 0) {
return findDiffStart(this, other, pos)
}
// :: (Fragment) → ?{a: number, b: number}
// Find the first position, searching from the end, at which this
// fragment and the given fragment differ, or `null` if they are the
// same. Since this position will not be the same in both nodes, an
// object with two separate positions is returned.
findDiffEnd(other, pos = this.size, otherPos = other.size) {
return findDiffEnd(this, other, pos, otherPos)
}
// : (number, ?number) → {index: number, offset: number}
// Find the index and inner offset corresponding to a given relative
// position in this fragment. The result object will be reused
// (overwritten) the next time the function is called. (Not public.)
findIndex(pos, round = -1) {
if (pos == 0) return retIndex(0, pos)
if (pos == this.size) return retIndex(this.content.length, pos)
if (pos > this.size || pos < 0) throw new RangeError(`Position ${pos} outside of fragment (${this})`)
for (let i = 0, curPos = 0;; i++) {
let cur = this.child(i), end = curPos + cur.nodeSize
if (end >= pos) {
if (end == pos || round > 0) return retIndex(i + 1, end)
return retIndex(i, curPos)
}
curPos = end
}
}
// :: () → string
// Return a debugging string that describes this fragment.
toString() { return "<" + this.toStringInner() + ">" }
toStringInner() { return this.content.join(", ") }
// :: () → ?Object
// Create a JSON-serializeable representation of this fragment.
toJSON() {
return this.content.length ? this.content.map(n => n.toJSON()) : null
}
// :: (Schema, ?Object) → Fragment
// Deserialize a fragment from its JSON representation.
static fromJSON(schema, value) {
if (!value) return Fragment.empty
if (!Array.isArray(value)) throw new RangeError("Invalid input for Fragment.fromJSON")
return new Fragment(value.map(schema.nodeFromJSON))
}
// :: ([Node]) → Fragment
// Build a fragment from an array of nodes. Ensures that adjacent
// text nodes with the same marks are joined together.
static fromArray(array) {
if (!array.length) return Fragment.empty
let joined, size = 0
for (let i = 0; i < array.length; i++) {
let node = array[i]
size += node.nodeSize
if (i && node.isText && array[i - 1].sameMarkup(node)) {
if (!joined) joined = array.slice(0, i)
joined[joined.length - 1] = node.withText(joined[joined.length - 1].text + node.text)
} else if (joined) {
joined.push(node)
}
}
return new Fragment(joined || array, size)
}
// :: (?union) → Fragment
// Create a fragment from something that can be interpreted as a set
// of nodes. For `null`, it returns the empty fragment. For a
// fragment, the fragment itself. For a node or array of nodes, a
// fragment containing those nodes.
static from(nodes) {
if (!nodes) return Fragment.empty
if (nodes instanceof Fragment) return nodes
if (Array.isArray(nodes)) return this.fromArray(nodes)
if (nodes.attrs) return new Fragment([nodes], nodes.nodeSize)
throw new RangeError("Can not convert " + nodes + " to a Fragment" +
(nodes.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""))
}
}
const found = {index: 0, offset: 0}
function retIndex(index, offset) {
found.index = index
found.offset = offset
return found
}
// :: Fragment
// An empty fragment. Intended to be reused whenever a node doesn't
// contain anything (rather than allocating a new empty fragment for
// each leaf node).
Fragment.empty = new Fragment([], 0)
node-prosemirror-model-1.16.1+~cs1.1.5/src/from_dom.js 0000664 0000000 0000000 00000074135 14207620105 0022324 0 ustar 00root root 0000000 0000000 import {Fragment} from "./fragment"
import {Slice} from "./replace"
import {Mark} from "./mark"
// ParseOptions:: interface
// These are the options recognized by the
// [`parse`](#model.DOMParser.parse) and
// [`parseSlice`](#model.DOMParser.parseSlice) methods.
//
// preserveWhitespace:: ?union
// By default, whitespace is collapsed as per HTML's rules. Pass
// `true` to preserve whitespace, but normalize newlines to
// spaces, and `"full"` to preserve whitespace entirely.
//
// findPositions:: ?[{node: dom.Node, offset: number}]
// When given, the parser will, beside parsing the content,
// record the document positions of the given DOM positions. It
// will do so by writing to the objects, adding a `pos` property
// that holds the document position. DOM positions that are not
// in the parsed content will not be written to.
//
// from:: ?number
// The child node index to start parsing from.
//
// to:: ?number
// The child node index to stop parsing at.
//
// topNode:: ?Node
// By default, the content is parsed into the schema's default
// [top node type](#model.Schema.topNodeType). You can pass this
// option to use the type and attributes from a different node
// as the top container.
//
// topMatch:: ?ContentMatch
// Provide the starting content match that content parsed into the
// top node is matched against.
//
// context:: ?ResolvedPos
// A set of additional nodes to count as
// [context](#model.ParseRule.context) when parsing, above the
// given [top node](#model.ParseOptions.topNode).
// ParseRule:: interface
// A value that describes how to parse a given DOM node or inline
// style as a ProseMirror node or mark.
//
// tag:: ?string
// A CSS selector describing the kind of DOM elements to match. A
// single rule should have _either_ a `tag` or a `style` property.
//
// namespace:: ?string
// The namespace to match. This should be used with `tag`.
// Nodes are only matched when the namespace matches or this property
// is null.
//
// style:: ?string
// A CSS property name to match. When given, this rule matches
// inline styles that list that property. May also have the form
// `"property=value"`, in which case the rule only matches if the
// property's value exactly matches the given value. (For more
// complicated filters, use [`getAttrs`](#model.ParseRule.getAttrs)
// and return false to indicate that the match failed.) Rules
// matching styles may only produce [marks](#model.ParseRule.mark),
// not nodes.
//
// priority:: ?number
// Can be used to change the order in which the parse rules in a
// schema are tried. Those with higher priority come first. Rules
// without a priority are counted as having priority 50. This
// property is only meaningful in a schema—when directly
// constructing a parser, the order of the rule array is used.
//
// consuming:: ?boolean
// By default, when a rule matches an element or style, no further
// rules get a chance to match it. By setting this to `false`, you
// indicate that even when this rule matches, other rules that come
// after it should also run.
//
// context:: ?string
// When given, restricts this rule to only match when the current
// context—the parent nodes into which the content is being
// parsed—matches this expression. Should contain one or more node
// names or node group names followed by single or double slashes.
// For example `"paragraph/"` means the rule only matches when the
// parent node is a paragraph, `"blockquote/paragraph/"` restricts
// it to be in a paragraph that is inside a blockquote, and
// `"section//"` matches any position inside a section—a double
// slash matches any sequence of ancestor nodes. To allow multiple
// different contexts, they can be separated by a pipe (`|`)
// character, as in `"blockquote/|list_item/"`.
//
// node:: ?string
// The name of the node type to create when this rule matches. Only
// valid for rules with a `tag` property, not for style rules. Each
// rule should have one of a `node`, `mark`, or `ignore` property
// (except when it appears in a [node](#model.NodeSpec.parseDOM) or
// [mark spec](#model.MarkSpec.parseDOM), in which case the `node`
// or `mark` property will be derived from its position).
//
// mark:: ?string
// The name of the mark type to wrap the matched content in.
//
// ignore:: ?bool
// When true, ignore content that matches this rule.
//
// closeParent:: ?bool
// When true, finding an element that matches this rule will close
// the current node.
//
// skip:: ?bool
// When true, ignore the node that matches this rule, but do parse
// its content.
//
// attrs:: ?Object
// Attributes for the node or mark created by this rule. When
// `getAttrs` is provided, it takes precedence.
//
// getAttrs:: ?(union) → ?union