@lblod/ember-rdfa-editor 12.12.0 → 12.12.1-dev.cfccfaf88a64bd52aea209b09d95c4e705c0ca44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/commands/toggle-mark-add-first.d.ts +2 -0
- package/declarations/commands/toggle-mark-add-first.d.ts.map +1 -1
- package/declarations/components/toolbar/mark.d.ts.map +1 -1
- package/declarations/core/keymap.d.ts.map +1 -1
- package/declarations/core/rdfa-types.d.ts +2 -0
- package/declarations/core/rdfa-types.d.ts.map +1 -1
- package/declarations/core/say-controller.d.ts.map +1 -1
- package/declarations/nodes/inline-rdfa.d.ts +11 -0
- package/declarations/nodes/inline-rdfa.d.ts.map +1 -1
- package/declarations/plugins/color/commands/set-color.d.ts.map +1 -1
- package/declarations/plugins/highlight/commands/set-highlight.d.ts.map +1 -1
- package/declarations/utils/_private/rdfa-parser/post-process-as-rdfa-nodes.d.ts.map +1 -1
- package/dist/commands/toggle-mark-add-first.js +2 -0
- package/dist/commands/toggle-mark-add-first.js.map +1 -1
- package/dist/components/toolbar/mark.js +7 -4
- package/dist/components/toolbar/mark.js.map +1 -1
- package/dist/core/keymap.js +37 -14
- package/dist/core/keymap.js.map +1 -1
- package/dist/core/rdfa-types.js +7 -1
- package/dist/core/rdfa-types.js.map +1 -1
- package/dist/core/say-controller.js +0 -1
- package/dist/core/say-controller.js.map +1 -1
- package/dist/nodes/inline-rdfa.js +24 -6
- package/dist/nodes/inline-rdfa.js.map +1 -1
- package/dist/plugins/color/commands/set-color.js +4 -2
- package/dist/plugins/color/commands/set-color.js.map +1 -1
- package/dist/plugins/highlight/commands/set-highlight.js +4 -2
- package/dist/plugins/highlight/commands/set-highlight.js.map +1 -1
- package/dist/utils/_private/rdfa-parser/post-process-as-rdfa-nodes.js +42 -2
- package/dist/utils/_private/rdfa-parser/post-process-as-rdfa-nodes.js.map +1 -1
- package/package.json +7 -7
|
@@ -11,6 +11,8 @@ import type { Command } from 'prosemirror-state';
|
|
|
11
11
|
*
|
|
12
12
|
* @param markType
|
|
13
13
|
* @param attrs
|
|
14
|
+
*
|
|
15
|
+
* @deprecated Use the the `toggleMark` command with the `removeWhenPresent` option instead.
|
|
14
16
|
*/
|
|
15
17
|
export declare function toggleMarkAddFirst(markType: MarkType, attrs?: Attrs | null): Command;
|
|
16
18
|
//# sourceMappingURL=toggle-mark-add-first.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-mark-add-first.d.ts","sourceRoot":"","sources":["../../src/commands/toggle-mark-add-first.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,mBAAmB,CAAC;AAQhE
|
|
1
|
+
{"version":3,"file":"toggle-mark-add-first.d.ts","sourceRoot":"","sources":["../../src/commands/toggle-mark-add-first.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,mBAAmB,CAAC;AAQhE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,KAAK,GAAE,KAAK,GAAG,IAAW,GACzB,OAAO,CAoCT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mark.d.ts","sourceRoot":"","sources":["../../../src/components/toolbar/mark.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,aAAa,MAAM,8BAA8B,CAAC;AAKzD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE;QACJ,UAAU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":"keymap.d.ts","sourceRoot":"","sources":["../../src/core/keymap.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA6B3C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE;QACV;;;;;WAKG;QACH,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,CACnB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,KACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAoE7B,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACtE;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"keymap.d.ts","sourceRoot":"","sources":["../../src/core/keymap.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA6B3C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE;QACV;;;;;WAKG;QACH,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,CACnB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,KACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAoE7B,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACtE;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAmD3B,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACvE;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAgB3B,eAAO,MAAM,wBAAwB,EAAE,MAyBtC,CAAC;AAaF,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpE;;;GAGG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -22,4 +22,6 @@ export interface RdfaResourceAttrs extends RdfaAwareAttrs {
|
|
|
22
22
|
}
|
|
23
23
|
export type RdfaAttrs = RdfaLiteralAttrs | RdfaResourceAttrs;
|
|
24
24
|
export declare function isRdfaAttrs(attrs: Attrs): attrs is RdfaAttrs;
|
|
25
|
+
export declare function isResourceAttrs(attrs: RdfaAttrs): attrs is RdfaResourceAttrs;
|
|
26
|
+
export declare function isLiteralAttrs(attrs: RdfaAttrs): attrs is RdfaLiteralAttrs;
|
|
25
27
|
//# sourceMappingURL=rdfa-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdfa-types.d.ts","sourceRoot":"","sources":["../../src/core/rdfa-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,cAAc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ED,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO;IAMhD,oBAAoB,CAAC,UAAU,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,GACL,UAAU;CAEjE"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
import type { RdfaAttrs } from '#root/core/rdfa-types.js';
|
|
1
2
|
type Options = {
|
|
2
3
|
rdfaAware?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Migrations to apply to nodes parsed as inline-rdfa, to modify the data model.
|
|
6
|
+
* @returns false to use the default parsing or an object to define overrides
|
|
7
|
+
**/
|
|
8
|
+
modelMigrations?: (attrs: RdfaAttrs) => false | {
|
|
9
|
+
/** A modified contentElement function to allow for nested structures to be modified **/
|
|
10
|
+
contentElement?: (element: HTMLElement) => HTMLElement;
|
|
11
|
+
/** A modified getAttrs that returns attrs matching the new model **/
|
|
12
|
+
getAttrs?: (element: HTMLElement) => RdfaAttrs;
|
|
13
|
+
};
|
|
3
14
|
};
|
|
4
15
|
export declare const inlineRdfaWithConfig: (options?: Options) => import("../core/say-node-spec.ts").default;
|
|
5
16
|
export declare const inlineRdfaWithConfigView: (options?: Options) => (controller: import("../index.ts").SayController) => import("../utils/ember-node.ts").SayNodeViewConstructor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-rdfa.d.ts","sourceRoot":"","sources":["../../src/nodes/inline-rdfa.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inline-rdfa.d.ts","sourceRoot":"","sources":["../../src/nodes/inline-rdfa.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,KAAK,OAAO,GAAG;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;QAGI;IACJ,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAC/B,KAAK,GACL;QACE,wFAAwF;QACxF,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,WAAW,CAAC;QACvD,qEAAqE;QACrE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,CAAC;KAChD,CAAC;CACP,CAAC;AAwEF,eAAO,MAAM,oBAAoB,aAAc,OAAO,+CACP,CAAC;AAEhD,eAAO,MAAM,wBAAwB,aAAc,OAAO,iHACX,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-color.d.ts","sourceRoot":"","sources":["../../../../src/plugins/color/commands/set-color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"set-color.d.ts","sourceRoot":"","sources":["../../../../src/plugins/color/commands/set-color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAkB/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-highlight.d.ts","sourceRoot":"","sources":["../../../../src/plugins/highlight/commands/set-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"set-highlight.d.ts","sourceRoot":"","sources":["../../../../src/plugins/highlight/commands/set-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAkBnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-process-as-rdfa-nodes.d.ts","sourceRoot":"","sources":["../../../../src/utils/_private/rdfa-parser/post-process-as-rdfa-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvE,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,iBAAiB,EAAE,CACjB,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,kBAAkB,CAAC,EAAE,MAAM,KACxB,IAAI,CAAC;IACV,kBAAkB,EAAE,CAClB,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EACzD,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,gBAAgB,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EACpC,eAAe,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EACnC,eAAe,CAAC,EAAE,MAAM,KACrB,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgDI;AACJ,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"post-process-as-rdfa-nodes.d.ts","sourceRoot":"","sources":["../../../../src/utils/_private/rdfa-parser/post-process-as-rdfa-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvE,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,iBAAiB,EAAE,CACjB,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,kBAAkB,CAAC,EAAE,MAAM,KACxB,IAAI,CAAC;IACV,kBAAkB,EAAE,CAClB,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,EACzD,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,gBAAgB,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EACpC,eAAe,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EACnC,eAAe,CAAC,EAAE,MAAM,KACrB,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgDI;AACJ,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,CAuJ1E"}
|
|
@@ -12,6 +12,8 @@ import { markApplies, selectionHasMarkEverywhere, fromToWithoutEdgeSpaces } from
|
|
|
12
12
|
*
|
|
13
13
|
* @param markType
|
|
14
14
|
* @param attrs
|
|
15
|
+
*
|
|
16
|
+
* @deprecated Use the the `toggleMark` command with the `removeWhenPresent` option instead.
|
|
15
17
|
*/
|
|
16
18
|
function toggleMarkAddFirst(markType, attrs = null) {
|
|
17
19
|
return function (state, dispatch) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-mark-add-first.js","sources":["../../src/commands/toggle-mark-add-first.ts"],"sourcesContent":["import type { Attrs, MarkType } from 'prosemirror-model';\nimport type { Command, TextSelection } from 'prosemirror-state';\nimport { shallowEqual } from '#root/utils/_private/object-utils.ts';\nimport {\n fromToWithoutEdgeSpaces,\n markApplies,\n selectionHasMarkEverywhere,\n} from '#root/utils/_private/mark-utils.ts';\n\n/**\n * Adapted from https://github.com/ProseMirror/prosemirror-commands/blob/7635496296b2e561a5893b03154bd89c127a6972/src/commands.ts#L579\n * Create a command function that toggles the given mark with the\n * given attributes. Will return `false` when the current selection\n * doesn't support that mark. This adds the mark if any marks of that type\n * are missing in the selection, or remove it from the whole selection otherwise.* If the\n * selection is empty, this applies to the {@link EditorState#storedMarks stored marks}\n * instead of a range of the document.\n *\n * @param markType\n * @param attrs\n */\nexport function toggleMarkAddFirst(\n markType: MarkType,\n attrs: Attrs | null = null,\n): Command {\n return function (state, dispatch) {\n const { empty, $cursor, ranges } = state.selection as TextSelection;\n if ((empty && !$cursor) || !markApplies(state.doc, ranges, markType)) {\n return false;\n }\n if (dispatch) {\n if ($cursor) {\n const mark = markType.isInSet(state.storedMarks || $cursor.marks());\n if (mark && (!attrs || shallowEqual(attrs, mark.attrs))) {\n dispatch(state.tr.removeStoredMark(markType));\n } else {\n dispatch(state.tr.addStoredMark(markType.create(attrs)));\n }\n } else {\n const hasEverywhere = selectionHasMarkEverywhere(\n state.doc,\n state.selection,\n markType,\n attrs ?? undefined,\n );\n const tr = state.tr;\n for (let i = 0; i < ranges.length; i++) {\n const { $from, $to } = ranges[i];\n if (hasEverywhere) {\n tr.removeMark($from.pos, $to.pos, markType);\n } else {\n const { from, to } = fromToWithoutEdgeSpaces($from, $to);\n tr.addMark(from, to, markType.create(attrs));\n }\n }\n dispatch(tr.scrollIntoView());\n }\n }\n return true;\n };\n}\n"],"names":["toggleMarkAddFirst","markType","attrs","state","dispatch","empty","$cursor","ranges","selection","markApplies","doc","mark","isInSet","storedMarks","marks","shallowEqual","tr","removeStoredMark","addStoredMark","create","hasEverywhere","selectionHasMarkEverywhere","undefined","i","length","$from","$to","removeMark","pos","from","to","fromToWithoutEdgeSpaces","addMark","scrollIntoView"],"mappings":";;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,CAChCC,QAAkB,EAClBC,KAAmB,GAAG,IAAI,EACjB;AACT,EAAA,OAAO,UAAUC,KAAK,EAAEC,QAAQ,EAAE;IAChC,MAAM;MAAEC,KAAK;MAAEC,OAAO;AAAEC,MAAAA;KAAQ,GAAGJ,KAAK,CAACK,SAA0B;AACnE,IAAA,IAAKH,KAAK,IAAI,CAACC,OAAO,IAAK,CAACG,WAAW,CAACN,KAAK,CAACO,GAAG,EAAEH,MAAM,EAAEN,QAAQ,CAAC,EAAE;AACpE,MAAA,OAAO,KAAK;AACd;AACA,IAAA,IAAIG,QAAQ,EAAE;AACZ,MAAA,IAAIE,OAAO,EAAE;AACX,QAAA,MAAMK,IAAI,GAAGV,QAAQ,CAACW,OAAO,CAACT,KAAK,CAACU,WAAW,IAAIP,OAAO,CAACQ,KAAK,EAAE,CAAC;AACnE,QAAA,IAAIH,IAAI,KAAK,CAACT,KAAK,IAAIa,YAAY,CAACb,KAAK,EAAES,IAAI,CAACT,KAAK,CAAC,CAAC,EAAE;UACvDE,QAAQ,CAACD,KAAK,CAACa,EAAE,CAACC,gBAAgB,CAAChB,QAAQ,CAAC,CAAC;AAC/C,SAAC,MAAM;AACLG,UAAAA,QAAQ,CAACD,KAAK,CAACa,EAAE,CAACE,aAAa,CAACjB,QAAQ,CAACkB,MAAM,CAACjB,KAAK,CAAC,CAAC,CAAC;AAC1D;AACF,OAAC,MAAM;AACL,QAAA,MAAMkB,aAAa,GAAGC,0BAA0B,CAC9ClB,KAAK,CAACO,GAAG,EACTP,KAAK,CAACK,SAAS,EACfP,QAAQ,EACRC,KAAK,IAAIoB,SACX,CAAC;AACD,QAAA,MAAMN,EAAE,GAAGb,KAAK,CAACa,EAAE;AACnB,QAAA,KAAK,IAAIO,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGhB,MAAM,CAACiB,MAAM,EAAED,CAAC,EAAE,EAAE;UACtC,MAAM;YAAEE,KAAK;AAAEC,YAAAA;AAAI,WAAC,GAAGnB,MAAM,CAACgB,CAAC,CAAC;AAChC,UAAA,IAAIH,aAAa,EAAE;AACjBJ,YAAAA,EAAE,CAACW,UAAU,CAACF,KAAK,CAACG,GAAG,EAAEF,GAAG,CAACE,GAAG,EAAE3B,QAAQ,CAAC;AAC7C,WAAC,MAAM;YACL,MAAM;cAAE4B,IAAI;AAAEC,cAAAA;AAAG,aAAC,GAAGC,uBAAuB,CAACN,KAAK,EAAEC,GAAG,CAAC;AACxDV,YAAAA,EAAE,CAACgB,OAAO,CAACH,IAAI,EAAEC,EAAE,EAAE7B,QAAQ,CAACkB,MAAM,CAACjB,KAAK,CAAC,CAAC;AAC9C;AACF;AACAE,QAAAA,QAAQ,CAACY,EAAE,CAACiB,cAAc,EAAE,CAAC;AAC/B;AACF;AACA,IAAA,OAAO,IAAI;GACZ;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"toggle-mark-add-first.js","sources":["../../src/commands/toggle-mark-add-first.ts"],"sourcesContent":["import type { Attrs, MarkType } from 'prosemirror-model';\nimport type { Command, TextSelection } from 'prosemirror-state';\nimport { shallowEqual } from '#root/utils/_private/object-utils.ts';\nimport {\n fromToWithoutEdgeSpaces,\n markApplies,\n selectionHasMarkEverywhere,\n} from '#root/utils/_private/mark-utils.ts';\n\n/**\n * Adapted from https://github.com/ProseMirror/prosemirror-commands/blob/7635496296b2e561a5893b03154bd89c127a6972/src/commands.ts#L579\n * Create a command function that toggles the given mark with the\n * given attributes. Will return `false` when the current selection\n * doesn't support that mark. This adds the mark if any marks of that type\n * are missing in the selection, or remove it from the whole selection otherwise.* If the\n * selection is empty, this applies to the {@link EditorState#storedMarks stored marks}\n * instead of a range of the document.\n *\n * @param markType\n * @param attrs\n *\n * @deprecated Use the the `toggleMark` command with the `removeWhenPresent` option instead.\n */\nexport function toggleMarkAddFirst(\n markType: MarkType,\n attrs: Attrs | null = null,\n): Command {\n return function (state, dispatch) {\n const { empty, $cursor, ranges } = state.selection as TextSelection;\n if ((empty && !$cursor) || !markApplies(state.doc, ranges, markType)) {\n return false;\n }\n if (dispatch) {\n if ($cursor) {\n const mark = markType.isInSet(state.storedMarks || $cursor.marks());\n if (mark && (!attrs || shallowEqual(attrs, mark.attrs))) {\n dispatch(state.tr.removeStoredMark(markType));\n } else {\n dispatch(state.tr.addStoredMark(markType.create(attrs)));\n }\n } else {\n const hasEverywhere = selectionHasMarkEverywhere(\n state.doc,\n state.selection,\n markType,\n attrs ?? undefined,\n );\n const tr = state.tr;\n for (let i = 0; i < ranges.length; i++) {\n const { $from, $to } = ranges[i];\n if (hasEverywhere) {\n tr.removeMark($from.pos, $to.pos, markType);\n } else {\n const { from, to } = fromToWithoutEdgeSpaces($from, $to);\n tr.addMark(from, to, markType.create(attrs));\n }\n }\n dispatch(tr.scrollIntoView());\n }\n }\n return true;\n };\n}\n"],"names":["toggleMarkAddFirst","markType","attrs","state","dispatch","empty","$cursor","ranges","selection","markApplies","doc","mark","isInSet","storedMarks","marks","shallowEqual","tr","removeStoredMark","addStoredMark","create","hasEverywhere","selectionHasMarkEverywhere","undefined","i","length","$from","$to","removeMark","pos","from","to","fromToWithoutEdgeSpaces","addMark","scrollIntoView"],"mappings":";;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AK;AAAEC,YAAAA;AAAI,WAAC,GAAGnB,MAAM,CAACgB,CAAC,CAAC;AAChC,UAAA,IAAIH,aAAa,EAAE;AACjBJ,YAAAA,EAAE,CAACW,UAAU,CAACF,KAAK,CAACG,GAAG,EAAEF,GAAG,CAACE,GAAG,EAAE3B,QAAQ,CAAC;AAC7C,WAAC,MAAM;YACL,MAAM;cAAE4B,IAAI;AAAEC,cAAAA;AAAG,aAAC,GAAGC,uBAAuB,CAACN,KAAK,EAAEC,GAAG,CAAC;AACxDV,YAAAA,EAAE,CAACgB,OAAO,CAACH,IAAI,EAAEC,EAAE,EAAE7B,QAAQ,CAACkB,MAAM,CAACjB,KAAK,CAAC,CAAC;AAC9C;AACF;AACAE,QAAAA,QAAQ,CAACY,EAAE,CAACiB,cAAc,EAAE,CAAC;AAC/B;AACF;AACA,IAAA,OAAO,IAAI;GACZ;AACH;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { action } from '@ember/object';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
|
-
import 'prosemirror-commands';
|
|
3
|
+
import { toggleMark } from 'prosemirror-commands';
|
|
4
4
|
import '../../utils/_private/constants.js';
|
|
5
5
|
import 'prosemirror-model';
|
|
6
6
|
import 'uuid';
|
|
@@ -14,7 +14,6 @@ import 'iter-tools';
|
|
|
14
14
|
import 'prosemirror-state';
|
|
15
15
|
import 'prosemirror-transform';
|
|
16
16
|
import '@curvenote/prosemirror-utils';
|
|
17
|
-
import { toggleMarkAddFirst } from '../../commands/toggle-mark-add-first.js';
|
|
18
17
|
import '../../plugin-D1qUAML5.js';
|
|
19
18
|
import 'prosemirror-view';
|
|
20
19
|
import '../../plugins/gap-cursor/gap-cursor.js';
|
|
@@ -41,12 +40,16 @@ class ToolbarMark extends Component {
|
|
|
41
40
|
return this.controller && this.mark && this.controller.isMarkActive(this.mark);
|
|
42
41
|
}
|
|
43
42
|
get canToggle() {
|
|
44
|
-
return this.controller && this.mark && this.controller.checkCommand(
|
|
43
|
+
return this.controller && this.mark && this.controller.checkCommand(toggleMark(this.mark, null, {
|
|
44
|
+
removeWhenPresent: false
|
|
45
|
+
}));
|
|
45
46
|
}
|
|
46
47
|
toggle() {
|
|
47
48
|
if (this.controller && this.mark) {
|
|
48
49
|
this.controller.focus();
|
|
49
|
-
this.controller.doCommand(
|
|
50
|
+
this.controller.doCommand(toggleMark(this.mark, null, {
|
|
51
|
+
removeWhenPresent: false
|
|
52
|
+
}));
|
|
50
53
|
this.args.onActivate?.();
|
|
51
54
|
}
|
|
52
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mark.js","sources":["../../../src/components/toolbar/mark.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport Component from '@glimmer/component';\nimport type { MarkType } from 'prosemirror-model';\nimport type { ComponentLike } from '@glint/template';\nimport {
|
|
1
|
+
{"version":3,"file":"mark.js","sources":["../../../src/components/toolbar/mark.gts"],"sourcesContent":["import { action } from '@ember/object';\nimport Component from '@glimmer/component';\nimport type { MarkType } from 'prosemirror-model';\nimport type { ComponentLike } from '@glint/template';\nimport { toggleMark } from '#root/commands/index.ts';\nimport SayController from '#root/core/say-controller.ts';\nimport { not } from 'ember-truth-helpers';\nimport { on } from '@ember/modifier';\nimport ToolbarButton from './button.gts';\n\ntype Signature = {\n Args: {\n controller?: SayController;\n mark: string;\n icon: ComponentLike<{ Element: Element }>;\n title: string;\n onActivate?: () => void;\n };\n};\n\nexport default class ToolbarMark extends Component<Signature> {\n get controller() {\n return this.args.controller;\n }\n\n get mark(): MarkType | undefined {\n if (\n !this.controller ||\n !this.controller.activeEditorState.schema.marks[this.args.mark]\n ) {\n console.error(\n `Can't find mark '${this.args.mark}', did you add it to your schema?`,\n );\n return;\n }\n return this.controller.activeEditorState.schema.marks[this.args.mark];\n }\n\n get isActive() {\n return (\n this.controller && this.mark && this.controller.isMarkActive(this.mark)\n );\n }\n\n get canToggle() {\n return (\n this.controller &&\n this.mark &&\n this.controller.checkCommand(\n toggleMark(this.mark, null, { removeWhenPresent: false }),\n )\n );\n }\n\n @action\n toggle() {\n if (this.controller && this.mark) {\n this.controller.focus();\n this.controller.doCommand(\n toggleMark(this.mark, null, { removeWhenPresent: false }),\n );\n this.args.onActivate?.();\n }\n }\n\n <template>\n {{#if @controller}}\n <ToolbarButton\n @controller={{@controller}}\n @active={{this.isActive}}\n @title={{@title}}\n @icon={{@icon}}\n @disabled={{not this.canToggle}}\n {{on \"click\" this.toggle}}\n />\n {{/if}}\n </template>\n}\n"],"names":["ToolbarMark","Component","controller","args","mark","activeEditorState","schema","marks","console","error","isActive","isMarkActive","canToggle","checkCommand","toggleMark","removeWhenPresent","toggle","focus","doCommand","onActivate","n","prototype","action","setComponentTemplate","precompileTemplate","strictMode","scope","ToolbarButton","not","on"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBe,MAAMA,oBAAoBC,SAAU,CAAA;EACjD,IAAIC,UAAaA,GAAA;AACf,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,UAAU;AAC7B;EAEA,IAAIE,IAAAA,GAA6B;IAC/B,IACE,CAAC,IAAI,CAACF,UAAU,IAChB,CAAC,IAAI,CAACA,UAAU,CAACG,iBAAiB,CAACC,MAAM,CAACC,KAAK,CAAC,IAAI,CAACJ,IAAI,CAACC,IAAI,CAAC,EAC/D;MACAI,OAAA,CAAQC,KAAK,CACX,CAAoB,iBAAA,EAAA,IAAI,CAACN,IAAI,CAACC,IAAI,CAAA,iCAAA,CAAmC,CAAA;AAEvE,MAAA;AACF;AACA,IAAA,OAAO,IAAI,CAACF,UAAU,CAACG,iBAAiB,CAACC,MAAM,CAACC,KAAK,CAAC,IAAI,CAACJ,IAAI,CAACC,IAAI,CAAC;AACvE;EAEA,IAAIM,QAAWA,GAAA;AACb,IAAA,OACE,IAAI,CAACR,UAAU,IAAI,IAAI,CAACE,IAAI,IAAI,IAAI,CAACF,UAAU,CAACS,YAAY,CAAC,IAAI,CAACP,IAAI,CACxE;AACF;EAEA,IAAIQ,SAAYA,GAAA;IACd,OACE,IAAI,CAACV,UAAU,IACf,IAAI,CAACE,IAAI,IACT,IAAI,CAACF,UAAU,CAACW,YAAY,CAC1BC,UAAA,CAAW,IAAI,CAACV,IAAI,EAAE,IAAM,EAAA;AAAEW,MAAAA,iBAAmB,EAAA;AAAM,KAE3D,CAAA,CAAA;AACF;AAGAC,EAAAA,MAASA,GAAA;AACP,IAAA,IAAI,IAAI,CAACd,UAAU,IAAI,IAAI,CAACE,IAAI,EAAE;AAChC,MAAA,IAAI,CAACF,UAAU,CAACe,KAAK,EAAA;AACrB,MAAA,IAAI,CAACf,UAAU,CAACgB,SAAS,CACvBJ,WAAW,IAAI,CAACV,IAAI,EAAE,IAAM,EAAA;AAAEW,QAAAA,iBAAmB,EAAA;AAAM,OAAA,CAAA,CAAA;AAEzD,MAAA,IAAI,CAACZ,IAAI,CAACgB,UAAU,IAAA;AACtB;AACF;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CATCC,MAAA,CAAA,CAAA;AAAA;AAWD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAWA,2NAAA,EAAA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,aAAA;QAAAC,GAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
package/dist/core/keymap.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { redo, undo } from 'prosemirror-history';
|
|
2
2
|
import { liftListItem, sinkListItem, splitListItem } from 'prosemirror-schema-list';
|
|
3
3
|
import 'prosemirror-model';
|
|
4
|
-
import {
|
|
5
|
-
import { chainCommands, deleteSelection, joinForward, selectTextblockEnd, selectTextblockStart, selectAll, exitCode, newlineInCode, createParagraphNear, splitBlock, joinBackward, liftEmptyBlock } from 'prosemirror-commands';
|
|
4
|
+
import { chainCommands, deleteSelection, joinForward, selectTextblockEnd, selectTextblockStart, selectAll, exitCode, toggleMark, newlineInCode, createParagraphNear, splitBlock, joinBackward, liftEmptyBlock } from 'prosemirror-commands';
|
|
6
5
|
import { insertHardBreak } from '../commands/insert-hard-break.js';
|
|
7
6
|
import '../utils/_private/constants.js';
|
|
8
7
|
import 'uuid';
|
|
@@ -88,12 +87,24 @@ function pcBaseKeymap(schema, options) {
|
|
|
88
87
|
'Mod-Z': undo,
|
|
89
88
|
'Mod-y': redo,
|
|
90
89
|
'Mod-Y': redo,
|
|
91
|
-
'Mod-b':
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
'Mod-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
'Mod-b': toggleMark(schema.marks['strong'], null, {
|
|
91
|
+
removeWhenPresent: false
|
|
92
|
+
}),
|
|
93
|
+
'Mod-B': toggleMark(schema.marks['strong'], null, {
|
|
94
|
+
removeWhenPresent: false
|
|
95
|
+
}),
|
|
96
|
+
'Mod-i': toggleMark(schema.marks['em'], null, {
|
|
97
|
+
removeWhenPresent: false
|
|
98
|
+
}),
|
|
99
|
+
'Mod-I': toggleMark(schema.marks['em'], null, {
|
|
100
|
+
removeWhenPresent: false
|
|
101
|
+
}),
|
|
102
|
+
'Mod-u': toggleMark(schema.marks['underline'], null, {
|
|
103
|
+
removeWhenPresent: false
|
|
104
|
+
}),
|
|
105
|
+
'Mod-U': toggleMark(schema.marks['underline'], null, {
|
|
106
|
+
removeWhenPresent: false
|
|
107
|
+
}),
|
|
97
108
|
Enter: chainCommands(splitListItem(schema.nodes['list_item']), newlineInCode, createParagraphNear, liftEmptyBlockChecked, splitBlock, insertHardBreak),
|
|
98
109
|
'Shift-Enter': chainCommands(exitCode, insertHardBreak),
|
|
99
110
|
'Mod-Enter': exitCode,
|
|
@@ -147,12 +158,24 @@ function macBaseKeymap(schema, options) {
|
|
|
147
158
|
}
|
|
148
159
|
const embeddedEditorBaseKeymap = schema => {
|
|
149
160
|
return {
|
|
150
|
-
'Mod-b':
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
'Mod-
|
|
154
|
-
|
|
155
|
-
|
|
161
|
+
'Mod-b': toggleMark(schema.marks['strong'], null, {
|
|
162
|
+
removeWhenPresent: false
|
|
163
|
+
}),
|
|
164
|
+
'Mod-B': toggleMark(schema.marks['strong'], null, {
|
|
165
|
+
removeWhenPresent: false
|
|
166
|
+
}),
|
|
167
|
+
'Mod-i': toggleMark(schema.marks['em'], null, {
|
|
168
|
+
removeWhenPresent: false
|
|
169
|
+
}),
|
|
170
|
+
'Mod-I': toggleMark(schema.marks['em'], null, {
|
|
171
|
+
removeWhenPresent: false
|
|
172
|
+
}),
|
|
173
|
+
'Mod-u': toggleMark(schema.marks['underline'], null, {
|
|
174
|
+
removeWhenPresent: false
|
|
175
|
+
}),
|
|
176
|
+
'Mod-U': toggleMark(schema.marks['underline'], null, {
|
|
177
|
+
removeWhenPresent: false
|
|
178
|
+
}),
|
|
156
179
|
Enter: chainCommands(newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock, insertHardBreak),
|
|
157
180
|
'Shift-Enter': chainCommands(exitCode, insertHardBreak)
|
|
158
181
|
};
|
package/dist/core/keymap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keymap.js","sources":["../../src/core/keymap.ts"],"sourcesContent":["import { redo, undo } from 'prosemirror-history';\nimport {\n liftListItem,\n sinkListItem,\n splitListItem,\n} from 'prosemirror-schema-list';\nimport type { Command } from 'prosemirror-state';\nimport { Schema } from 'prosemirror-model';\nimport { toggleMarkAddFirst } from '#root/commands/toggle-mark-add-first.ts';\nimport {\n chainCommands,\n createParagraphNear,\n deleteSelection,\n exitCode,\n joinBackward,\n joinForward,\n liftEmptyBlock,\n newlineInCode,\n selectAll,\n selectTextblockEnd,\n selectTextblockStart,\n splitBlock,\n} from 'prosemirror-commands';\nimport {\n insertHardBreak,\n reduceIndent,\n liftEmptyBlockChecked,\n selectNodeBackward,\n selectNodeForward,\n selectBlockRdfaNode,\n} from '#root/commands/index.ts';\nimport selectParentNodeOfType from '../commands/select-parent-node-of-type.ts';\nimport { hasParentNodeOfType } from '@curvenote/prosemirror-utils';\nimport { undoInputRule } from 'prosemirror-inputrules';\nimport { setAlignment } from '../plugins/alignment/commands.ts';\n\n/**\n * @deprecated KeymapOptions is deprecated.\n * The behaviour of `selectBlockRdfaNode` is now enabled by default.\n */\nexport type KeymapOptions = {\n backspace?: {\n /**\n * Enables alternative behaviour for backspace.\n * Instead of deleting into the preceding block_rdfa node, it will select the preceding block_rdfa node.\n *\n * `block_rdfa` node has to enhanced with `isolating: true, selectable: true` in the schema.\n */\n selectBlockRdfaNode: boolean;\n };\n};\n\nexport type Keymap = (\n schema: Schema,\n options?: KeymapOptions,\n) => Record<string, Command>;\n\nconst backspaceBase: Command[] = [\n undoInputRule,\n reduceIndent,\n deleteSelection,\n (state, dispatch, view) => {\n const isInTable = hasParentNodeOfType(state.schema.nodes['table'])(\n state.selection,\n );\n if (joinBackward(state, dispatch) && dispatch && view) {\n const { state } = view;\n if (!isInTable) {\n selectParentNodeOfType(state.schema.nodes['table'])(\n state,\n dispatch,\n view,\n );\n }\n return true;\n }\n return false;\n },\n selectNodeBackward,\n];\n\nconst getBackspaceCommand = (options?: KeymapOptions) => {\n if (options?.backspace?.selectBlockRdfaNode) {\n return chainCommands(selectBlockRdfaNode, ...backspaceBase);\n }\n\n return chainCommands(...backspaceBase);\n};\n\nconst del = chainCommands(\n deleteSelection,\n (state, dispatch, view) => {\n const isInTable = hasParentNodeOfType(state.schema.nodes['table'])(\n state.selection,\n );\n if (joinForward(state, dispatch) && dispatch && view) {\n const { state } = view;\n if (!isInTable) {\n selectParentNodeOfType(state.schema.nodes['table'])(\n state,\n dispatch,\n view,\n );\n }\n return true;\n }\n return false;\n },\n selectNodeForward,\n);\n/// A basic keymap containing bindings not specific to any schema.\n/// Binds the following keys (when multiple commands are listed, they\n/// are chained with [`chainCommands`](#commands.chainCommands)):\n///\n/// * **Enter** to `newlineInCode`, `createParagraphNear`, `liftEmptyBlock`, `splitBlock`\n/// * **Mod-Enter** to `exitCode`\n/// * **Backspace** and **Mod-Backspace** to `deleteSelection`, `joinBackward`, `selectNodeBackward`\n/// * **Delete** and **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`\n/// * **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`\n/// * **Mod-a** to `selectAll`\n///\n/// `undo` and `redo` pc keybindings are overwritten in embedded-controller!\n\nexport function pcBaseKeymap(schema: Schema): Record<string, Command>;\n/**\n * @deprecated providing the `options` argument to `pcBaseKeymap` is deprecated.\n * The behaviour of `selectBlockRdfaNode` is included by default.\n */\nexport function pcBaseKeymap(\n schema: Schema,\n options?: KeymapOptions,\n): Record<string, Command>;\nexport function pcBaseKeymap(schema: Schema, options?: KeymapOptions) {\n return {\n 'Mod-z': undo,\n 'Mod-Z': undo,\n 'Mod-y': redo,\n 'Mod-Y': redo,\n 'Mod-b': toggleMarkAddFirst(schema.marks['strong']),\n 'Mod-B': toggleMarkAddFirst(schema.marks['strong']),\n 'Mod-i': toggleMarkAddFirst(schema.marks['em']),\n 'Mod-I': toggleMarkAddFirst(schema.marks['em']),\n 'Mod-u': toggleMarkAddFirst(schema.marks['underline']),\n 'Mod-U': toggleMarkAddFirst(schema.marks['underline']),\n Enter: chainCommands(\n splitListItem(schema.nodes['list_item']),\n newlineInCode,\n createParagraphNear,\n liftEmptyBlockChecked,\n splitBlock,\n insertHardBreak,\n ),\n 'Shift-Enter': chainCommands(exitCode, insertHardBreak),\n 'Mod-Enter': exitCode,\n Backspace: getBackspaceCommand(options),\n 'Mod-Backspace': getBackspaceCommand(options),\n 'Shift-Backspace': getBackspaceCommand(options),\n Delete: del,\n 'Mod-Delete': del,\n 'Mod-a': selectAll,\n Tab: sinkListItem(schema.nodes['list_item']),\n 'Shift-Tab': liftListItem(schema.nodes['list_item']),\n // Alignment shortcuts\n 'Mod-Shift-L': setAlignment({ option: 'left' }),\n 'Mod-Shift-E': setAlignment({ option: 'center' }),\n 'Mod-Shift-R': setAlignment({ option: 'right' }),\n 'Mod-Shift-J': setAlignment({ option: 'justify' }),\n };\n}\n\n/// A copy of `pcBaseKeymap` that also binds **Ctrl-h** like Backspace,\n/// **Ctrl-d** like Delete, **Alt-Backspace** like Ctrl-Backspace, and\n/// **Ctrl-Alt-Backspace**, **Alt-Delete**, and **Alt-d** like\n/// Ctrl-Delete.\nexport function macBaseKeymap(schema: Schema): Record<string, Command>;\n/**\n * @deprecated providing the `options` argument to `macBaseKeymap` is deprecated.\n * The behaviour of `selectBlockRdfaNode` is included by default.\n */\nexport function macBaseKeymap(\n schema: Schema,\n options?: KeymapOptions,\n): Record<string, Command>;\nexport function macBaseKeymap(schema: Schema, options?: KeymapOptions) {\n const pcmap = pcBaseKeymap(schema, options);\n return {\n ...pcmap,\n 'Ctrl-h': pcmap['Backspace'],\n 'Alt-Backspace': pcmap['Mod-Backspace'],\n 'Ctrl-d': pcmap['Delete'],\n 'Ctrl-Alt-Backspace': pcmap['Mod-Delete'],\n 'Alt-Delete': pcmap['Mod-Delete'],\n 'Alt-d': pcmap['Mod-Delete'],\n 'Ctrl-a': selectTextblockStart,\n 'Ctrl-e': selectTextblockEnd,\n };\n}\n\nexport const embeddedEditorBaseKeymap: Keymap = (schema) => {\n return {\n 'Mod-b': toggleMarkAddFirst(schema.marks['strong']),\n 'Mod-B': toggleMarkAddFirst(schema.marks['strong']),\n 'Mod-i': toggleMarkAddFirst(schema.marks['em']),\n 'Mod-I': toggleMarkAddFirst(schema.marks['em']),\n 'Mod-u': toggleMarkAddFirst(schema.marks['underline']),\n 'Mod-U': toggleMarkAddFirst(schema.marks['underline']),\n Enter: chainCommands(\n newlineInCode,\n createParagraphNear,\n liftEmptyBlock,\n splitBlock,\n insertHardBreak,\n ),\n 'Shift-Enter': chainCommands(exitCode, insertHardBreak),\n };\n};\n\ndeclare const os: { platform?(): string } | undefined;\nlet mac: boolean;\nif (typeof navigator !== 'undefined') {\n mac = /Mac|iP(hone|[oa]d)/.test(navigator.platform);\n} else {\n if (typeof os !== 'undefined' && os.platform) {\n mac = os.platform() === 'darwin';\n } else {\n mac = false;\n }\n}\nexport function baseKeymap(schema: Schema): Record<string, Command>;\n/**\n * @deprecated providing the `options` argument to `baseKeymap` is deprecated.\n * The behaviour of `selectBlockRdfaNode` is included by default.\n */\nexport function baseKeymap(\n schema: Schema,\n options?: KeymapOptions,\n): Record<string, Command>;\nexport function baseKeymap(schema: Schema, options?: KeymapOptions) {\n return mac ? macBaseKeymap(schema, options) : pcBaseKeymap(schema, options);\n}\n"],"names":["backspaceBase","undoInputRule","reduceIndent","deleteSelection","state","dispatch","view","isInTable","hasParentNodeOfType","schema","nodes","selection","joinBackward","selectParentNodeOfType","selectNodeBackward","getBackspaceCommand","options","backspace","selectBlockRdfaNode","chainCommands","del","joinForward","selectNodeForward","pcBaseKeymap","undo","redo","toggleMarkAddFirst","marks","Enter","splitListItem","newlineInCode","createParagraphNear","liftEmptyBlockChecked","splitBlock","insertHardBreak","exitCode","Backspace","Delete","selectAll","Tab","sinkListItem","liftListItem","setAlignment","option","macBaseKeymap","pcmap","selectTextblockStart","selectTextblockEnd","embeddedEditorBaseKeymap","liftEmptyBlock","mac","navigator","test","platform","os","baseKeymap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;AACA;AACA;AACA;;AAkBA,MAAMA,aAAwB,GAAG,CAC/BC,aAAa,EACbC,YAAY,EACZC,eAAe,EACf,CAACC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;AACzB,EAAA,MAAMC,SAAS,GAAGC,mBAAmB,CAACJ,KAAK,CAACK,MAAM,CAACC,KAAK,CAAC,OAAO,CAAC,CAAC,CAChEN,KAAK,CAACO,SACR,CAAC;EACD,IAAIC,YAAY,CAACR,KAAK,EAAEC,QAAQ,CAAC,IAAIA,QAAQ,IAAIC,IAAI,EAAE;IACrD,MAAM;AAAEF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,CAAC,CAAC;IAC/C,OAAO,EAAED,kBAAkB,CAACjB,MAAM,CAACkB,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAED,kBAAkB,CAACjB,MAAM,CAACkB,KAAK,CAAC,WAAW,CAAC,CAAC;IACtD,OAAO,EAAED,kBAAkB,CAACjB,MAAM,CAACkB,KAAK,CAAC,WAAW,CAAC,CAAC;AACtDC,IAAAA,KAAK,EAAET,aAAa,CAClBW,aAAa,EACbC,mBAAmB,EACnBkB,cAAc,EACdhB,UAAU,EACVC,eACF,CAAC;AACD,IAAA,aAAa,EAAEf,aAAa,CAACgB,QAAQ,EAAED,eAAe;GACvD;AACH;AAGA,IAAIgB,GAAY;AAChB,IAAI,OAAOC,SAAS,KAAK,WAAW,EAAE;EACpCD,GAAG,GAAG,oBAAoB,CAACE,IAAI,CAACD,SAAS,CAACE,QAAQ,CAAC;AACrD,CAAC,MAAM;EACL,IAAI,OAAOC,EAAE,KAAK,WAAW,IAAIA,EAAE,CAACD,QAAQ,EAAE;AAC5CH,IAAAA,GAAG,GAAGI,EAAE,CAACD,QAAQ,EAAE,KAAK,QAAQ;AAClC,GAAC,MAAM;AACLH,IAAAA,GAAG,GAAG,KAAK;AACb;AACF;;AAEA;AACA;AACA;AACA;;AAKO,SAASK,UAAUA,CAAC9C,MAAc,EAAEO,OAAuB,EAAE;AAClE,EAAA,OAAOkC,GAAG,GAAGN,aAAa,CAACnC,MAAM,EAAEO,OAAO,CAAC,GAAGO,YAAY,CAACd,MAAM,EAAEO,OAAO,CAAC;AAC7E;;;;"}
|
|
1
|
+
{"version":3,"file":"keymap.js","sources":["../../src/core/keymap.ts"],"sourcesContent":["import { redo, undo } from 'prosemirror-history';\nimport {\n liftListItem,\n sinkListItem,\n splitListItem,\n} from 'prosemirror-schema-list';\nimport type { Command } from 'prosemirror-state';\nimport { Schema } from 'prosemirror-model';\nimport {\n chainCommands,\n createParagraphNear,\n deleteSelection,\n exitCode,\n joinBackward,\n joinForward,\n liftEmptyBlock,\n newlineInCode,\n selectAll,\n selectTextblockEnd,\n selectTextblockStart,\n splitBlock,\n toggleMark,\n} from 'prosemirror-commands';\nimport {\n insertHardBreak,\n reduceIndent,\n liftEmptyBlockChecked,\n selectNodeBackward,\n selectNodeForward,\n selectBlockRdfaNode,\n} from '#root/commands/index.ts';\nimport selectParentNodeOfType from '../commands/select-parent-node-of-type.ts';\nimport { hasParentNodeOfType } from '@curvenote/prosemirror-utils';\nimport { undoInputRule } from 'prosemirror-inputrules';\nimport { setAlignment } from '../plugins/alignment/commands.ts';\n\n/**\n * @deprecated KeymapOptions is deprecated.\n * The behaviour of `selectBlockRdfaNode` is now enabled by default.\n */\nexport type KeymapOptions = {\n backspace?: {\n /**\n * Enables alternative behaviour for backspace.\n * Instead of deleting into the preceding block_rdfa node, it will select the preceding block_rdfa node.\n *\n * `block_rdfa` node has to enhanced with `isolating: true, selectable: true` in the schema.\n */\n selectBlockRdfaNode: boolean;\n };\n};\n\nexport type Keymap = (\n schema: Schema,\n options?: KeymapOptions,\n) => Record<string, Command>;\n\nconst backspaceBase: Command[] = [\n undoInputRule,\n reduceIndent,\n deleteSelection,\n (state, dispatch, view) => {\n const isInTable = hasParentNodeOfType(state.schema.nodes['table'])(\n state.selection,\n );\n if (joinBackward(state, dispatch) && dispatch && view) {\n const { state } = view;\n if (!isInTable) {\n selectParentNodeOfType(state.schema.nodes['table'])(\n state,\n dispatch,\n view,\n );\n }\n return true;\n }\n return false;\n },\n selectNodeBackward,\n];\n\nconst getBackspaceCommand = (options?: KeymapOptions) => {\n if (options?.backspace?.selectBlockRdfaNode) {\n return chainCommands(selectBlockRdfaNode, ...backspaceBase);\n }\n\n return chainCommands(...backspaceBase);\n};\n\nconst del = chainCommands(\n deleteSelection,\n (state, dispatch, view) => {\n const isInTable = hasParentNodeOfType(state.schema.nodes['table'])(\n state.selection,\n );\n if (joinForward(state, dispatch) && dispatch && view) {\n const { state } = view;\n if (!isInTable) {\n selectParentNodeOfType(state.schema.nodes['table'])(\n state,\n dispatch,\n view,\n );\n }\n return true;\n }\n return false;\n },\n selectNodeForward,\n);\n/// A basic keymap containing bindings not specific to any schema.\n/// Binds the following keys (when multiple commands are listed, they\n/// are chained with [`chainCommands`](#commands.chainCommands)):\n///\n/// * **Enter** to `newlineInCode`, `createParagraphNear`, `liftEmptyBlock`, `splitBlock`\n/// * **Mod-Enter** to `exitCode`\n/// * **Backspace** and **Mod-Backspace** to `deleteSelection`, `joinBackward`, `selectNodeBackward`\n/// * **Delete** and **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`\n/// * **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`\n/// * **Mod-a** to `selectAll`\n///\n/// `undo` and `redo` pc keybindings are overwritten in embedded-controller!\n\nexport function pcBaseKeymap(schema: Schema): Record<string, Command>;\n/**\n * @deprecated providing the `options` argument to `pcBaseKeymap` is deprecated.\n * The behaviour of `selectBlockRdfaNode` is included by default.\n */\nexport function pcBaseKeymap(\n schema: Schema,\n options?: KeymapOptions,\n): Record<string, Command>;\nexport function pcBaseKeymap(schema: Schema, options?: KeymapOptions) {\n return {\n 'Mod-z': undo,\n 'Mod-Z': undo,\n 'Mod-y': redo,\n 'Mod-Y': redo,\n 'Mod-b': toggleMark(schema.marks['strong'], null, {\n removeWhenPresent: false,\n }),\n 'Mod-B': toggleMark(schema.marks['strong'], null, {\n removeWhenPresent: false,\n }),\n 'Mod-i': toggleMark(schema.marks['em'], null, { removeWhenPresent: false }),\n 'Mod-I': toggleMark(schema.marks['em'], null, { removeWhenPresent: false }),\n 'Mod-u': toggleMark(schema.marks['underline'], null, {\n removeWhenPresent: false,\n }),\n 'Mod-U': toggleMark(schema.marks['underline'], null, {\n removeWhenPresent: false,\n }),\n Enter: chainCommands(\n splitListItem(schema.nodes['list_item']),\n newlineInCode,\n createParagraphNear,\n liftEmptyBlockChecked,\n splitBlock,\n insertHardBreak,\n ),\n 'Shift-Enter': chainCommands(exitCode, insertHardBreak),\n 'Mod-Enter': exitCode,\n Backspace: getBackspaceCommand(options),\n 'Mod-Backspace': getBackspaceCommand(options),\n 'Shift-Backspace': getBackspaceCommand(options),\n Delete: del,\n 'Mod-Delete': del,\n 'Mod-a': selectAll,\n Tab: sinkListItem(schema.nodes['list_item']),\n 'Shift-Tab': liftListItem(schema.nodes['list_item']),\n // Alignment shortcuts\n 'Mod-Shift-L': setAlignment({ option: 'left' }),\n 'Mod-Shift-E': setAlignment({ option: 'center' }),\n 'Mod-Shift-R': setAlignment({ option: 'right' }),\n 'Mod-Shift-J': setAlignment({ option: 'justify' }),\n };\n}\n\n/// A copy of `pcBaseKeymap` that also binds **Ctrl-h** like Backspace,\n/// **Ctrl-d** like Delete, **Alt-Backspace** like Ctrl-Backspace, and\n/// **Ctrl-Alt-Backspace**, **Alt-Delete**, and **Alt-d** like\n/// Ctrl-Delete.\nexport function macBaseKeymap(schema: Schema): Record<string, Command>;\n/**\n * @deprecated providing the `options` argument to `macBaseKeymap` is deprecated.\n * The behaviour of `selectBlockRdfaNode` is included by default.\n */\nexport function macBaseKeymap(\n schema: Schema,\n options?: KeymapOptions,\n): Record<string, Command>;\nexport function macBaseKeymap(schema: Schema, options?: KeymapOptions) {\n const pcmap = pcBaseKeymap(schema, options);\n return {\n ...pcmap,\n 'Ctrl-h': pcmap['Backspace'],\n 'Alt-Backspace': pcmap['Mod-Backspace'],\n 'Ctrl-d': pcmap['Delete'],\n 'Ctrl-Alt-Backspace': pcmap['Mod-Delete'],\n 'Alt-Delete': pcmap['Mod-Delete'],\n 'Alt-d': pcmap['Mod-Delete'],\n 'Ctrl-a': selectTextblockStart,\n 'Ctrl-e': selectTextblockEnd,\n };\n}\n\nexport const embeddedEditorBaseKeymap: Keymap = (schema) => {\n return {\n 'Mod-b': toggleMark(schema.marks['strong'], null, {\n removeWhenPresent: false,\n }),\n 'Mod-B': toggleMark(schema.marks['strong'], null, {\n removeWhenPresent: false,\n }),\n 'Mod-i': toggleMark(schema.marks['em'], null, { removeWhenPresent: false }),\n 'Mod-I': toggleMark(schema.marks['em'], null, { removeWhenPresent: false }),\n 'Mod-u': toggleMark(schema.marks['underline'], null, {\n removeWhenPresent: false,\n }),\n 'Mod-U': toggleMark(schema.marks['underline'], null, {\n removeWhenPresent: false,\n }),\n Enter: chainCommands(\n newlineInCode,\n createParagraphNear,\n liftEmptyBlock,\n splitBlock,\n insertHardBreak,\n ),\n 'Shift-Enter': chainCommands(exitCode, insertHardBreak),\n };\n};\n\ndeclare const os: { platform?(): string } | undefined;\nlet mac: boolean;\nif (typeof navigator !== 'undefined') {\n mac = /Mac|iP(hone|[oa]d)/.test(navigator.platform);\n} else {\n if (typeof os !== 'undefined' && os.platform) {\n mac = os.platform() === 'darwin';\n } else {\n mac = false;\n }\n}\nexport function baseKeymap(schema: Schema): Record<string, Command>;\n/**\n * @deprecated providing the `options` argument to `baseKeymap` is deprecated.\n * The behaviour of `selectBlockRdfaNode` is included by default.\n */\nexport function baseKeymap(\n schema: Schema,\n options?: KeymapOptions,\n): Record<string, Command>;\nexport function baseKeymap(schema: Schema, options?: KeymapOptions) {\n return mac ? macBaseKeymap(schema, options) : pcBaseKeymap(schema, options);\n}\n"],"names":["backspaceBase","undoInputRule","reduceIndent","deleteSelection","state","dispatch","view","isInTable","hasParentNodeOfType","schema","nodes","selection","joinBackward","selectParentNodeOfType","selectNodeBackward","getBackspaceCommand","options","backspace","selectBlockRdfaNode","chainCommands","del","joinForward","selectNodeForward","pcBaseKeymap","undo","redo","toggleMark","marks","removeWhenPresent","Enter","splitListItem","newlineInCode","createParagraphNear","liftEmptyBlockChecked","splitBlock","insertHardBreak","exitCode","Backspace","Delete","selectAll","Tab","sinkListItem","liftListItem","setAlignment","option","macBaseKeymap","pcmap","selectTextblockStart","selectTextblockEnd","embeddedEditorBaseKeymap","liftEmptyBlock","mac","navigator","test","platform","os","baseKeymap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;AACA;AACA;AACA;;AAkBA,MAAMA,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A,iBAAiB,EAAE;AACrB,KAAC,CAAC;AACFC,IAAAA,KAAK,EAAEV,aAAa,CAClBY,aAAa,EACbC,mBAAmB,EACnBkB,cAAc,EACdhB,UAAU,EACVC,eACF,CAAC;AACD,IAAA,aAAa,EAAEhB,aAAa,CAACiB,QAAQ,EAAED,eAAe;GACvD;AACH;AAGA,IAAIgB,GAAY;AAChB,IAAI,OAAOC,SAAS,KAAK,WAAW,EAAE;EACpCD,GAAG,GAAG,oBAAoB,CAACE,IAAI,CAACD,SAAS,CAACE,QAAQ,CAAC;AACrD,CAAC,MAAM;EACL,IAAI,OAAOC,EAAE,KAAK,WAAW,IAAIA,EAAE,CAACD,QAAQ,EAAE;AAC5CH,IAAAA,GAAG,GAAGI,EAAE,CAACD,QAAQ,EAAE,KAAK,QAAQ;AAClC,GAAC,MAAM;AACLH,IAAAA,GAAG,GAAG,KAAK;AACb;AACF;;AAEA;AACA;AACA;AACA;;AAKO,SAASK,UAAUA,CAAC/C,MAAc,EAAEO,OAAuB,EAAE;AAClE,EAAA,OAAOmC,GAAG,GAAGN,aAAa,CAACpC,MAAM,EAAEO,OAAO,CAAC,GAAGO,YAAY,CAACd,MAAM,EAAEO,OAAO,CAAC;AAC7E;;;;"}
|
package/dist/core/rdfa-types.js
CHANGED
|
@@ -15,6 +15,12 @@ const rdfaNodeTypes = ['resource', 'literal'];
|
|
|
15
15
|
function isRdfaAttrs(attrs) {
|
|
16
16
|
return '__rdfaId' in attrs && 'backlinks' in attrs && rdfaNodeTypes.includes(attrs['rdfaNodeType']);
|
|
17
17
|
}
|
|
18
|
+
function isResourceAttrs(attrs) {
|
|
19
|
+
return attrs.rdfaNodeType === 'resource';
|
|
20
|
+
}
|
|
21
|
+
function isLiteralAttrs(attrs) {
|
|
22
|
+
return attrs.rdfaNodeType === 'literal';
|
|
23
|
+
}
|
|
18
24
|
|
|
19
|
-
export { isRdfaAttrs, rdfaNodeTypes };
|
|
25
|
+
export { isLiteralAttrs, isRdfaAttrs, isResourceAttrs, rdfaNodeTypes };
|
|
20
26
|
//# sourceMappingURL=rdfa-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdfa-types.js","sources":["../../src/core/rdfa-types.ts"],"sourcesContent":["import { type Attrs } from 'prosemirror-model';\nimport {\n type FullTriple,\n type IncomingTriple,\n type OutgoingTriple,\n} from './rdfa-processor.ts';\nimport { type SayNamedNode } from './say-data-factory/index.ts';\n\n// These types moved here to avoid circular dependencies\n\nexport const rdfaNodeTypes = ['resource', 'literal'] as const;\nexport interface RdfaAwareAttrs {\n __rdfaId: string;\n rdfaNodeType: (typeof rdfaNodeTypes)[number];\n backlinks: IncomingTriple[];\n externalTriples?: FullTriple[];\n}\nexport interface RdfaLiteralAttrs extends RdfaAwareAttrs {\n rdfaNodeType: 'literal';\n content: string | null;\n datatype?: SayNamedNode | null;\n language?: string | null;\n}\nexport interface RdfaResourceAttrs extends RdfaAwareAttrs {\n rdfaNodeType: 'resource';\n externalTriples?: FullTriple[];\n subject: string;\n properties: OutgoingTriple[];\n}\nexport type RdfaAttrs = RdfaLiteralAttrs | RdfaResourceAttrs;\n\nexport function isRdfaAttrs(attrs: Attrs): attrs is RdfaAttrs {\n return (\n '__rdfaId' in attrs &&\n 'backlinks' in attrs &&\n rdfaNodeTypes.includes(attrs['rdfaNodeType'] as 'resource' | 'literal')\n );\n}\n"],"names":["rdfaNodeTypes","isRdfaAttrs","attrs","includes"],"mappings":";;;;;;;;;;;AAQA;;MAEaA,aAAa,GAAG,CAAC,UAAU,EAAE,SAAS;AAqB5C,SAASC,WAAWA,CAACC,KAAY,EAAsB;AAC5D,EAAA,OACE,UAAU,IAAIA,KAAK,IACnB,WAAW,IAAIA,KAAK,IACpBF,aAAa,CAACG,QAAQ,CAACD,KAAK,CAAC,cAAc,CAA2B,CAAC;AAE3E;;;;"}
|
|
1
|
+
{"version":3,"file":"rdfa-types.js","sources":["../../src/core/rdfa-types.ts"],"sourcesContent":["import { type Attrs } from 'prosemirror-model';\nimport {\n type FullTriple,\n type IncomingTriple,\n type OutgoingTriple,\n} from './rdfa-processor.ts';\nimport { type SayNamedNode } from './say-data-factory/index.ts';\n\n// These types moved here to avoid circular dependencies\n\nexport const rdfaNodeTypes = ['resource', 'literal'] as const;\nexport interface RdfaAwareAttrs {\n __rdfaId: string;\n rdfaNodeType: (typeof rdfaNodeTypes)[number];\n backlinks: IncomingTriple[];\n externalTriples?: FullTriple[];\n}\nexport interface RdfaLiteralAttrs extends RdfaAwareAttrs {\n rdfaNodeType: 'literal';\n content: string | null;\n datatype?: SayNamedNode | null;\n language?: string | null;\n}\nexport interface RdfaResourceAttrs extends RdfaAwareAttrs {\n rdfaNodeType: 'resource';\n externalTriples?: FullTriple[];\n subject: string;\n properties: OutgoingTriple[];\n}\nexport type RdfaAttrs = RdfaLiteralAttrs | RdfaResourceAttrs;\n\nexport function isRdfaAttrs(attrs: Attrs): attrs is RdfaAttrs {\n return (\n '__rdfaId' in attrs &&\n 'backlinks' in attrs &&\n rdfaNodeTypes.includes(attrs['rdfaNodeType'] as 'resource' | 'literal')\n );\n}\n\nexport function isResourceAttrs(attrs: RdfaAttrs): attrs is RdfaResourceAttrs {\n return attrs.rdfaNodeType === 'resource';\n}\nexport function isLiteralAttrs(attrs: RdfaAttrs): attrs is RdfaLiteralAttrs {\n return attrs.rdfaNodeType === 'literal';\n}\n"],"names":["rdfaNodeTypes","isRdfaAttrs","attrs","includes","isResourceAttrs","rdfaNodeType","isLiteralAttrs"],"mappings":";;;;;;;;;;;AAQA;;MAEaA,aAAa,GAAG,CAAC,UAAU,EAAE,SAAS;AAqB5C,SAASC,WAAWA,CAACC,KAAY,EAAsB;AAC5D,EAAA,OACE,UAAU,IAAIA,KAAK,IACnB,WAAW,IAAIA,KAAK,IACpBF,aAAa,CAACG,QAAQ,CAACD,KAAK,CAAC,cAAc,CAA2B,CAAC;AAE3E;AAEO,SAASE,eAAeA,CAACF,KAAgB,EAA8B;AAC5E,EAAA,OAAOA,KAAK,CAACG,YAAY,KAAK,UAAU;AAC1C;AACO,SAASC,cAAcA,CAACJ,KAAgB,EAA6B;AAC1E,EAAA,OAAOA,KAAK,CAACG,YAAY,KAAK,SAAS;AACzC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"say-controller.js","sources":["../../src/core/say-controller.ts"],"sourcesContent":["import { SayStore } from '#root/utils/_private/datastore/say-store.ts';\nimport type Owner from '@ember/owner';\nimport { unwrap } from '#root/utils/_private/option.ts';\nimport { shallowEqual } from '#root/utils/_private/object-utils.ts';\nimport { datastoreKey } from '#root/plugins/datastore/index.ts';\nimport { selectionHasMarkEverywhere } from '#root/utils/_private/mark-utils.ts';\nimport SayView, { type SetHtmlOptions } from '#root/core/say-view.ts';\nimport type SayEditor from '#root/core/say-editor.ts';\nimport { tracked } from '@glimmer/tracking';\nimport { type Attrs, MarkType, Schema } from 'prosemirror-model';\nimport {\n type Command,\n EditorState,\n Selection,\n Transaction,\n} from 'prosemirror-state';\nimport { htmlToDoc } from '#root/utils/_private/html-utils.ts';\n\nexport default class SayController {\n @tracked\n private readonly editor: SayEditor;\n\n constructor(pm: SayEditor) {\n this.editor = pm;\n }\n\n get externalContextStore(): SayStore {\n return unwrap(datastoreKey.getState(this.editor.mainView.state))\n .contextStore;\n }\n\n get mainEditorView() {\n return this.editor.mainView;\n }\n\n get activeEditorView() {\n return this.editor.activeView;\n }\n\n get mainEditorState() {\n return this.editor.mainView.state;\n }\n\n get activeEditorState() {\n return this.editor.activeView.state;\n }\n\n get htmlContent(): string {\n return this.editor.htmlContent;\n }\n\n get inEmbeddedView(): boolean {\n return !!this.activeEditorView.parent;\n }\n\n get domParser() {\n return this.mainEditorView.domParser;\n }\n\n clone() {\n return new SayController(this.editor);\n }\n\n focus() {\n this.editor.activeView.focus();\n }\n\n setActiveView(view: SayView) {\n this.editor.setActiveView(view);\n }\n\n /**\n * Replaces the state (and current document) with a parsed version of the provided `html` string.\n * This method creates a new `doc` node and parses it correctly based on the provided html.\n * Note: plugin state is not preserved when using this method (e.g. the history-plugin state is reset).\n */\n initialize(\n html: string,\n {\n shouldFocus = true,\n doNotClean = false,\n }: Exclude<SetHtmlOptions, 'range'> = {},\n ) {\n const doc = htmlToDoc(html, {\n schema: this.schema,\n editorView: this.editor.mainView,\n parser: this.editor.parser,\n doNotClean,\n });\n\n this.editor.mainView.updateState(\n EditorState.create({\n doc,\n plugins: this.mainEditorState.plugins,\n selection: Selection.atEnd(doc),\n }),\n );\n\n if (shouldFocus) {\n this.focus();\n }\n }\n\n /**\n * setHtmlContent replaces the content of the current document with the provided html\n * Note: it does not create a new `doc` node and does not update the `doc` node based on the provided html\n * (e.g. `lang` attributes on the `doc` node are not parsed)\n */\n setHtmlContent(content: string, options: SetHtmlOptions = {}) {\n this.mainEditorView.setHtmlContent(content, options);\n }\n\n doCommand(command: Command, { view = this.activeEditorView } = {}): boolean {\n
|
|
1
|
+
{"version":3,"file":"say-controller.js","sources":["../../src/core/say-controller.ts"],"sourcesContent":["import { SayStore } from '#root/utils/_private/datastore/say-store.ts';\nimport type Owner from '@ember/owner';\nimport { unwrap } from '#root/utils/_private/option.ts';\nimport { shallowEqual } from '#root/utils/_private/object-utils.ts';\nimport { datastoreKey } from '#root/plugins/datastore/index.ts';\nimport { selectionHasMarkEverywhere } from '#root/utils/_private/mark-utils.ts';\nimport SayView, { type SetHtmlOptions } from '#root/core/say-view.ts';\nimport type SayEditor from '#root/core/say-editor.ts';\nimport { tracked } from '@glimmer/tracking';\nimport { type Attrs, MarkType, Schema } from 'prosemirror-model';\nimport {\n type Command,\n EditorState,\n Selection,\n Transaction,\n} from 'prosemirror-state';\nimport { htmlToDoc } from '#root/utils/_private/html-utils.ts';\n\nexport default class SayController {\n @tracked\n private readonly editor: SayEditor;\n\n constructor(pm: SayEditor) {\n this.editor = pm;\n }\n\n get externalContextStore(): SayStore {\n return unwrap(datastoreKey.getState(this.editor.mainView.state))\n .contextStore;\n }\n\n get mainEditorView() {\n return this.editor.mainView;\n }\n\n get activeEditorView() {\n return this.editor.activeView;\n }\n\n get mainEditorState() {\n return this.editor.mainView.state;\n }\n\n get activeEditorState() {\n return this.editor.activeView.state;\n }\n\n get htmlContent(): string {\n return this.editor.htmlContent;\n }\n\n get inEmbeddedView(): boolean {\n return !!this.activeEditorView.parent;\n }\n\n get domParser() {\n return this.mainEditorView.domParser;\n }\n\n clone() {\n return new SayController(this.editor);\n }\n\n focus() {\n this.editor.activeView.focus();\n }\n\n setActiveView(view: SayView) {\n this.editor.setActiveView(view);\n }\n\n /**\n * Replaces the state (and current document) with a parsed version of the provided `html` string.\n * This method creates a new `doc` node and parses it correctly based on the provided html.\n * Note: plugin state is not preserved when using this method (e.g. the history-plugin state is reset).\n */\n initialize(\n html: string,\n {\n shouldFocus = true,\n doNotClean = false,\n }: Exclude<SetHtmlOptions, 'range'> = {},\n ) {\n const doc = htmlToDoc(html, {\n schema: this.schema,\n editorView: this.editor.mainView,\n parser: this.editor.parser,\n doNotClean,\n });\n\n this.editor.mainView.updateState(\n EditorState.create({\n doc,\n plugins: this.mainEditorState.plugins,\n selection: Selection.atEnd(doc),\n }),\n );\n\n if (shouldFocus) {\n this.focus();\n }\n }\n\n /**\n * setHtmlContent replaces the content of the current document with the provided html\n * Note: it does not create a new `doc` node and does not update the `doc` node based on the provided html\n * (e.g. `lang` attributes on the `doc` node are not parsed)\n */\n setHtmlContent(content: string, options: SetHtmlOptions = {}) {\n this.mainEditorView.setHtmlContent(content, options);\n }\n\n doCommand(command: Command, { view = this.activeEditorView } = {}): boolean {\n return command(view.state, view.dispatch, view);\n }\n\n checkCommand(\n command: Command,\n { view = this.activeEditorView } = {},\n ): boolean {\n return command(view.state);\n }\n\n isMarkActive(markType: MarkType, attrs?: Attrs) {\n const state = this.activeEditorState;\n const { $from, empty } = state.selection;\n if (empty) {\n const mark = markType.isInSet(state.storedMarks || $from.marks());\n return !!mark && (!attrs || shallowEqual(attrs, mark.attrs));\n } else {\n return selectionHasMarkEverywhere(\n state.doc,\n state.selection,\n markType,\n attrs,\n );\n }\n }\n\n withTransaction(\n callback: (tr: Transaction, state: EditorState) => Transaction | null,\n { view = this.activeEditorView } = {},\n ) {\n const tr = view.state.tr;\n const result = callback(tr, view.state);\n if (result) {\n view.dispatch(result);\n }\n }\n\n get datastore(): SayStore {\n return unwrap(datastoreKey.getState(this.mainEditorState)).datastore();\n }\n\n get schema(): Schema {\n return this.mainEditorState.schema;\n }\n\n get owner(): Owner {\n return this.editor.owner;\n }\n\n get documentLanguage() {\n return this.getDocumentAttribute('lang');\n }\n\n set documentLanguage(language: string) {\n this.setDocumentAttribute('lang', language);\n }\n\n setDocumentAttribute(key: string, value: unknown) {\n this.withTransaction((tr) => {\n return tr.setDocAttribute(key, value);\n });\n }\n\n getDocumentAttribute<TAttribute = string>(attribute: string) {\n return this.mainEditorState.doc.attrs[attribute] as TAttribute;\n }\n}\n"],"names":["SayController","g","prototype","tracked","i","void 0","constructor","pm","editor","externalContextStore","unwrap","datastoreKey","getState","mainView","state","contextStore","mainEditorView","activeEditorView","activeView","mainEditorState","activeEditorState","htmlContent","inEmbeddedView","parent","domParser","clone","focus","setActiveView","view","initialize","html","shouldFocus","doNotClean","doc","htmlToDoc","schema","editorView","parser","updateState","EditorState","create","plugins","selection","Selection","atEnd","setHtmlContent","content","options","doCommand","command","dispatch","checkCommand","isMarkActive","markType","attrs","$from","empty","mark","isInSet","storedMarks","marks","shallowEqual","selectionHasMarkEverywhere","withTransaction","callback","tr","result","datastore","owner","documentLanguage","getDocumentAttribute","language","setDocumentAttribute","key","value","setDocAttribute","attribute"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBe,MAAMA,aAAa,CAAC;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAChCC,OAAO,CAAA,CAAA;AAAA;AAAA,EAAA,OAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAAC,MAAA;EAGRC,WAAWA,CA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AACE,QAAgB,EAAE;AACrC,IAAA,IAAI,CAACC,oBAAoB,CAAC,MAAM,EAAED,QAAQ,CAAC;AAC7C;AAEAC,EAAAA,oBAAoBA,CAACC,GAAW,EAAEC,KAAc,EAAE;AAChD,IAAA,IAAI,CAACX,eAAe,CAAEE,EAAE,IAAK;AAC3B,MAAA,OAAOA,EAAE,CAACU,eAAe,CAACF,GAAG,EAAEC,KAAK,CAAC;AACvC,KAAC,CAAC;AACJ;EAEAJ,oBAAoBA,CAAsBM,SAAiB,EAAE;IAC3D,OAAO,IAAI,CAACzD,eAAe,CAACc,GAAG,CAACqB,KAAK,CAACsB,SAAS,CAAC;AAClD;AACF;;;;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import 'prosemirror-model';
|
|
2
|
-
import { rdfaAttrSpec,
|
|
2
|
+
import { rdfaAttrSpec, getRdfaAttrs, getRdfaContentElement, renderRdfaAware } from '../core/schema.js';
|
|
3
3
|
import { createEmberNodeSpec, createEmberNodeView } from '../utils/_private/ember-node.js';
|
|
4
4
|
import InlineRdfaComponent from '../components/ember-node/inline-rdfa.js';
|
|
5
5
|
import getClassnamesFromNode from '../utils/get-classnames-from-node.js';
|
|
6
6
|
|
|
7
7
|
const emberNodeConfig = ({
|
|
8
|
-
rdfaAware = false
|
|
8
|
+
rdfaAware = false,
|
|
9
|
+
modelMigrations
|
|
9
10
|
} = {}) => {
|
|
10
11
|
return {
|
|
11
12
|
name: 'inline-rdfa',
|
|
@@ -40,19 +41,36 @@ const emberNodeConfig = ({
|
|
|
40
41
|
tag: 'span',
|
|
41
42
|
// default prio is 50, highest prio comes first, and this parserule should at least come after all other nodes
|
|
42
43
|
priority: 10,
|
|
43
|
-
getAttrs(
|
|
44
|
-
if (typeof
|
|
44
|
+
getAttrs(element) {
|
|
45
|
+
if (typeof element === 'string') {
|
|
45
46
|
return false;
|
|
46
47
|
}
|
|
47
|
-
const attrs = getRdfaAttrs(
|
|
48
|
+
const attrs = getRdfaAttrs(element, {
|
|
48
49
|
rdfaAware
|
|
49
50
|
});
|
|
50
51
|
if (attrs) {
|
|
52
|
+
const migrations = modelMigrations && modelMigrations(attrs);
|
|
53
|
+
if (migrations && migrations.getAttrs) {
|
|
54
|
+
return migrations.getAttrs(element);
|
|
55
|
+
}
|
|
51
56
|
return attrs;
|
|
52
57
|
}
|
|
53
58
|
return false;
|
|
54
59
|
},
|
|
55
|
-
contentElement:
|
|
60
|
+
contentElement: element => {
|
|
61
|
+
if (rdfaAware && modelMigrations) {
|
|
62
|
+
const attrs = getRdfaAttrs(element, {
|
|
63
|
+
rdfaAware
|
|
64
|
+
});
|
|
65
|
+
if (attrs) {
|
|
66
|
+
const migrations = modelMigrations(attrs);
|
|
67
|
+
if (migrations && migrations.contentElement) {
|
|
68
|
+
return migrations.contentElement(element);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return getRdfaContentElement(element);
|
|
73
|
+
}
|
|
56
74
|
}],
|
|
57
75
|
attrs: rdfaAttrSpec({
|
|
58
76
|
rdfaAware
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-rdfa.js","sources":["../../src/nodes/inline-rdfa.ts"],"sourcesContent":["import { Node as PNode } from 'prosemirror-model';\nimport {\n getRdfaAttrs,\n getRdfaContentElement,\n rdfaAttrSpec,\n renderRdfaAware,\n} from '../core/schema.ts';\nimport {\n type EmberNodeConfig,\n createEmberNodeSpec,\n createEmberNodeView,\n} from '../utils/ember-node.ts';\nimport InlineRdfaComponent from '../components/ember-node/inline-rdfa.ts';\nimport type { ComponentLike } from '@glint/template';\nimport getClassnamesFromNode from '../utils/get-classnames-from-node.ts';\n\ntype Options = {\n rdfaAware?: boolean;\n};\n\nconst emberNodeConfig: (options?: Options) => EmberNodeConfig = ({\n rdfaAware = false,\n} = {}) => {\n return {\n name: 'inline-rdfa',\n inline: true,\n component: InlineRdfaComponent as unknown as ComponentLike,\n group: 'inline',\n content: 'inline*',\n atom: true,\n draggable: false,\n selectable: true,\n editable: rdfaAware,\n isolating: rdfaAware,\n classNames: ['say-inline-rdfa'],\n toDOM(node: PNode) {\n if (rdfaAware) {\n return renderRdfaAware({\n renderable: node,\n tag: 'span',\n attrs: { class: getClassnamesFromNode(node) },\n content: 0,\n });\n } else {\n return [\n 'span',\n { ...node.attrs, class: getClassnamesFromNode(node) },\n 0,\n ];\n }\n },\n parseDOM: [\n {\n tag: 'span',\n // default prio is 50, highest prio comes first, and this parserule should at least come after all other nodes\n priority: 10,\n getAttrs(
|
|
1
|
+
{"version":3,"file":"inline-rdfa.js","sources":["../../src/nodes/inline-rdfa.ts"],"sourcesContent":["import { Node as PNode } from 'prosemirror-model';\nimport {\n getRdfaAttrs,\n getRdfaContentElement,\n rdfaAttrSpec,\n renderRdfaAware,\n} from '../core/schema.ts';\nimport {\n type EmberNodeConfig,\n createEmberNodeSpec,\n createEmberNodeView,\n} from '../utils/ember-node.ts';\nimport InlineRdfaComponent from '../components/ember-node/inline-rdfa.ts';\nimport type { ComponentLike } from '@glint/template';\nimport getClassnamesFromNode from '../utils/get-classnames-from-node.ts';\nimport type { RdfaAttrs } from '#root/core/rdfa-types.js';\n\ntype Options = {\n rdfaAware?: boolean;\n /**\n * Migrations to apply to nodes parsed as inline-rdfa, to modify the data model.\n * @returns false to use the default parsing or an object to define overrides\n **/\n modelMigrations?: (attrs: RdfaAttrs) =>\n | false\n | {\n /** A modified contentElement function to allow for nested structures to be modified **/\n contentElement?: (element: HTMLElement) => HTMLElement;\n /** A modified getAttrs that returns attrs matching the new model **/\n getAttrs?: (element: HTMLElement) => RdfaAttrs;\n };\n};\n\nconst emberNodeConfig: (options?: Options) => EmberNodeConfig = ({\n rdfaAware = false,\n modelMigrations,\n} = {}) => {\n return {\n name: 'inline-rdfa',\n inline: true,\n component: InlineRdfaComponent as unknown as ComponentLike,\n group: 'inline',\n content: 'inline*',\n atom: true,\n draggable: false,\n selectable: true,\n editable: rdfaAware,\n isolating: rdfaAware,\n classNames: ['say-inline-rdfa'],\n toDOM(node: PNode) {\n if (rdfaAware) {\n return renderRdfaAware({\n renderable: node,\n tag: 'span',\n attrs: { class: getClassnamesFromNode(node) },\n content: 0,\n });\n } else {\n return [\n 'span',\n { ...node.attrs, class: getClassnamesFromNode(node) },\n 0,\n ];\n }\n },\n parseDOM: [\n {\n tag: 'span',\n // default prio is 50, highest prio comes first, and this parserule should at least come after all other nodes\n priority: 10,\n getAttrs(element: string | HTMLElement) {\n if (typeof element === 'string') {\n return false;\n }\n const attrs = getRdfaAttrs(element, { rdfaAware });\n if (attrs) {\n const migrations =\n modelMigrations && modelMigrations(attrs as unknown as RdfaAttrs);\n if (migrations && migrations.getAttrs) {\n return migrations.getAttrs(element);\n }\n return attrs;\n }\n return false;\n },\n contentElement: (element) => {\n if (rdfaAware && modelMigrations) {\n const attrs = getRdfaAttrs(element, { rdfaAware });\n if (attrs) {\n const migrations = modelMigrations(attrs);\n if (migrations && migrations.contentElement) {\n return migrations.contentElement(element);\n }\n }\n }\n return getRdfaContentElement(element);\n },\n },\n ],\n attrs: rdfaAttrSpec({ rdfaAware }),\n };\n};\n\nexport const inlineRdfaWithConfig = (options?: Options) =>\n createEmberNodeSpec(emberNodeConfig(options));\n\nexport const inlineRdfaWithConfigView = (options?: Options) =>\n createEmberNodeView(emberNodeConfig(options));\n"],"names":["emberNodeConfig","rdfaAware","modelMigrations","name","inline","component","InlineRdfaComponent","group","content","atom","draggable","selectable","editable","isolating","classNames","toDOM","node","renderRdfaAware","renderable","tag","attrs","class","getClassnamesFromNode","parseDOM","priority","getAttrs","element","getRdfaAttrs","migrations","contentElement","getRdfaContentElement","rdfaAttrSpec","inlineRdfaWithConfig","options","createEmberNodeSpec","inlineRdfaWithConfigView","createEmberNodeView"],"mappings":";;;;;;AAiCA,MAAMA,eAAuD,GAAGA,CAAC;AAC/DC,EAAAA,SAAS,GAAG,KAAK;AACjBC,EAAAA;AACF,CAAC,GAAG,EAAE,KAAK;EACT,OAAO;AACLC,IAAAA,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,CAACH,QAAQ,EAAE;AACrC,YAAA,OAAOG,UAAU,CAACH,QAAQ,CAACC,OAAO,CAAC;AACrC;AACA,UAAA,OAAON,KAAK;AACd;AACA,QAAA,OAAO,KAAK;OACb;MACDS,cAAc,EAAGH,OAAO,IAAK;QAC3B,IAAIzB,SAAS,IAAIC,eAAe,EAAE;AAChC,UAAA,MAAMkB,KAAK,GAAGO,YAAY,CAACD,OAAO,EAAE;AAAEzB,YAAAA;AAAU,WAAC,CAAC;AAClD,UAAA,IAAImB,KAAK,EAAE;AACT,YAAA,MAAMQ,UAAU,GAAG1B,eAAe,CAACkB,KAAK,CAAC;AACzC,YAAA,IAAIQ,UAAU,IAAIA,UAAU,CAACC,cAAc,EAAE;AAC3C,cAAA,OAAOD,UAAU,CAACC,cAAc,CAACH,OAAO,CAAC;AAC3C;AACF;AACF;QACA,OAAOI,qBAAqB,CAACJ,OAAO,CAAC;AACvC;AACF,KAAC,CACF;IACDN,KAAK,EAAEW,YAAY,CAAC;AAAE9B,MAAAA;KAAW;GAClC;AACH,CAAC;AAEM,MAAM+B,oBAAoB,GAAIC,OAAiB,IACpDC,mBAAmB,CAAClC,eAAe,CAACiC,OAAO,CAAC;AAEvC,MAAME,wBAAwB,GAAIF,OAAiB,IACxDG,mBAAmB,CAACpC,eAAe,CAACiC,OAAO,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toggleMark } from 'prosemirror-commands';
|
|
2
2
|
|
|
3
3
|
function setColor(color) {
|
|
4
4
|
return function (state, dispatch) {
|
|
@@ -15,7 +15,9 @@ function setColor(color) {
|
|
|
15
15
|
const mark = schema.marks['color'].create(markAttrs);
|
|
16
16
|
tr.addStoredMark(mark);
|
|
17
17
|
} else {
|
|
18
|
-
return
|
|
18
|
+
return toggleMark(schema.marks['color'], markAttrs, {
|
|
19
|
+
removeWhenPresent: false
|
|
20
|
+
})(state, dispatch);
|
|
19
21
|
}
|
|
20
22
|
dispatch(tr);
|
|
21
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-color.js","sources":["../../../../src/plugins/color/commands/set-color.ts"],"sourcesContent":["import type { Command } from 'prosemirror-state';\nimport {
|
|
1
|
+
{"version":3,"file":"set-color.js","sources":["../../../../src/plugins/color/commands/set-color.ts"],"sourcesContent":["import type { Command } from 'prosemirror-state';\nimport { toggleMark } from 'prosemirror-commands';\n\nexport function setColor(color: string): Command {\n return function (state, dispatch) {\n if (dispatch) {\n const { schema, selection } = state;\n const markAttrs = { color };\n const tr = state.tr;\n if (selection.empty) {\n const mark = schema.marks['color'].create(markAttrs);\n tr.addStoredMark(mark);\n } else {\n return toggleMark(schema.marks['color'], markAttrs, {\n removeWhenPresent: false,\n })(state, dispatch);\n }\n dispatch(tr);\n }\n return true;\n };\n}\n"],"names":["setColor","color","state","dispatch","schema","selection","markAttrs","tr","empty","mark","marks","create","addStoredMark","toggleMark","removeWhenPresent"],"mappings":";;AAGO,SAASA,QAAQA,CAACC,KAAa,EAAW;AAC/C,EAAA,OAAO,UAAUC,KAAK,EAAEC,QAAQ,EAAE;AAChC,IAAA,IAAIA,QAAQ,EAAE;MACZ,MAAM;QAAEC,MAAM;AAAEC,QAAAA;AAAU,OAAC,GAAGH,KAAK;AACnC,MAAA,MAAMI,SAAS,GAAG;AAAEL,QAAAA;OAAO;AAC3B,MAAA,MAAMM,EAAE,GAAGL,KAAK,CAACK,EAAE;MACnB,IAAIF,SAAS,CAACG,KAAK,EAAE;AACnB,QAAA,MAAMC,IAAI,GAAGL,MAAM,CAACM,KAAK,CAAC,OAAO,CAAC,CAACC,MAAM,CAACL,SAAS,CAAC;AACpDC,QAAAA,EAAE,CAACK,aAAa,CAACH,IAAI,CAAC;AACxB,OAAC,MAAM;QACL,OAAOI,UAAU,CAACT,MAAM,CAACM,KAAK,CAAC,OAAO,CAAC,EAAEJ,SAAS,EAAE;AAClDQ,UAAAA,iBAAiB,EAAE;AACrB,SAAC,CAAC,CAACZ,KAAK,EAAEC,QAAQ,CAAC;AACrB;MACAA,QAAQ,CAACI,EAAE,CAAC;AACd;AACA,IAAA,OAAO,IAAI;GACZ;AACH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toggleMark } from 'prosemirror-commands';
|
|
2
2
|
|
|
3
3
|
function setHighlight(color) {
|
|
4
4
|
return function (state, dispatch) {
|
|
@@ -15,7 +15,9 @@ function setHighlight(color) {
|
|
|
15
15
|
const mark = schema.marks['highlight'].create(markAttrs);
|
|
16
16
|
tr.addStoredMark(mark);
|
|
17
17
|
} else {
|
|
18
|
-
return
|
|
18
|
+
return toggleMark(schema.marks['highlight'], markAttrs, {
|
|
19
|
+
removeWhenPresent: false
|
|
20
|
+
})(state, dispatch);
|
|
19
21
|
}
|
|
20
22
|
dispatch(tr);
|
|
21
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-highlight.js","sources":["../../../../src/plugins/highlight/commands/set-highlight.ts"],"sourcesContent":["import type { Command } from 'prosemirror-state';\nimport {
|
|
1
|
+
{"version":3,"file":"set-highlight.js","sources":["../../../../src/plugins/highlight/commands/set-highlight.ts"],"sourcesContent":["import type { Command } from 'prosemirror-state';\nimport { toggleMark } from 'prosemirror-commands';\n\nexport function setHighlight(color: string): Command {\n return function (state, dispatch) {\n if (dispatch) {\n const { schema, selection } = state;\n const markAttrs = { value: color };\n const tr = state.tr;\n if (selection.empty) {\n const mark = schema.marks['highlight'].create(markAttrs);\n tr.addStoredMark(mark);\n } else {\n return toggleMark(schema.marks['highlight'], markAttrs, {\n removeWhenPresent: false,\n })(state, dispatch);\n }\n dispatch(tr);\n }\n return true;\n };\n}\n"],"names":["setHighlight","color","state","dispatch","schema","selection","markAttrs","value","tr","empty","mark","marks","create","addStoredMark","toggleMark","removeWhenPresent"],"mappings":";;AAGO,SAASA,YAAYA,CAACC,KAAa,EAAW;AACnD,EAAA,OAAO,UAAUC,KAAK,EAAEC,QAAQ,EAAE;AAChC,IAAA,IAAIA,QAAQ,EAAE;MACZ,MAAM;QAAEC,MAAM;AAAEC,QAAAA;AAAU,OAAC,GAAGH,KAAK;AACnC,MAAA,MAAMI,SAAS,GAAG;AAAEC,QAAAA,KAAK,EAAEN;OAAO;AAClC,MAAA,MAAMO,EAAE,GAAGN,KAAK,CAACM,EAAE;MACnB,IAAIH,SAAS,CAACI,KAAK,EAAE;AACnB,QAAA,MAAMC,IAAI,GAAGN,MAAM,CAACO,KAAK,CAAC,WAAW,CAAC,CAACC,MAAM,CAACN,SAAS,CAAC;AACxDE,QAAAA,EAAE,CAACK,aAAa,CAACH,IAAI,CAAC;AACxB,OAAC,MAAM;QACL,OAAOI,UAAU,CAACV,MAAM,CAACO,KAAK,CAAC,WAAW,CAAC,EAAEL,SAAS,EAAE;AACtDS,UAAAA,iBAAiB,EAAE;AACrB,SAAC,CAAC,CAACb,KAAK,EAAEC,QAAQ,CAAC;AACrB;MACAA,QAAQ,CAACK,EAAE,CAAC;AACd;AACA,IAAA,OAAO,IAAI;GACZ;AACH;;;;"}
|
|
@@ -83,8 +83,9 @@ function postProcessTagAsRdfaNode(args) {
|
|
|
83
83
|
}
|
|
84
84
|
} else {
|
|
85
85
|
if (truthyAttribute(attributes, 'about') && !truthyAttribute(attributes, 'data-literal-node') &&
|
|
86
|
-
//
|
|
87
|
-
|
|
86
|
+
// temporary workaround for parsing bugs, needs rdfa handling rework
|
|
87
|
+
// to fully solve
|
|
88
|
+
!hackyCheckIfOldLiteralNode(node, attributes)) {
|
|
88
89
|
// same exception as above, we always interpret (property +about -content) cases as literal nodes
|
|
89
90
|
markAsResourceNode(node, unwrap(activeTag.subject), activeTag, activeTag.predicates?.find(pred => pred.value === attributes['property']), activeTag.datatype, activeTag.language);
|
|
90
91
|
return;
|
|
@@ -149,6 +150,45 @@ function truthyAttribute(attrs, key) {
|
|
|
149
150
|
}
|
|
150
151
|
return false;
|
|
151
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* With the current parsing logic there exists an ambiguity between
|
|
155
|
+
* resource nodes with a contentLiteral, and literal nodes. They both
|
|
156
|
+
* manifest in the same way in the html.
|
|
157
|
+
* In most cases this ambiguity is resolved by the data-literal-node
|
|
158
|
+
* attribute we add in newly created documents. However, there are still old
|
|
159
|
+
* documents where this was not added. This function attempts to solve for
|
|
160
|
+
* those specific cases we have identified, pending a rework of the rdfa
|
|
161
|
+
* system.
|
|
162
|
+
*
|
|
163
|
+
* The function attempts to find a parentnode which defines the resource
|
|
164
|
+
* the node is pointing to. If it exists, we can be reasonably certain this
|
|
165
|
+
* is intended to be a literal node.
|
|
166
|
+
*
|
|
167
|
+
* @param node The node being checked
|
|
168
|
+
* @param attributes the attributes of the node
|
|
169
|
+
* @param [searchDepthLimit=2] a safety limit for searching upwards to find
|
|
170
|
+
* a defining resource node
|
|
171
|
+
*/
|
|
172
|
+
function hackyCheckIfOldLiteralNode(node, attributes, searchDepthLimit = 2) {
|
|
173
|
+
const subject = attributes['about'];
|
|
174
|
+
if (!subject) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
let parent = node.parentElement;
|
|
178
|
+
if (!parent) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
let depth = 0;
|
|
182
|
+
while (parent && depth < searchDepthLimit) {
|
|
183
|
+
const parentSubject = parent.getAttribute('about');
|
|
184
|
+
if (parentSubject && parentSubject === subject) {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
parent = parent.parentElement;
|
|
188
|
+
depth += 1;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
152
192
|
|
|
153
193
|
export { postProcessTagAsRdfaNode };
|
|
154
194
|
//# sourceMappingURL=post-process-as-rdfa-nodes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-process-as-rdfa-nodes.js","sources":["../../../../src/utils/_private/rdfa-parser/post-process-as-rdfa-nodes.ts"],"sourcesContent":["import { unwrap } from '../option.ts';\nimport type { IActiveTag } from './active-tag.ts';\nimport type { ModelBlankNode, ModelNamedNode } from './rdfa-parser.ts';\nexport interface PostProcessArgs<N> {\n activeTag: IActiveTag<N>;\n attributes: Record<string, string>;\n isRootTag: boolean;\n isExternalTriple: boolean;\n typedResource: true | ModelBlankNode<N> | ModelNamedNode<N> | null;\n markAsLiteralNode: (\n node: N,\n activeTag: IActiveTag<N>,\n attributes: Record<string, string>,\n predicateAttribute?: string,\n ) => void;\n markAsResourceNode: (\n node: N,\n resource: boolean | ModelBlankNode<N> | ModelNamedNode<N>,\n activeTag: IActiveTag<N>,\n contentPredicate?: ModelNamedNode<N>,\n contentDatatype?: ModelNamedNode<N>,\n contentLanguage?: string,\n ) => void;\n}\n\n/**\n * How the preprocessor works:\n *\n * some definitions:\n *\n * say you have a triple `<uri> predicate \"object\"`,\n * where \"object\" is the value of an attribute (such as content),\n * we call the tuple (predicate, \"object\") a property of <uri>\n *\n * if you have a triple <uri> predicate <uri2>, we call the tuple (predicate, <uri2>) a relationship of <uri>\n *\n * if you have a triple <uri> predicate \"object\",\n * where \"object\" is derived from the concatenated text content of a node,\n * we call the tuple (predicate, node) also a relationship of <uri>\n *\n * The core idea of the preprocessor is this: turn a random rdfa document,\n * which has resources and predicates all over the place, into a document with 2 types of nodes:\n *\n * - a resource node: defines a resource and, crucially, holds ALL properties and relationships of that resource, in both directions\n\n * - a literal node: the \"manifestation\" of a literal relationship on a resource\n *\n * now, this split maps nicely on the spec for the rdfa parsing algorithm.\n * Essentially, when visiting a node, there are 4 possible outcomes (that are relevant for us):\n *\n * a. the node defines a new subject (we mark it as a resource node)\n * b. it \"closes\" a triple by defining its value with the concatenated textcontent (we mark it as a literal node)\n * c. it does both a and b (we mark it as a literal node, see below)\n * d. it does anything else (we don't mark it)\n *\n * in the case of d, we can safely ignore it because of how the resource and literal nodes get processed later on.\n * We attach all their properties and relationships after we fully parse the document,\n * and the parser doesn't ignore d, so it captures all cases.\n *\n * This also means that before the nodes ever get to prosemirror,\n * all the relationships and properties are correctly attached, taking the entire document into account.\n\n * ## Special note\n *\n * the case where an element has both an about and a property attribute,\n * (this is case \"c\" from above) it will always get parsed as a literal node,\n * even if it technically also defines a subject.\n *\n * This means there can be literal nodes that point to a resource which does not have a resource node in the document.\n * This doesn't break anything and is actually completely sensible.\n * A node like this effectively defines a complete triple,\n * completely independant from the context it's in, with the value of about as the subject,\n * the value of property as predicate and the concatenated textcontent as the object.\n **/\nexport function postProcessTagAsRdfaNode<N>(args: PostProcessArgs<N>): void {\n const {\n activeTag,\n attributes,\n isRootTag,\n isExternalTriple,\n typedResource,\n markAsLiteralNode,\n markAsResourceNode,\n } = args;\n const node = activeTag.node;\n if (node && isExternalTriple) {\n markAsResourceNode(\n node,\n unwrap(activeTag.subject),\n activeTag,\n activeTag.predicates?.find(\n (pred) => pred.value === attributes['property'],\n ),\n activeTag.datatype,\n activeTag.language,\n );\n return;\n }\n if (!activeTag.skipElement && node) {\n // no rel or rev\n if (\n !truthyAttribute(attributes, 'rel') &&\n !truthyAttribute(attributes, 'rev')\n ) {\n if (\n truthyAttribute(attributes, 'property') &&\n !truthyAttribute(attributes, 'content') &&\n !truthyAttribute(attributes, 'datatype')\n ) {\n if (\n truthyAttribute(attributes, 'about') &&\n !truthyAttribute(attributes, 'data-literal-node')\n ) {\n markAsResourceNode(\n node,\n unwrap(activeTag.subject),\n activeTag,\n activeTag.predicates?.find(\n (pred) => pred.value === attributes['property'],\n ),\n activeTag.datatype,\n activeTag.language,\n );\n return;\n } else if (isRootTag) {\n // root resource\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else {\n if (truthyAttribute(attributes, 'typeof')) {\n markAsResourceNode(node, unwrap(typedResource), activeTag);\n return;\n }\n }\n } else {\n if (\n truthyAttribute(attributes, 'about') &&\n !truthyAttribute(attributes, 'data-literal-node') &&\n // Is this correct, an alternative solution would be to check on the presence of a `resource` attr here?\n !truthyAttribute(attributes, 'datatype')\n ) {\n // same exception as above, we always interpret (property +about -content) cases as literal nodes\n markAsResourceNode(\n node,\n unwrap(activeTag.subject),\n activeTag,\n activeTag.predicates?.find(\n (pred) => pred.value === attributes['property'],\n ),\n activeTag.datatype,\n activeTag.language,\n );\n return;\n } else if (\n truthyAttribute(attributes, 'href') ||\n truthyAttribute(attributes, 'src') ||\n truthyAttribute(attributes, 'resource')\n ) {\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (isRootTag) {\n // root resource node\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (truthyAttribute(attributes, 'typeof')) {\n // blank resource node\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (\n truthyAttribute(attributes, 'data-literal-node') &&\n truthyAttribute(attributes, 'data-say-id')\n ) {\n markAsLiteralNode(node, activeTag, attributes);\n return;\n } else if (activeTag.object) {\n // intentionally empty, to preserve structure from algorithm in spec\n }\n }\n } else {\n if (truthyAttribute(attributes, 'about')) {\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (truthyAttribute(attributes, 'typeof')) {\n markAsResourceNode(node, unwrap(typedResource), activeTag);\n return;\n } else if (isRootTag) {\n // root resource node\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (activeTag.object) {\n // intentionally empty, to preserve structure from algorithm in spec\n }\n }\n\n // no-op returns are intentional\n if (truthyAttribute(attributes, 'property')) {\n if (truthyAttribute(attributes, 'datatype')) {\n if (!truthyAttribute(attributes, 'content')) {\n markAsLiteralNode(node, activeTag, attributes);\n return;\n }\n } else if (truthyAttribute(attributes, 'content')) {\n return;\n } else if (\n !truthyAttribute(attributes, 'rel') &&\n !truthyAttribute(attributes, 'rev') &&\n !truthyAttribute(attributes, 'content') &&\n (truthyAttribute(attributes, 'resource') ||\n truthyAttribute(attributes, 'href') ||\n truthyAttribute(attributes, 'src'))\n ) {\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (\n truthyAttribute(attributes, 'typeof') &&\n !truthyAttribute(attributes, 'about')\n ) {\n return;\n } else {\n markAsLiteralNode(node, activeTag, attributes);\n return;\n }\n }\n }\n}\nfunction truthyAttribute(attrs: Record<string, string>, key: string) {\n if (key in attrs) {\n const value = attrs[key];\n if (value === '' || value === 'false') {\n return false;\n }\n return true;\n }\n return false;\n}\n"],"names":["postProcessTagAsRdfaNode","args","activeTag","attributes","isRootTag","isExternalTriple","typedResource","markAsLiteralNode","markAsResourceNode","node","unwrap","subject","predicates","find","pred","value","datatype","language","skipElement","truthyAttribute","object","attrs","key"],"mappings":";;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAwBA,CAAIC,IAAwB,EAAQ;EAC1E,MAAM;IACJC,SAAS;IACTC,UAAU;IACVC,SAAS;IACTC,gBAAgB;IAChBC,aAAa;IACbC,iBAAiB;AACjBC,IAAAA;AACF,GAAC,GAAGP,IAAI;AACR,EAAA,MAAMQ,IAAI,GAAGP,SAAS,CAACO,IAAI;EAC3B,IAAIA,IAAI,IAAIJ,gBAAgB,EAAE;AAC5BG,IAAAA,kBAAkB,CAChBC,IAAI,EACJC,MAAM,CAACR,SAAS,CAACS,OAAO,CAAC,EACzBT,SAAS,EACTA,SAAS,CAACU,UAAU,EAAEC,IAAI,CACvBC,IAAI,IAAKA,IAAI,CAACC,KAAK,KAAKZ,UAAU,CAAC,UAAU,CAChD,CAAC,EACDD,SAAS,CAACc,QAAQ,EAClBd,SAAS,CAACe,QACZ,CAAC;AACD,IAAA;AACF;AACA,EAAA,IAAI,CAACf,SAAS,CAACgB,WAAW,IAAIT,IAAI,EAAE;AAClC;AACA,IAA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C,MAAM;AACLI,QAAAA,iBAAiB,CAACE,IAAI,EAAEP,SAAS,EAAEC,UAAU,CAAC;AAC9C,QAAA;AACF;AACF;AACF;AACF;AACA,SAASgB,eAAeA,CAACE,KAA6B,EAAEC,GAAW,EAAE;EACnE,IAAIA,GAAG,IAAID,KAAK,EAAE;AAChB,IAAA,MAAMN,KAAK,GAAGM,KAAK,CAACC,GAAG,CAAC;AACxB,IAAA,IAAIP,KAAK,KAAK,EAAE,IAAIA,KAAK,KAAK,OAAO,EAAE;AACrC,MAAA,OAAO,KAAK;AACd;AACA,IAAA,OAAO,IAAI;AACb;AACA,EAAA,OAAO,KAAK;AACd;;;;"}
|
|
1
|
+
{"version":3,"file":"post-process-as-rdfa-nodes.js","sources":["../../../../src/utils/_private/rdfa-parser/post-process-as-rdfa-nodes.ts"],"sourcesContent":["import { unwrap } from '../option.ts';\nimport type { IActiveTag } from './active-tag.ts';\nimport type { ModelBlankNode, ModelNamedNode } from './rdfa-parser.ts';\nexport interface PostProcessArgs<N> {\n activeTag: IActiveTag<N>;\n attributes: Record<string, string>;\n isRootTag: boolean;\n isExternalTriple: boolean;\n typedResource: true | ModelBlankNode<N> | ModelNamedNode<N> | null;\n markAsLiteralNode: (\n node: N,\n activeTag: IActiveTag<N>,\n attributes: Record<string, string>,\n predicateAttribute?: string,\n ) => void;\n markAsResourceNode: (\n node: N,\n resource: boolean | ModelBlankNode<N> | ModelNamedNode<N>,\n activeTag: IActiveTag<N>,\n contentPredicate?: ModelNamedNode<N>,\n contentDatatype?: ModelNamedNode<N>,\n contentLanguage?: string,\n ) => void;\n}\n\n/**\n * How the preprocessor works:\n *\n * some definitions:\n *\n * say you have a triple `<uri> predicate \"object\"`,\n * where \"object\" is the value of an attribute (such as content),\n * we call the tuple (predicate, \"object\") a property of <uri>\n *\n * if you have a triple <uri> predicate <uri2>, we call the tuple (predicate, <uri2>) a relationship of <uri>\n *\n * if you have a triple <uri> predicate \"object\",\n * where \"object\" is derived from the concatenated text content of a node,\n * we call the tuple (predicate, node) also a relationship of <uri>\n *\n * The core idea of the preprocessor is this: turn a random rdfa document,\n * which has resources and predicates all over the place, into a document with 2 types of nodes:\n *\n * - a resource node: defines a resource and, crucially, holds ALL properties and relationships of that resource, in both directions\n\n * - a literal node: the \"manifestation\" of a literal relationship on a resource\n *\n * now, this split maps nicely on the spec for the rdfa parsing algorithm.\n * Essentially, when visiting a node, there are 4 possible outcomes (that are relevant for us):\n *\n * a. the node defines a new subject (we mark it as a resource node)\n * b. it \"closes\" a triple by defining its value with the concatenated textcontent (we mark it as a literal node)\n * c. it does both a and b (we mark it as a literal node, see below)\n * d. it does anything else (we don't mark it)\n *\n * in the case of d, we can safely ignore it because of how the resource and literal nodes get processed later on.\n * We attach all their properties and relationships after we fully parse the document,\n * and the parser doesn't ignore d, so it captures all cases.\n *\n * This also means that before the nodes ever get to prosemirror,\n * all the relationships and properties are correctly attached, taking the entire document into account.\n\n * ## Special note\n *\n * the case where an element has both an about and a property attribute,\n * (this is case \"c\" from above) it will always get parsed as a literal node,\n * even if it technically also defines a subject.\n *\n * This means there can be literal nodes that point to a resource which does not have a resource node in the document.\n * This doesn't break anything and is actually completely sensible.\n * A node like this effectively defines a complete triple,\n * completely independant from the context it's in, with the value of about as the subject,\n * the value of property as predicate and the concatenated textcontent as the object.\n **/\nexport function postProcessTagAsRdfaNode<N>(args: PostProcessArgs<N>): void {\n const {\n activeTag,\n attributes,\n isRootTag,\n isExternalTriple,\n typedResource,\n markAsLiteralNode,\n markAsResourceNode,\n } = args;\n const node = activeTag.node;\n if (node && isExternalTriple) {\n markAsResourceNode(\n node,\n unwrap(activeTag.subject),\n activeTag,\n activeTag.predicates?.find(\n (pred) => pred.value === attributes['property'],\n ),\n activeTag.datatype,\n activeTag.language,\n );\n return;\n }\n if (!activeTag.skipElement && node) {\n // no rel or rev\n if (\n !truthyAttribute(attributes, 'rel') &&\n !truthyAttribute(attributes, 'rev')\n ) {\n if (\n truthyAttribute(attributes, 'property') &&\n !truthyAttribute(attributes, 'content') &&\n !truthyAttribute(attributes, 'datatype')\n ) {\n if (\n truthyAttribute(attributes, 'about') &&\n !truthyAttribute(attributes, 'data-literal-node')\n ) {\n markAsResourceNode(\n node,\n unwrap(activeTag.subject),\n activeTag,\n activeTag.predicates?.find(\n (pred) => pred.value === attributes['property'],\n ),\n activeTag.datatype,\n activeTag.language,\n );\n return;\n } else if (isRootTag) {\n // root resource\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else {\n if (truthyAttribute(attributes, 'typeof')) {\n markAsResourceNode(node, unwrap(typedResource), activeTag);\n return;\n }\n }\n } else {\n if (\n truthyAttribute(attributes, 'about') &&\n !truthyAttribute(attributes, 'data-literal-node') &&\n // temporary workaround for parsing bugs, needs rdfa handling rework\n // to fully solve\n !hackyCheckIfOldLiteralNode(node as unknown as Node, attributes)\n ) {\n // same exception as above, we always interpret (property +about -content) cases as literal nodes\n markAsResourceNode(\n node,\n unwrap(activeTag.subject),\n activeTag,\n activeTag.predicates?.find(\n (pred) => pred.value === attributes['property'],\n ),\n activeTag.datatype,\n activeTag.language,\n );\n return;\n } else if (\n truthyAttribute(attributes, 'href') ||\n truthyAttribute(attributes, 'src') ||\n truthyAttribute(attributes, 'resource')\n ) {\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (isRootTag) {\n // root resource node\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (truthyAttribute(attributes, 'typeof')) {\n // blank resource node\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (\n truthyAttribute(attributes, 'data-literal-node') &&\n truthyAttribute(attributes, 'data-say-id')\n ) {\n markAsLiteralNode(node, activeTag, attributes);\n return;\n } else if (activeTag.object) {\n // intentionally empty, to preserve structure from algorithm in spec\n }\n }\n } else {\n if (truthyAttribute(attributes, 'about')) {\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (truthyAttribute(attributes, 'typeof')) {\n markAsResourceNode(node, unwrap(typedResource), activeTag);\n return;\n } else if (isRootTag) {\n // root resource node\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (activeTag.object) {\n // intentionally empty, to preserve structure from algorithm in spec\n }\n }\n\n // no-op returns are intentional\n if (truthyAttribute(attributes, 'property')) {\n if (truthyAttribute(attributes, 'datatype')) {\n if (!truthyAttribute(attributes, 'content')) {\n markAsLiteralNode(node, activeTag, attributes);\n return;\n }\n } else if (truthyAttribute(attributes, 'content')) {\n return;\n } else if (\n !truthyAttribute(attributes, 'rel') &&\n !truthyAttribute(attributes, 'rev') &&\n !truthyAttribute(attributes, 'content') &&\n (truthyAttribute(attributes, 'resource') ||\n truthyAttribute(attributes, 'href') ||\n truthyAttribute(attributes, 'src'))\n ) {\n markAsResourceNode(node, unwrap(activeTag.subject), activeTag);\n return;\n } else if (\n truthyAttribute(attributes, 'typeof') &&\n !truthyAttribute(attributes, 'about')\n ) {\n return;\n } else {\n markAsLiteralNode(node, activeTag, attributes);\n return;\n }\n }\n }\n}\nfunction truthyAttribute(attrs: Record<string, string>, key: string) {\n if (key in attrs) {\n const value = attrs[key];\n if (value === '' || value === 'false') {\n return false;\n }\n return true;\n }\n return false;\n}\n/**\n * With the current parsing logic there exists an ambiguity between\n * resource nodes with a contentLiteral, and literal nodes. They both\n * manifest in the same way in the html.\n * In most cases this ambiguity is resolved by the data-literal-node\n * attribute we add in newly created documents. However, there are still old\n * documents where this was not added. This function attempts to solve for\n * those specific cases we have identified, pending a rework of the rdfa\n * system.\n *\n * The function attempts to find a parentnode which defines the resource\n * the node is pointing to. If it exists, we can be reasonably certain this\n * is intended to be a literal node.\n *\n * @param node The node being checked\n * @param attributes the attributes of the node\n * @param [searchDepthLimit=2] a safety limit for searching upwards to find\n * a defining resource node\n */\nfunction hackyCheckIfOldLiteralNode(\n node: Node,\n attributes: Record<string, string>,\n searchDepthLimit = 2,\n): boolean {\n const subject = attributes['about'];\n if (!subject) {\n return false;\n }\n let parent = node.parentElement;\n if (!parent) {\n return false;\n }\n let depth = 0;\n\n while (parent && depth < searchDepthLimit) {\n const parentSubject = parent.getAttribute('about');\n if (parentSubject && parentSubject === subject) {\n return true;\n }\n parent = parent.parentElement;\n depth += 1;\n }\n return false;\n}\n"],"names":["postProcessTagAsRdfaNode","args","activeTag","attributes","isRootTag","isExternalTriple","typedResource","markAsLiteralNode","markAsResourceNode","node","unwrap","subject","predicates","find","pred","value","datatype","language","skipElement","truthyAttribute","hackyCheckIfOldLiteralNode","object","attrs","key","searchDepthLimit","parent","parentElement","depth","parentSubject","getAttribute"],"mappings":";;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAwBA,CAAIC,IAAwB,EAAQ;EAC1E,MAAM;IACJC,SAAS;IACTC,UAAU;IACVC,SAAS;IACTC,gBAAgB;IAChBC,aAAa;IACbC,iBAAiB;AACjBC,IAAAA;AACF,GAAC,GAAGP,IAAI;AACR,EAAA,MAAMQ,IAAI,GAAGP,SAAS,CAACO,IAAI;EAC3B,IAAIA,IAAI,IAAIJ,gBAAgB,EAAE;AAC5BG,IAAAA,kBAAkB,CAChBC,IAAI,EACJC,MAAM,CAACR,SAAS,CAACS,OAAO,CAAC,EACzBT,SAAS,EACTA,SAAS,CAACU,UAAU,EAAEC,IAAI,CACvBC,IAAI,IAAKA,IAAI,CAACC,KAAK,KAAKZ,UAAU,CAAC,UAAU,CAChD,CAAC,EACDD,SAAS,CAACc,QAAQ,EAClBd,SAAS,CAACe,QACZ,CAAC;AACD,IAAA;AACF;AACA,EAAA,IAAI,CAACf,SAAS,CAACgB,WAAW,IAAIT,IAAI,EAAE;AAClC;AACA,IA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|
2
2
|
"name": "@lblod/ember-rdfa-editor",
|
|
3
|
-
"version": "12.12.
|
|
3
|
+
"version": "12.12.1-dev.cfccfaf88a64bd52aea209b09d95c4e705c0ca44",
|
|
4
4
|
"description": "Ember addon wrapping an RDFa editor with a public API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -240,17 +240,17 @@
|
|
|
240
240
|
"linkifyjs": "^4.1.3",
|
|
241
241
|
"mdn-polyfills": "^5.20.0",
|
|
242
242
|
"process": "0.11.10",
|
|
243
|
-
"prosemirror-commands": "^1.
|
|
243
|
+
"prosemirror-commands": "^1.7.1",
|
|
244
244
|
"prosemirror-dropcursor": "^1.8.1",
|
|
245
245
|
"prosemirror-history": "1.4.1",
|
|
246
|
-
"prosemirror-inputrules": "^1.
|
|
246
|
+
"prosemirror-inputrules": "^1.5.0",
|
|
247
247
|
"prosemirror-keymap": "^1.2.2",
|
|
248
|
-
"prosemirror-model": "^1.
|
|
248
|
+
"prosemirror-model": "^1.25.3",
|
|
249
249
|
"prosemirror-schema-basic": "^1.2.2",
|
|
250
|
-
"prosemirror-schema-list": "^1.
|
|
250
|
+
"prosemirror-schema-list": "^1.5.1",
|
|
251
251
|
"prosemirror-state": "^1.4.3",
|
|
252
|
-
"prosemirror-transform": "^1.
|
|
253
|
-
"prosemirror-view": "^1.
|
|
252
|
+
"prosemirror-transform": "^1.10.4",
|
|
253
|
+
"prosemirror-view": "^1.40.1",
|
|
254
254
|
"rdf-data-factory": "^1.1.2",
|
|
255
255
|
"reactiveweb": "^1.3.0",
|
|
256
256
|
"relative-to-absolute-iri": "^1.0.7",
|