@lblod/ember-rdfa-editor 13.1.1 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -9
- package/declarations/components/_private/common/configurable-rdfa-display.d.ts +4 -4
- package/declarations/components/editor.d.ts +2 -0
- package/declarations/components/toolbar/button.d.ts +1 -1
- package/declarations/core/say-controller.d.ts +11 -4
- package/declarations/core/say-data-factory/blank-node.d.ts +1 -1
- package/declarations/core/say-data-factory/default-graph.d.ts +1 -1
- package/declarations/core/say-data-factory/literal.d.ts +1 -1
- package/declarations/core/say-data-factory/named-node.d.ts +1 -1
- package/declarations/core/say-data-factory/prosemirror-terms/content-literal.d.ts +1 -1
- package/declarations/core/say-data-factory/prosemirror-terms/literal-node.d.ts +1 -1
- package/declarations/core/say-data-factory/prosemirror-terms/resource-node.d.ts +1 -1
- package/declarations/core/say-data-factory/quad.d.ts +1 -1
- package/declarations/core/say-data-factory/variable.d.ts +1 -1
- package/declarations/core/say-editor.d.ts +1 -0
- package/declarations/core/say-view.d.ts +7 -1
- package/declarations/utils/_private/rdfa-parser/util.d.ts +1 -1
- package/dist/commands/_private/rdfa-commands/remove-backlink.js +1 -1
- package/dist/commands/_private/rdfa-commands/select-node-by-rdfa-id.js +1 -1
- package/dist/commands/_private/rdfa-commands/select-node-by-subject.js +1 -1
- package/dist/commands/_private/rdfa-commands/wrap-inline-resource.js +1 -1
- package/dist/commands/_private/rdfa-commands/wrap-literal.js +1 -1
- package/dist/commands/_private/rdfa-commands/wrap-resource.js +1 -1
- package/dist/commands/rdfa-commands/add-property.js +1 -1
- package/dist/commands/rdfa-commands/remove-property.js +1 -1
- package/dist/components/_private/attribute-editor/index.js +1 -1
- package/dist/components/_private/attribute-editor/index.js.map +1 -1
- package/dist/components/_private/common/configurable-rdfa-display.js +1 -1
- package/dist/components/_private/common/configurable-rdfa-display.js.map +1 -1
- package/dist/components/_private/common/property-details.js +1 -1
- package/dist/components/_private/node-controls/wrapping-utils.js +2 -2
- package/dist/components/_private/node-controls/wrapping-utils.js.map +1 -1
- package/dist/components/_private/rdfa-visualiser/rdfa-explorer.js +1 -1
- package/dist/components/_private/rdfa-visualiser/resource-info.js +1 -1
- package/dist/components/_private/rdfa-visualiser/visualiser-card.js +1 -1
- package/dist/components/collapsible.js +1 -1
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/editor.js +7 -1
- package/dist/components/editor.js.map +1 -1
- package/dist/components/ember-node/embedded-editor.js +4 -1
- package/dist/components/ember-node/embedded-editor.js.map +1 -1
- package/dist/components/plugins/history/redo.js +1 -1
- package/dist/components/plugins/history/undo.js +1 -1
- package/dist/components/plugins/list/ordered.js +1 -1
- package/dist/components/plugins/list/unordered.js +1 -1
- package/dist/components/toolbar/mark.js +1 -1
- package/dist/core/keymap.js +2 -2
- package/dist/core/rdfa-types.js +1 -1
- package/dist/core/say-controller.js +41 -5
- package/dist/core/say-controller.js.map +1 -1
- package/dist/core/say-data-factory/blank-node.js +2 -2
- package/dist/core/say-data-factory/blank-node.js.map +1 -1
- package/dist/core/say-data-factory/default-graph.js +2 -2
- package/dist/core/say-data-factory/default-graph.js.map +1 -1
- package/dist/core/say-data-factory/literal.js +2 -2
- package/dist/core/say-data-factory/literal.js.map +1 -1
- package/dist/core/say-data-factory/named-node.js +2 -2
- package/dist/core/say-data-factory/named-node.js.map +1 -1
- package/dist/core/say-data-factory/prosemirror-terms/content-literal.js +2 -2
- package/dist/core/say-data-factory/prosemirror-terms/content-literal.js.map +1 -1
- package/dist/core/say-data-factory/prosemirror-terms/literal-node.js +2 -2
- package/dist/core/say-data-factory/prosemirror-terms/literal-node.js.map +1 -1
- package/dist/core/say-data-factory/prosemirror-terms/resource-node.js +2 -2
- package/dist/core/say-data-factory/prosemirror-terms/resource-node.js.map +1 -1
- package/dist/core/say-data-factory/quad.js +2 -2
- package/dist/core/say-data-factory/quad.js.map +1 -1
- package/dist/core/say-data-factory/variable.js +2 -2
- package/dist/core/say-data-factory/variable.js.map +1 -1
- package/dist/core/say-editor.js +4 -2
- package/dist/core/say-editor.js.map +1 -1
- package/dist/core/say-view.js +2 -1
- package/dist/core/say-view.js.map +1 -1
- package/dist/index-CxRqg5Kr.js +671 -0
- package/dist/index-CxRqg5Kr.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/{main-dUbkrxFL.js → main-DFf-0En3.js} +7988 -8105
- package/dist/main-DFf-0En3.js.map +1 -0
- package/dist/nodes/invisible-rdfa.js +1 -1
- package/dist/plugins/history/index.js +1 -1
- package/dist/plugins/list/commands/lift-out-of-nested-lists.js +1 -1
- package/dist/plugins/rdfa-info/index.js +1 -1
- package/dist/plugins/rdfa-info/types.js +1 -1
- package/dist/plugins/remove-properties-of-deleted-nodes/index.js +1 -1
- package/dist/utils/_private/datastore/graphy-dataset.js +1 -1
- package/dist/utils/_private/ember-node.js +0 -2
- package/dist/utils/_private/ember-node.js.map +1 -1
- package/dist/utils/_private/rdfa-parser/util.js +1 -8
- package/dist/utils/_private/rdfa-parser/util.js.map +1 -1
- package/package.json +8 -7
- package/declarations/components/toolbar.d.ts +0 -1
- package/dist/main-dUbkrxFL.js.map +0 -1
|
@@ -17,7 +17,7 @@ import '../../../utils/_private/constants.js';
|
|
|
17
17
|
import 'uuid';
|
|
18
18
|
import 'relative-to-absolute-iri';
|
|
19
19
|
import 'rdf-data-factory';
|
|
20
|
-
import '../../../main-
|
|
20
|
+
import '../../../main-DFf-0En3.js';
|
|
21
21
|
import '../../../config/rdfa.js';
|
|
22
22
|
import 'iter-tools';
|
|
23
23
|
import { selectNodeBySubject } from '../../../commands/_private/rdfa-commands/select-node-by-subject.js';
|
|
@@ -14,7 +14,7 @@ import 'uuid';
|
|
|
14
14
|
import '../../../utils/_private/constants.js';
|
|
15
15
|
import 'relative-to-absolute-iri';
|
|
16
16
|
import 'rdf-data-factory';
|
|
17
|
-
import '../../../main-
|
|
17
|
+
import '../../../main-DFf-0En3.js';
|
|
18
18
|
import '../../../core/say-data-factory/data-factory.js';
|
|
19
19
|
import '../../../core/say-data-factory/default-graph.js';
|
|
20
20
|
import '../../../config/rdfa.js';
|
|
@@ -5,7 +5,7 @@ import 'uuid';
|
|
|
5
5
|
import '../../../utils/_private/constants.js';
|
|
6
6
|
import 'relative-to-absolute-iri';
|
|
7
7
|
import 'rdf-data-factory';
|
|
8
|
-
import '../../../main-
|
|
8
|
+
import '../../../main-DFf-0En3.js';
|
|
9
9
|
import '../../../core/say-data-factory/data-factory.js';
|
|
10
10
|
import '../../../core/say-data-factory/default-graph.js';
|
|
11
11
|
import '../../../config/rdfa.js';
|
|
@@ -29,7 +29,7 @@ class Collapsible extends Component {
|
|
|
29
29
|
n(this.prototype, "toggle", [action]);
|
|
30
30
|
}
|
|
31
31
|
static {
|
|
32
|
-
setComponentTemplate(precompileTemplate("\n <div class=\"say-editor-hints__insert\">\n <div class=\"au-c-accordion au-c-accordion--reverse au-c-accordion--border\">\n <AuToolbar @nowrap={{true}} @reverse={{true}} {{on \"click\" this.toggle}} as |Group|>\n <Group>\n <div>\n <AuButton @skin=\"link\" aria-hidden=\"true\" focusable=\"false\" aria-expanded=\"{{if this.expanded \"true\" \"false\"}}\">\n {{@title}}\n </AuButton>\n </div>\n </Group>\n <Group>\n {{#if this.expanded}}\n <AuIcon @icon={{RemoveIcon}} @alignment=\"left\" @size=\"large\" @ariaHidden=\"true\" />\n <span class=\"au-u-hidden-visually\">\n Open accordion\n </span>\n {{else}}\n <AuIcon @icon={{AddIcon}} @alignment=\"left\" @size=\"large\" @ariaHidden=\"true\" />\n <span class=\"au-u-hidden-visually\">\n Sluit accordion\n </span>\n {{/if}}\n </Group>\n </AuToolbar>\n <div class={{if this.expanded \"au-c-accordion__content\" \"au-u-hidden\"}}>\n <AuList @divider={{true}} as |Item|>\n {{yield Item}}\n </AuList>\n </div>\n </div>\n </div>\n ", {
|
|
32
|
+
setComponentTemplate(precompileTemplate("\n <div class=\"say-editor-hints__insert\">\n <div class=\"au-c-accordion au-c-accordion--reverse au-c-accordion--border\">\n <AuToolbar @nowrap={{true}} @reverse={{true}} {{on \"click\" this.toggle}} as |Group|>\n <Group>\n <div>\n <AuButton @skin=\"link\" aria-hidden=\"true\" {{!-- @glint-expect-error we should check if we can pass this attribute --}} focusable=\"false\" aria-expanded=\"{{if this.expanded \"true\" \"false\"}}\">\n {{@title}}\n </AuButton>\n </div>\n </Group>\n <Group>\n {{#if this.expanded}}\n <AuIcon @icon={{RemoveIcon}} @alignment=\"left\" @size=\"large\" @ariaHidden=\"true\" />\n <span class=\"au-u-hidden-visually\">\n Open accordion\n </span>\n {{else}}\n <AuIcon @icon={{AddIcon}} @alignment=\"left\" @size=\"large\" @ariaHidden=\"true\" />\n <span class=\"au-u-hidden-visually\">\n Sluit accordion\n </span>\n {{/if}}\n </Group>\n </AuToolbar>\n <div class={{if this.expanded \"au-c-accordion__content\" \"au-u-hidden\"}}>\n <AuList @divider={{true}} as |Item|>\n {{yield Item}}\n </AuList>\n </div>\n </div>\n </div>\n ", {
|
|
33
33
|
strictMode: true,
|
|
34
34
|
scope: () => ({
|
|
35
35
|
AuToolbar,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapsible.js","sources":["../../src/components/collapsible.gts"],"sourcesContent":["import AuButton from '@appuniversum/ember-appuniversum/components/au-button';\nimport AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';\nimport AuList, {\n type AuListSignature,\n} from '@appuniversum/ember-appuniversum/components/au-list';\nimport AuToolbar from '@appuniversum/ember-appuniversum/components/au-toolbar';\nimport { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';\nimport { RemoveIcon } from '@appuniversum/ember-appuniversum/components/icons/remove';\nimport { on } from '@ember/modifier';\n\nimport { action } from '@ember/object';\nimport Component from '@glimmer/component';\nimport { localCopy } from 'tracked-toolbox';\ntype Args = {\n title: string;\n onToggle?: (expanded: boolean) => void;\n} & (\n | {\n /** @deprecated, use `expanded` instead */\n expandedInitially?: boolean;\n expanded: never;\n }\n | {\n /** @deprecated, use `expanded` instead */\n expandedInitially?: never;\n expanded?: boolean;\n }\n);\n\ntype CollapsibleSignature = {\n Args: Args;\n Element: HTMLDivElement;\n Blocks: {\n default: AuListSignature['Blocks']['default'];\n };\n};\nexport default class Collapsible extends Component<CollapsibleSignature> {\n @localCopy('args.expanded') _expanded?: boolean;\n\n get expanded() {\n return this._expanded ?? this.args.expandedInitially;\n }\n\n @action\n toggle() {\n const newState = !this.expanded;\n this._expanded = newState;\n this.args.onToggle?.(newState);\n }\n\n <template>\n <div class=\"say-editor-hints__insert\">\n <div\n class=\"au-c-accordion au-c-accordion--reverse au-c-accordion--border\"\n >\n <AuToolbar\n @nowrap={{true}}\n @reverse={{true}}\n {{on \"click\" this.toggle}}\n as |Group|\n >\n <Group>\n <div>\n <AuButton\n @skin=\"link\"\n aria-hidden=\"true\"\n focusable=\"false\"\n aria-expanded=\"{{if this.expanded 'true' 'false'}}\"\n >\n {{@title}}\n </AuButton>\n </div>\n </Group>\n <Group>\n {{#if this.expanded}}\n <AuIcon\n @icon={{RemoveIcon}}\n @alignment=\"left\"\n @size=\"large\"\n @ariaHidden=\"true\"\n />\n <span class=\"au-u-hidden-visually\">\n Open accordion\n </span>\n {{else}}\n <AuIcon\n @icon={{AddIcon}}\n @alignment=\"left\"\n @size=\"large\"\n @ariaHidden=\"true\"\n />\n <span class=\"au-u-hidden-visually\">\n Sluit accordion\n </span>\n {{/if}}\n </Group>\n </AuToolbar>\n <div class={{if this.expanded \"au-c-accordion__content\" \"au-u-hidden\"}}>\n <AuList @divider={{true}} as |Item|>\n {{yield Item}}\n </AuList>\n </div>\n </div>\n </div>\n </template>\n}\n"],"names":["Collapsible","Component","g","prototype","localCopy","i","expanded","_expanded","args","expandedInitially","toggle","newState","onToggle","n","action","setComponentTemplate","precompileTemplate","strictMode","scope","AuToolbar","on","AuButton","AuIcon","RemoveIcon","AddIcon","AuList"],"mappings":";;;;;;;;;;;;;;AAoCe,MAAMA,oBAAoBC,SAAA,CAAU;AAAA,EAAA;AAAAC,IAAAA,CAAA,MAAAC,SAAA,EAAA,WAAA,EAAA,CAChDC,SAAA,CAAU,eAAA,CAAA,CAAA,CAAA;AAAA;EAAA,UAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,WAAA,CAAA,EAAA,MAAA;EAEX,IAAIC,QAAAA,GAAW;IACb,OAAO,IAAI,CAACC,SAAS,IAAI,IAAI,CAACC,IAAI,CAACC,iBAAiB;AACtD,EAAA;AAGAC,EAAAA,MAAAA,GAAS;AACP,IAAA,MAAMC,QAAA,GAAW,CAAC,IAAI,CAACL,QAAQ;IAC/B,IAAI,CAACC,SAAS,GAAGI,QAAA;AACjB,IAAA,IAAI,CAACH,IAAI,CAACI,QAAQ,GAAGD,QAAA,CAAA;AACvB,EAAA;AAAA,EAAA;IAAAE,CAAA,CAAA,IAAA,CAAAV,SAAA,EAAA,QAAA,EAAA,CALCW,MAAA,CAAA,CAAA;AAAA;AAOD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"collapsible.js","sources":["../../src/components/collapsible.gts"],"sourcesContent":["import AuButton from '@appuniversum/ember-appuniversum/components/au-button';\nimport AuIcon from '@appuniversum/ember-appuniversum/components/au-icon';\nimport AuList, {\n type AuListSignature,\n} from '@appuniversum/ember-appuniversum/components/au-list';\nimport AuToolbar from '@appuniversum/ember-appuniversum/components/au-toolbar';\nimport { AddIcon } from '@appuniversum/ember-appuniversum/components/icons/add';\nimport { RemoveIcon } from '@appuniversum/ember-appuniversum/components/icons/remove';\nimport { on } from '@ember/modifier';\n\nimport { action } from '@ember/object';\nimport Component from '@glimmer/component';\nimport { localCopy } from 'tracked-toolbox';\ntype Args = {\n title: string;\n onToggle?: (expanded: boolean) => void;\n} & (\n | {\n /** @deprecated, use `expanded` instead */\n expandedInitially?: boolean;\n expanded: never;\n }\n | {\n /** @deprecated, use `expanded` instead */\n expandedInitially?: never;\n expanded?: boolean;\n }\n);\n\ntype CollapsibleSignature = {\n Args: Args;\n Element: HTMLDivElement;\n Blocks: {\n default: AuListSignature['Blocks']['default'];\n };\n};\nexport default class Collapsible extends Component<CollapsibleSignature> {\n @localCopy('args.expanded') _expanded?: boolean;\n\n get expanded() {\n return this._expanded ?? this.args.expandedInitially;\n }\n\n @action\n toggle() {\n const newState = !this.expanded;\n this._expanded = newState;\n this.args.onToggle?.(newState);\n }\n\n <template>\n <div class=\"say-editor-hints__insert\">\n <div\n class=\"au-c-accordion au-c-accordion--reverse au-c-accordion--border\"\n >\n <AuToolbar\n @nowrap={{true}}\n @reverse={{true}}\n {{on \"click\" this.toggle}}\n as |Group|\n >\n <Group>\n <div>\n <AuButton\n @skin=\"link\"\n aria-hidden=\"true\"\n {{! @glint-expect-error we should check if we can pass this attribute }}\n focusable=\"false\"\n aria-expanded=\"{{if this.expanded 'true' 'false'}}\"\n >\n {{@title}}\n </AuButton>\n </div>\n </Group>\n <Group>\n {{#if this.expanded}}\n <AuIcon\n @icon={{RemoveIcon}}\n @alignment=\"left\"\n @size=\"large\"\n @ariaHidden=\"true\"\n />\n <span class=\"au-u-hidden-visually\">\n Open accordion\n </span>\n {{else}}\n <AuIcon\n @icon={{AddIcon}}\n @alignment=\"left\"\n @size=\"large\"\n @ariaHidden=\"true\"\n />\n <span class=\"au-u-hidden-visually\">\n Sluit accordion\n </span>\n {{/if}}\n </Group>\n </AuToolbar>\n <div class={{if this.expanded \"au-c-accordion__content\" \"au-u-hidden\"}}>\n <AuList @divider={{true}} as |Item|>\n {{yield Item}}\n </AuList>\n </div>\n </div>\n </div>\n </template>\n}\n"],"names":["Collapsible","Component","g","prototype","localCopy","i","expanded","_expanded","args","expandedInitially","toggle","newState","onToggle","n","action","setComponentTemplate","precompileTemplate","strictMode","scope","AuToolbar","on","AuButton","AuIcon","RemoveIcon","AddIcon","AuList"],"mappings":";;;;;;;;;;;;;;AAoCe,MAAMA,oBAAoBC,SAAA,CAAU;AAAA,EAAA;AAAAC,IAAAA,CAAA,MAAAC,SAAA,EAAA,WAAA,EAAA,CAChDC,SAAA,CAAU,eAAA,CAAA,CAAA,CAAA;AAAA;EAAA,UAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,WAAA,CAAA,EAAA,MAAA;EAEX,IAAIC,QAAAA,GAAW;IACb,OAAO,IAAI,CAACC,SAAS,IAAI,IAAI,CAACC,IAAI,CAACC,iBAAiB;AACtD,EAAA;AAGAC,EAAAA,MAAAA,GAAS;AACP,IAAA,MAAMC,QAAA,GAAW,CAAC,IAAI,CAACL,QAAQ;IAC/B,IAAI,CAACC,SAAS,GAAGI,QAAA;AACjB,IAAA,IAAI,CAACH,IAAI,CAACI,QAAQ,GAAGD,QAAA,CAAA;AACvB,EAAA;AAAA,EAAA;IAAAE,CAAA,CAAA,IAAA,CAAAV,SAAA,EAAA,QAAA,EAAA,CALCW,MAAA,CAAA,CAAA;AAAA;AAOD,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,y1CAAA,EAuDA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,SAAA;QAAAC,EAAA;QAAAC,QAAA;QAAAC,MAAA;QAAAC,UAAA;QAAAC,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -57,6 +57,9 @@ class RdfaEditor extends Component {
|
|
|
57
57
|
get baseIRI() {
|
|
58
58
|
return this.args.baseIRI || window.document.baseURI;
|
|
59
59
|
}
|
|
60
|
+
get editable() {
|
|
61
|
+
return this.args.editable;
|
|
62
|
+
}
|
|
60
63
|
|
|
61
64
|
// We show the notification toaster unless told otherwise in the editor arguments
|
|
62
65
|
get notificationToaster() {
|
|
@@ -112,7 +115,10 @@ class RdfaEditor extends Component {
|
|
|
112
115
|
plugins,
|
|
113
116
|
nodeViews: this.args.nodeViews,
|
|
114
117
|
defaultAttrGenerators: this.args.defaultAttrGenerators,
|
|
115
|
-
keyMapOptions: this.args.keyMapOptions
|
|
118
|
+
keyMapOptions: this.args.keyMapOptions,
|
|
119
|
+
editable: () => {
|
|
120
|
+
return !(this.editable === false);
|
|
121
|
+
}
|
|
116
122
|
});
|
|
117
123
|
window.__PM = this.prosemirror;
|
|
118
124
|
window.__PC = new SayController(this.prosemirror);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.js","sources":["../../src/components/editor.ts"],"sourcesContent":["import { action } from '@ember/object';\nimport Component from '@glimmer/component';\nimport {\n createLogger,\n type Logger,\n} from '#root/utils/_private/logging-utils.ts';\nimport { tracked } from 'tracked-built-ins';\nimport SayEditor, { type PluginConfig } from '#root/core/say-editor.ts';\nimport type { NodeViewConstructor } from 'prosemirror-view';\nimport { Schema } from 'prosemirror-model';\nimport { getOwner } from '@ember/application';\nimport type Owner from '@ember/owner';\nimport type { DefaultAttrGenPuginOptions } from '#root/plugins/default-attribute-value-generation/index.ts';\nimport SayController from '#root/core/say-controller.ts';\nimport type { KeymapOptions } from '../core/keymap.ts';\nimport { deprecate } from '@ember/debug';\nimport { notificationPlugin } from '#root/plugins/notification/index.ts';\nimport { service } from '@ember/service';\nimport type {\n Notification,\n NotificationOptions,\n} from '#root/plugins/notification/index.ts';\nimport type IntlService from 'ember-intl/services/intl';\n\nexport interface RdfaEditorArgs {\n /**\n * callback that is called with an interface to the editor after editor init completed\n * @default 'default'\n * @public\n */\n rdfaEditorInit(editor: SayController): void;\n\n initializers?: Array<Promise<void>>;\n schema: Schema;\n baseIRI?: string;\n plugins?: PluginConfig;\n stealFocus?: boolean;\n nodeViews?: (controller: SayController) => {\n [node: string]: NodeViewConstructor;\n };\n defaultAttrGenerators?: DefaultAttrGenPuginOptions;\n keyMapOptions?: KeymapOptions;\n notificationCallback?: (notification: Notification) => void;\n notificationToaster?: boolean;\n}\n\n/**\n * RDFa editor\n *\n * This module contains all classes and components provided by the @lblod/ember-rdfa-editor addon.\n * The main entrypoint is the {{#crossLink \"RdfaEditorComponent\"}}{{/crossLink}}.\n * @module rdfa-editor\n * @main rdfa-editor\n */\n\n/**\n * RDFa editor component\n *\n * This component wraps around a {{#crossLink \"ContentEditableComponent\"}}{{/crossLink}}\n * and provides an architecture to interact with the document through plugins.\n * {{#crossLinkModule \"rdfa-editor\"}}rdfa-editor{{/crossLinkModule}}.\n * @module rdfa-editor\n * @class RdfaEditorComponent\n * @extends Component\n */\nexport default class RdfaEditor extends Component<RdfaEditorArgs> {\n @tracked controller: SayController | null = null;\n @service declare toaster: {\n notify: (\n message: string | undefined,\n title: string | undefined,\n options: NotificationOptions,\n ) => void;\n };\n @service declare intl: IntlService;\n\n private logger: Logger = createLogger(this.constructor.name);\n private prosemirror: SayEditor | null = null;\n\n get initializers() {\n return this.args.initializers || [];\n }\n\n get baseIRI() {\n return this.args.baseIRI || window.document.baseURI;\n }\n\n // We show the notification toaster unless told otherwise in the editor arguments\n get notificationToaster() {\n return this.args.notificationToaster === false ? false : true;\n }\n\n /**\n * Handle init of rawEditor\n *\n * @method handleRawEditorInit\n *\n * @param {Element} target the html element the editor will render into\n *\n * @private\n */\n @action\n async handleRawEditorInit(target: Element) {\n if (this.initializers.length) {\n await Promise.all(this.initializers);\n this.logger(`Awaited ${this.initializers.length} initializers.`);\n }\n\n if (this.args.keyMapOptions) {\n deprecate(\n '@keyMapOptions is deprecated. The behaviour of `selectBlockRdfaNode` is included by default.',\n false,\n {\n id: '@lblod/ember-rdfa-editor.editor.keyMapOptions-argument',\n until: '10.0.0',\n for: '@lblod/ember-rdfa-editor',\n since: {\n available: '9.6.0',\n enabled: '9.6.0',\n },\n },\n );\n }\n\n const notificationCallback =\n this.args.notificationCallback ??\n ((notification: Notification) =>\n this.toaster.notify(\n notification.message,\n notification.title,\n notification.options,\n ));\n let plugins: PluginConfig;\n const notificationPluginOptions = {\n notificationCallback: notificationCallback.bind(this),\n intl: this.intl,\n };\n if (Array.isArray(this.args.plugins)) {\n plugins = [\n ...this.args.plugins,\n notificationPlugin(notificationPluginOptions),\n ];\n } else if (this.args.plugins) {\n plugins = {\n plugins: [\n ...this.args.plugins.plugins,\n notificationPlugin(notificationPluginOptions),\n ],\n override: this.args.plugins.override,\n };\n } else {\n plugins = [notificationPlugin(notificationPluginOptions)];\n }\n\n this.prosemirror = new SayEditor({\n owner: getOwner(this) as Owner,\n target,\n schema: this.args.schema,\n baseIRI: this.baseIRI,\n plugins,\n nodeViews: this.args.nodeViews,\n defaultAttrGenerators: this.args.defaultAttrGenerators,\n keyMapOptions: this.args.keyMapOptions,\n });\n window.__PM = this.prosemirror;\n window.__PC = new SayController(this.prosemirror);\n this.controller = new SayController(this.prosemirror);\n if (this.args.rdfaEditorInit) {\n this.args.rdfaEditorInit(new SayController(this.prosemirror));\n }\n }\n}\n"],"names":["RdfaEditor","Component","g","prototype","tracked","i","service","logger","createLogger","constructor","name","prosemirror","initializers","args","baseIRI","window","document","baseURI","notificationToaster","handleRawEditorInit","target","length","Promise","all","keyMapOptions","deprecate","id","until","for","since","available","enabled","notificationCallback","notification","toaster","notify","message","title","options","plugins","notificationPluginOptions","bind","intl","Array","isArray","notificationPlugin","override","SayEditor","owner","getOwner","schema","nodeViews","defaultAttrGenerators","__PM","__PC","SayController","controller","rdfaEditorInit","n","action","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"editor.js","sources":["../../src/components/editor.ts"],"sourcesContent":["import { action } from '@ember/object';\nimport Component from '@glimmer/component';\nimport {\n createLogger,\n type Logger,\n} from '#root/utils/_private/logging-utils.ts';\nimport { tracked } from 'tracked-built-ins';\nimport SayEditor, { type PluginConfig } from '#root/core/say-editor.ts';\nimport type { NodeViewConstructor } from 'prosemirror-view';\nimport { Schema } from 'prosemirror-model';\nimport { getOwner } from '@ember/application';\nimport type Owner from '@ember/owner';\nimport type { DefaultAttrGenPuginOptions } from '#root/plugins/default-attribute-value-generation/index.ts';\nimport SayController from '#root/core/say-controller.ts';\nimport type { KeymapOptions } from '../core/keymap.ts';\nimport { deprecate } from '@ember/debug';\nimport { notificationPlugin } from '#root/plugins/notification/index.ts';\nimport { service } from '@ember/service';\nimport type {\n Notification,\n NotificationOptions,\n} from '#root/plugins/notification/index.ts';\nimport type IntlService from 'ember-intl/services/intl';\n\nexport interface RdfaEditorArgs {\n /**\n * callback that is called with an interface to the editor after editor init completed\n * @default 'default'\n * @public\n */\n rdfaEditorInit(editor: SayController): void;\n\n initializers?: Array<Promise<void>>;\n schema: Schema;\n baseIRI?: string;\n plugins?: PluginConfig;\n stealFocus?: boolean;\n nodeViews?: (controller: SayController) => {\n [node: string]: NodeViewConstructor;\n };\n defaultAttrGenerators?: DefaultAttrGenPuginOptions;\n keyMapOptions?: KeymapOptions;\n editable?: boolean;\n notificationCallback?: (notification: Notification) => void;\n notificationToaster?: boolean;\n}\n\n/**\n * RDFa editor\n *\n * This module contains all classes and components provided by the @lblod/ember-rdfa-editor addon.\n * The main entrypoint is the {{#crossLink \"RdfaEditorComponent\"}}{{/crossLink}}.\n * @module rdfa-editor\n * @main rdfa-editor\n */\n\n/**\n * RDFa editor component\n *\n * This component wraps around a {{#crossLink \"ContentEditableComponent\"}}{{/crossLink}}\n * and provides an architecture to interact with the document through plugins.\n * {{#crossLinkModule \"rdfa-editor\"}}rdfa-editor{{/crossLinkModule}}.\n * @module rdfa-editor\n * @class RdfaEditorComponent\n * @extends Component\n */\nexport default class RdfaEditor extends Component<RdfaEditorArgs> {\n @tracked controller: SayController | null = null;\n @service declare toaster: {\n notify: (\n message: string | undefined,\n title: string | undefined,\n options: NotificationOptions,\n ) => void;\n };\n @service declare intl: IntlService;\n\n private logger: Logger = createLogger(this.constructor.name);\n private prosemirror: SayEditor | null = null;\n\n get initializers() {\n return this.args.initializers || [];\n }\n\n get baseIRI() {\n return this.args.baseIRI || window.document.baseURI;\n }\n\n get editable() {\n return this.args.editable;\n }\n\n // We show the notification toaster unless told otherwise in the editor arguments\n get notificationToaster() {\n return this.args.notificationToaster === false ? false : true;\n }\n\n /**\n * Handle init of rawEditor\n *\n * @method handleRawEditorInit\n *\n * @param {Element} target the html element the editor will render into\n *\n * @private\n */\n @action\n async handleRawEditorInit(target: Element) {\n if (this.initializers.length) {\n await Promise.all(this.initializers);\n this.logger(`Awaited ${this.initializers.length} initializers.`);\n }\n\n if (this.args.keyMapOptions) {\n deprecate(\n '@keyMapOptions is deprecated. The behaviour of `selectBlockRdfaNode` is included by default.',\n false,\n {\n id: '@lblod/ember-rdfa-editor.editor.keyMapOptions-argument',\n until: '10.0.0',\n for: '@lblod/ember-rdfa-editor',\n since: {\n available: '9.6.0',\n enabled: '9.6.0',\n },\n },\n );\n }\n\n const notificationCallback =\n this.args.notificationCallback ??\n ((notification: Notification) =>\n this.toaster.notify(\n notification.message,\n notification.title,\n notification.options,\n ));\n let plugins: PluginConfig;\n const notificationPluginOptions = {\n notificationCallback: notificationCallback.bind(this),\n intl: this.intl,\n };\n if (Array.isArray(this.args.plugins)) {\n plugins = [\n ...this.args.plugins,\n notificationPlugin(notificationPluginOptions),\n ];\n } else if (this.args.plugins) {\n plugins = {\n plugins: [\n ...this.args.plugins.plugins,\n notificationPlugin(notificationPluginOptions),\n ],\n override: this.args.plugins.override,\n };\n } else {\n plugins = [notificationPlugin(notificationPluginOptions)];\n }\n\n this.prosemirror = new SayEditor({\n owner: getOwner(this) as Owner,\n target,\n schema: this.args.schema,\n baseIRI: this.baseIRI,\n plugins,\n nodeViews: this.args.nodeViews,\n defaultAttrGenerators: this.args.defaultAttrGenerators,\n keyMapOptions: this.args.keyMapOptions,\n editable: () => {\n return !(this.editable === false);\n },\n });\n window.__PM = this.prosemirror;\n window.__PC = new SayController(this.prosemirror);\n this.controller = new SayController(this.prosemirror);\n if (this.args.rdfaEditorInit) {\n this.args.rdfaEditorInit(new SayController(this.prosemirror));\n }\n }\n}\n"],"names":["RdfaEditor","Component","g","prototype","tracked","i","service","logger","createLogger","constructor","name","prosemirror","initializers","args","baseIRI","window","document","baseURI","editable","notificationToaster","handleRawEditorInit","target","length","Promise","all","keyMapOptions","deprecate","id","until","for","since","available","enabled","notificationCallback","notification","toaster","notify","message","title","options","plugins","notificationPluginOptions","bind","intl","Array","isArray","notificationPlugin","override","SayEditor","owner","getOwner","schema","nodeViews","defaultAttrGenerators","__PM","__PC","SayController","controller","rdfaEditorInit","n","action","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;;;AA+CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,MAAMA,UAAU,SAASC,SAAS,CAAiB;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CAC/DC,OAAO,CAAA,EAAA,YAAA;AAAA,MAAA,OAAoC,IAAI;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,WAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,YAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,SAAA,EAAA,CAC/CG,OAAO,CAAA,CAAA;AAAA;EAAA,QAAA,IAAAD,CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,MAAA,EAAA,CAOPG,OAAO,CAAA,CAAA;AAAA;EAAA,KAAA,IAAAD,CAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;EAEAE,MAAM,GAAWC,YAAY,CAAC,IAAI,CAACC,WAAW,CAACC,IAAI,CAAC;AACpDC,EAAAA,WAAW,GAAqB,IAAI;EAE5C,IAAIC,YAAYA,GAAG;AACjB,IAAA,OAAO,IAAI,CAACC,IAAI,CAACD,YAAY,IAAI,EAAE;AACrC,EAAA;EAEA,IAAIE,OAAOA,GAAG;IACZ,OAAO,IAAI,CAACD,IAAI,CAACC,OAAO,IAAIC,MAAM,CAACC,QAAQ,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9BI,MAAM,CAACwC,IAAI,GAAG,IAAIC,aAAa,CAAC,IAAI,CAAC7C,WAAW,CAAC;IACjD,IAAI,CAAC8C,UAAU,GAAG,IAAID,aAAa,CAAC,IAAI,CAAC7C,WAAW,CAAC;AACrD,IAAA,IAAI,IAAI,CAACE,IAAI,CAAC6C,cAAc,EAAE;AAC5B,MAAA,IAAI,CAAC7C,IAAI,CAAC6C,cAAc,CAAC,IAAIF,aAAa,CAAC,IAAI,CAAC7C,WAAW,CAAC,CAAC;AAC/D,IAAA;AACF,EAAA;AAAC,EAAA;IAAAgD,CAAA,CAAA,IAAA,CAAAxD,SAAA,EAAA,qBAAA,EAAA,CAxEAyD,MAAM,CAAA,CAAA;AAAA;AAyET;AAACC,oBAAA,CAAAC,QAAA,EAjHoB9D,UAAU,CAAA;;;;"}
|
|
@@ -2,7 +2,7 @@ import { action } from '@ember/object';
|
|
|
2
2
|
import { service } from '@ember/service';
|
|
3
3
|
import Component from '@glimmer/component';
|
|
4
4
|
import { v4 } from 'uuid';
|
|
5
|
-
import { redo, undo } from '
|
|
5
|
+
import { r as redo, u as undo } from '../../index-CxRqg5Kr.js';
|
|
6
6
|
import { isSome, unwrap } from '../../utils/_private/option.js';
|
|
7
7
|
import { lastKeyPressedPluginKey } from '../../plugins/last-key-pressed/index.js';
|
|
8
8
|
import { EditorState, NodeSelection, Selection, TextSelection } from 'prosemirror-state';
|
|
@@ -96,6 +96,9 @@ class EmbeddedEditor extends Component {
|
|
|
96
96
|
this.contentWrapper = target;
|
|
97
97
|
this.innerView = new SayView(this.contentWrapper, {
|
|
98
98
|
decorations: () => this.args.contentDecorations,
|
|
99
|
+
editable: () => {
|
|
100
|
+
return this.outerView.editable;
|
|
101
|
+
},
|
|
99
102
|
state: EditorState.create({
|
|
100
103
|
doc: this.node,
|
|
101
104
|
plugins: [keymap(this.keymap), ...this.plugins]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedded-editor.js","sources":["../../../src/components/ember-node/embedded-editor.ts"],"sourcesContent":["/**\n *\n * Based on the footnotes example from https://github.com/ProseMirror/website\n *\n * Copyright (C) 2015-2017 by Marijn Haverbeke <marijnh@gmail.com> and others\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\nimport { action } from '@ember/object';\nimport { service } from '@ember/service';\nimport Component from '@glimmer/component';\nimport type { EmberNodeArgs } from '#root/utils/ember-node.ts';\nimport type IntlService from 'ember-intl/services/intl';\nimport { v4 as uuid } from 'uuid';\nimport { redo, undo } from '#root/plugins/history/index.ts';\nimport { isSome, unwrap } from '#root/utils/_private/option.ts';\nimport { lastKeyPressedPluginKey } from '#root/plugins/last-key-pressed/index.ts';\nimport {\n EditorState,\n NodeSelection,\n Plugin,\n Selection,\n TextSelection,\n Transaction,\n type Command,\n} from 'prosemirror-state';\nimport { embeddedEditorBaseKeymap } from '#root/core/keymap.ts';\nimport SayView from '#root/core/say-view.ts';\nimport type { NodeViewConstructor } from 'prosemirror-view';\nimport { AttrStep, Step, StepMap } from 'prosemirror-transform';\nimport { keymap } from 'prosemirror-keymap';\n\ntype Args = EmberNodeArgs & {\n placeholder: string;\n initEditor?: (view: SayView) => void;\n /* override the keymap. */\n keymap?: { [key: string]: Command };\n /* editor plugins to add */\n plugins?: Plugin[];\n nodeViews?: {\n [node: string]: NodeViewConstructor;\n };\n onSelected?: (selected: boolean, innerState: EditorState) => void;\n};\n\n/**\n * An embedded editor to use for *inline* content. This way you can specify extra content for an\n * inline (atom) node. For block content, use content directly instead ({{yield}} in ember-nodes).\n */\nexport default class EmbeddedEditor extends Component<Args> {\n @service declare intl: IntlService;\n innerView: SayView | null = null;\n\n contentWrapper: Element | null = null;\n\n editorId = uuid();\n\n get outerView() {\n return this.args.view;\n }\n\n get node() {\n return this.args.node;\n }\n\n get schema() {\n return this.controller.schema;\n }\n\n get pos() {\n return this.args.getPos();\n }\n\n get controller() {\n return this.args.controller;\n }\n\n get plugins() {\n return this.args.plugins || [];\n }\n\n get keymap() {\n const undoRedoMap = {\n 'Mod-z': () =>\n undo(this.outerView.state, this.outerView.dispatch.bind(this)),\n 'Mod-Z': () =>\n undo(this.outerView.state, this.outerView.dispatch.bind(this)),\n 'Mod-y': () =>\n redo(this.outerView.state, this.outerView.dispatch.bind(this)),\n 'Mod-Y': () =>\n redo(this.outerView.state, this.outerView.dispatch.bind(this)),\n };\n\n if (this.args.keymap) {\n return {\n ...this.args.keymap,\n ...undoRedoMap,\n };\n } else {\n return { ...embeddedEditorBaseKeymap(this.schema), ...undoRedoMap };\n }\n }\n\n get nodeViews() {\n return this.outerView.props.nodeViews;\n }\n\n @action\n didInsertContentWrapper(target: Element) {\n this.contentWrapper = target;\n this.innerView = new SayView(\n this.contentWrapper,\n {\n decorations: () => this.args.contentDecorations,\n state: EditorState.create({\n doc: this.node,\n plugins: [keymap(this.keymap), ...this.plugins],\n // the schema is derived from 'doc' key and can't be customized\n }),\n attributes: {\n ...(this.args.placeholder && {\n 'data-placeholder': this.args.placeholder,\n }),\n },\n dispatchTransaction: this.dispatchInner,\n handleDOMEvents: {\n mousedown: () => {\n // Kludge to prevent issues due to the fact that the whole\n // footnote is node-selected (and thus DOM-selected) when\n // the parent editor is focused.\n\n if (this.outerView.hasFocus()) this.innerView?.focus();\n },\n focus: () => {\n const pos = this.pos;\n if (pos !== undefined) {\n const outerSelectionTr = this.outerView.state.tr;\n const outerSelection = new NodeSelection(\n this.outerView.state.doc.resolve(pos),\n );\n outerSelectionTr.setSelection(outerSelection);\n this.outerView.dispatch(outerSelectionTr);\n }\n\n if (this.innerView) {\n this.args.controller.setActiveView(this.innerView);\n }\n },\n },\n // These handlers are needed to fix part of a bug in Gecko (firefox): https://bugzilla.mozilla.org/show_bug.cgi?id=1612076\n handleKeyDown: ({ state: { selection, doc } }, event) => {\n if (selection.empty) {\n if (selection.from === 0) {\n // At the start of the embedded editor\n if (event.code === 'ArrowLeft' || event.code === 'Backspace') {\n this.outerView.focus();\n }\n if (event.code === 'Backspace' && doc.content.size !== 0) {\n // Prevent the deletion of the node as there is still content\n event.preventDefault();\n this.selectOutside('before');\n }\n }\n if (selection.from === doc.nodeSize - 2) {\n // At the end of the embedded editor\n if (event.code === 'ArrowRight' || event.code === 'Delete') {\n this.outerView.focus();\n }\n if (event.code === 'Delete' && doc.content.size !== 0) {\n // Prevent the deletion of the node as there is still content\n event.preventDefault();\n this.selectOutside('after');\n }\n }\n }\n },\n nodeViews: this.nodeViews,\n },\n this.outerView,\n );\n if (this.args.initEditor) {\n this.args.initEditor(this.innerView);\n }\n }\n\n @action\n onSelected(_: unknown, sel: [boolean]) {\n if (this.args.onSelected && this.innerView) {\n this.args.onSelected(sel[0], this.innerView.state);\n }\n if (this.args.selected && this.innerView) {\n const lastKeyPressedPluginState = lastKeyPressedPluginKey.getState(\n this.controller.mainEditorState,\n );\n\n const lastKeyPressed = lastKeyPressedPluginState?.lastKeyPressed;\n if (!this.innerView.hasFocus()) {\n this.innerView.dispatch(\n this.innerView.state.tr.setSelection(\n Selection[\n ['ArrowLeft', 'Backspace'].includes(lastKeyPressed ?? '')\n ? 'atEnd'\n : 'atStart'\n ](this.innerView.state.doc),\n ),\n );\n\n this.innerView.focus();\n }\n } else if (this.innerView) {\n const state = this.innerView.state;\n // De-select the inner node if we're no longer selected\n this.dispatchInner(\n state.tr.setSelection(TextSelection.create(state.doc, 0, 0)),\n );\n }\n }\n\n @action\n onNodeUpdate() {\n if (this.innerView) {\n const state = this.innerView.state;\n const start = this.node.content.findDiffStart(state.doc.content);\n const end = this.node.content.findDiffEnd(state.doc.content);\n const tr = state.tr;\n let trChanged = false;\n if (isSome(start) && isSome(end)) {\n let { a: endA, b: endB } = end;\n const overlap = start - Math.min(endA, endB);\n if (overlap > 0) {\n endA += overlap;\n endB += overlap;\n }\n tr.replace(start, endB, this.node.slice(start, endA)).setMeta(\n 'fromOutside',\n this.editorId,\n );\n trChanged = true;\n }\n // check if our top node has new attributes, and update the state\n // if so\n if (!this.node.hasMarkup(state.doc.type, state.doc.attrs)) {\n for (const [key, val] of Object.entries(this.node.attrs)) {\n tr.setDocAttribute(key, val);\n }\n\n tr.setMeta('fromOutside', this.editorId);\n trChanged = true;\n }\n if (trChanged) {\n this.innerView.dispatch(tr);\n }\n }\n }\n\n @action\n onDecorationsUpdate() {\n this.innerView?.dispatch(this.innerView.state.tr);\n }\n\n selectOutside(side: 'before' | 'after') {\n const selectionSide = side === 'after' ? '$head' : '$anchor';\n const outerState = this.outerView.state;\n this.outerView.dispatch(\n outerState.tr.setSelection(\n TextSelection.create(\n outerState.doc,\n outerState.selection[selectionSide].pos,\n ),\n ),\n );\n }\n\n dispatchInner = (tr: Transaction) => {\n const pos = this.pos;\n if (this.innerView && pos !== undefined) {\n const { state, transactions } = this.innerView.state.applyTransaction(tr);\n this.innerView.updateState(state);\n if (tr.getMeta('fromOutside') !== this.editorId) {\n const outerTr = this.outerView.state.tr,\n offsetMap = StepMap.offset(pos + 1);\n for (let i = 0; i < transactions.length; i++) {\n const steps = transactions[i].steps;\n for (let j = 0; j < steps.length; j++) {\n const step = steps[j];\n let mappedStep: Step;\n if (step instanceof AttrStep) {\n const mappedPos = offsetMap.mapResult(step.pos, 1);\n if (mappedPos.deleted) {\n throw new Error('Mapped position has been deleted');\n }\n mappedStep = new AttrStep(mappedPos.pos, step.attr, step.value);\n } else {\n mappedStep = unwrap(step.map(offsetMap));\n }\n outerTr.step(mappedStep);\n }\n }\n if (outerTr.docChanged) this.outerView.dispatch(outerTr);\n }\n }\n };\n\n willDestroy(): void {\n super.willDestroy();\n this.innerView?.destroy();\n this.innerView = null;\n }\n}\n"],"names":["EmbeddedEditor","Component","g","prototype","service","i","innerView","contentWrapper","editorId","uuid","outerView","args","view","node","schema","controller","pos","getPos","plugins","keymap","undoRedoMap","Mod-z","undo","state","dispatch","bind","Mod-Z","Mod-y","redo","Mod-Y","embeddedEditorBaseKeymap","nodeViews","props","didInsertContentWrapper","target","SayView","decorations","contentDecorations","EditorState","create","doc","attributes","placeholder","dispatchTransaction","dispatchInner","handleDOMEvents","mousedown","hasFocus","focus","undefined","outerSelectionTr","tr","outerSelection","NodeSelection","resolve","setSelection","setActiveView","handleKeyDown","selection","event","empty","from","code","content","size","preventDefault","selectOutside","nodeSize","initEditor","n","action","onSelected","_","sel","selected","lastKeyPressedPluginState","lastKeyPressedPluginKey","getState","mainEditorState","lastKeyPressed","Selection","includes","TextSelection","onNodeUpdate","start","findDiffStart","end","findDiffEnd","trChanged","isSome","a","endA","b","endB","overlap","Math","min","replace","slice","setMeta","hasMarkup","type","attrs","key","val","Object","entries","setDocAttribute","onDecorationsUpdate","side","selectionSide","outerState","transactions","applyTransaction","updateState","getMeta","outerTr","offsetMap","StepMap","offset","length","steps","j","step","mappedStep","AttrStep","mappedPos","mapResult","deleted","Error","attr","value","unwrap","map","docChanged","willDestroy","destroy","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAG,CAAChB,SAAS,CAAC,CAAC;AAC1C,YAAA;AACAD,YAAAA,OAAO,CAACO,IAAI,CAACC,UAAU,CAAC;AAC1B,UAAA;AACF,QAAA;QACA,IAAIR,OAAO,CAACkB,UAAU,EAAE,IAAI,CAAC5H,SAAS,CAACc,QAAQ,CAAC4F,OAAO,CAAC;AAC1D,MAAA;AACF,IAAA;EACF,CAAC;AAEDmB,EAAAA,WAAWA,GAAS;IAClB,KAAK,CAACA,WAAW,EAAE;AACnB,IAAA,IAAI,CAACjI,SAAS,EAAEkI,OAAO,EAAE;IACzB,IAAI,CAAClI,SAAS,GAAG,IAAI;AACvB,EAAA;AACF;AAACmI,oBAAA,CAAAC,QAAA,EAnQoB1I,cAAc,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"embedded-editor.js","sources":["../../../src/components/ember-node/embedded-editor.ts"],"sourcesContent":["/**\n *\n * Based on the footnotes example from https://github.com/ProseMirror/website\n *\n * Copyright (C) 2015-2017 by Marijn Haverbeke <marijnh@gmail.com> and others\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\nimport { action } from '@ember/object';\nimport { service } from '@ember/service';\nimport Component from '@glimmer/component';\nimport type { EmberNodeArgs } from '#root/utils/ember-node.ts';\nimport type IntlService from 'ember-intl/services/intl';\nimport { v4 as uuid } from 'uuid';\nimport { redo, undo } from '#root/plugins/history/index.ts';\nimport { isSome, unwrap } from '#root/utils/_private/option.ts';\nimport { lastKeyPressedPluginKey } from '#root/plugins/last-key-pressed/index.ts';\nimport {\n EditorState,\n NodeSelection,\n Plugin,\n Selection,\n TextSelection,\n Transaction,\n type Command,\n} from 'prosemirror-state';\nimport { embeddedEditorBaseKeymap } from '#root/core/keymap.ts';\nimport SayView from '#root/core/say-view.ts';\nimport type { NodeViewConstructor } from 'prosemirror-view';\nimport { AttrStep, Step, StepMap } from 'prosemirror-transform';\nimport { keymap } from 'prosemirror-keymap';\n\ntype Args = EmberNodeArgs & {\n placeholder: string;\n initEditor?: (view: SayView) => void;\n /* override the keymap. */\n keymap?: { [key: string]: Command };\n /* editor plugins to add */\n plugins?: Plugin[];\n nodeViews?: {\n [node: string]: NodeViewConstructor;\n };\n onSelected?: (selected: boolean, innerState: EditorState) => void;\n};\n\n/**\n * An embedded editor to use for *inline* content. This way you can specify extra content for an\n * inline (atom) node. For block content, use content directly instead ({{yield}} in ember-nodes).\n */\nexport default class EmbeddedEditor extends Component<Args> {\n @service declare intl: IntlService;\n innerView: SayView | null = null;\n\n contentWrapper: Element | null = null;\n\n editorId = uuid();\n\n get outerView() {\n return this.args.view;\n }\n\n get node() {\n return this.args.node;\n }\n\n get schema() {\n return this.controller.schema;\n }\n\n get pos() {\n return this.args.getPos();\n }\n\n get controller() {\n return this.args.controller;\n }\n\n get plugins() {\n return this.args.plugins || [];\n }\n\n get keymap() {\n const undoRedoMap = {\n 'Mod-z': () =>\n undo(this.outerView.state, this.outerView.dispatch.bind(this)),\n 'Mod-Z': () =>\n undo(this.outerView.state, this.outerView.dispatch.bind(this)),\n 'Mod-y': () =>\n redo(this.outerView.state, this.outerView.dispatch.bind(this)),\n 'Mod-Y': () =>\n redo(this.outerView.state, this.outerView.dispatch.bind(this)),\n };\n\n if (this.args.keymap) {\n return {\n ...this.args.keymap,\n ...undoRedoMap,\n };\n } else {\n return { ...embeddedEditorBaseKeymap(this.schema), ...undoRedoMap };\n }\n }\n\n get nodeViews() {\n return this.outerView.props.nodeViews;\n }\n\n @action\n didInsertContentWrapper(target: Element) {\n this.contentWrapper = target;\n this.innerView = new SayView(\n this.contentWrapper,\n {\n decorations: () => this.args.contentDecorations,\n editable: () => {\n return this.outerView.editable;\n },\n state: EditorState.create({\n doc: this.node,\n plugins: [keymap(this.keymap), ...this.plugins],\n // the schema is derived from 'doc' key and can't be customized\n }),\n attributes: {\n ...(this.args.placeholder && {\n 'data-placeholder': this.args.placeholder,\n }),\n },\n dispatchTransaction: this.dispatchInner,\n handleDOMEvents: {\n mousedown: () => {\n // Kludge to prevent issues due to the fact that the whole\n // footnote is node-selected (and thus DOM-selected) when\n // the parent editor is focused.\n\n if (this.outerView.hasFocus()) this.innerView?.focus();\n },\n focus: () => {\n const pos = this.pos;\n if (pos !== undefined) {\n const outerSelectionTr = this.outerView.state.tr;\n const outerSelection = new NodeSelection(\n this.outerView.state.doc.resolve(pos),\n );\n outerSelectionTr.setSelection(outerSelection);\n this.outerView.dispatch(outerSelectionTr);\n }\n\n if (this.innerView) {\n this.args.controller.setActiveView(this.innerView);\n }\n },\n },\n // These handlers are needed to fix part of a bug in Gecko (firefox): https://bugzilla.mozilla.org/show_bug.cgi?id=1612076\n handleKeyDown: ({ state: { selection, doc } }, event) => {\n if (selection.empty) {\n if (selection.from === 0) {\n // At the start of the embedded editor\n if (event.code === 'ArrowLeft' || event.code === 'Backspace') {\n this.outerView.focus();\n }\n if (event.code === 'Backspace' && doc.content.size !== 0) {\n // Prevent the deletion of the node as there is still content\n event.preventDefault();\n this.selectOutside('before');\n }\n }\n if (selection.from === doc.nodeSize - 2) {\n // At the end of the embedded editor\n if (event.code === 'ArrowRight' || event.code === 'Delete') {\n this.outerView.focus();\n }\n if (event.code === 'Delete' && doc.content.size !== 0) {\n // Prevent the deletion of the node as there is still content\n event.preventDefault();\n this.selectOutside('after');\n }\n }\n }\n },\n nodeViews: this.nodeViews,\n },\n this.outerView,\n );\n if (this.args.initEditor) {\n this.args.initEditor(this.innerView);\n }\n }\n\n @action\n onSelected(_: unknown, sel: [boolean]) {\n if (this.args.onSelected && this.innerView) {\n this.args.onSelected(sel[0], this.innerView.state);\n }\n if (this.args.selected && this.innerView) {\n const lastKeyPressedPluginState = lastKeyPressedPluginKey.getState(\n this.controller.mainEditorState,\n );\n\n const lastKeyPressed = lastKeyPressedPluginState?.lastKeyPressed;\n if (!this.innerView.hasFocus()) {\n this.innerView.dispatch(\n this.innerView.state.tr.setSelection(\n Selection[\n ['ArrowLeft', 'Backspace'].includes(lastKeyPressed ?? '')\n ? 'atEnd'\n : 'atStart'\n ](this.innerView.state.doc),\n ),\n );\n\n this.innerView.focus();\n }\n } else if (this.innerView) {\n const state = this.innerView.state;\n // De-select the inner node if we're no longer selected\n this.dispatchInner(\n state.tr.setSelection(TextSelection.create(state.doc, 0, 0)),\n );\n }\n }\n\n @action\n onNodeUpdate() {\n if (this.innerView) {\n const state = this.innerView.state;\n const start = this.node.content.findDiffStart(state.doc.content);\n const end = this.node.content.findDiffEnd(state.doc.content);\n const tr = state.tr;\n let trChanged = false;\n if (isSome(start) && isSome(end)) {\n let { a: endA, b: endB } = end;\n const overlap = start - Math.min(endA, endB);\n if (overlap > 0) {\n endA += overlap;\n endB += overlap;\n }\n tr.replace(start, endB, this.node.slice(start, endA)).setMeta(\n 'fromOutside',\n this.editorId,\n );\n trChanged = true;\n }\n // check if our top node has new attributes, and update the state\n // if so\n if (!this.node.hasMarkup(state.doc.type, state.doc.attrs)) {\n for (const [key, val] of Object.entries(this.node.attrs)) {\n tr.setDocAttribute(key, val);\n }\n\n tr.setMeta('fromOutside', this.editorId);\n trChanged = true;\n }\n if (trChanged) {\n this.innerView.dispatch(tr);\n }\n }\n }\n\n @action\n onDecorationsUpdate() {\n this.innerView?.dispatch(this.innerView.state.tr);\n }\n\n selectOutside(side: 'before' | 'after') {\n const selectionSide = side === 'after' ? '$head' : '$anchor';\n const outerState = this.outerView.state;\n this.outerView.dispatch(\n outerState.tr.setSelection(\n TextSelection.create(\n outerState.doc,\n outerState.selection[selectionSide].pos,\n ),\n ),\n );\n }\n\n dispatchInner = (tr: Transaction) => {\n const pos = this.pos;\n if (this.innerView && pos !== undefined) {\n const { state, transactions } = this.innerView.state.applyTransaction(tr);\n this.innerView.updateState(state);\n if (tr.getMeta('fromOutside') !== this.editorId) {\n const outerTr = this.outerView.state.tr,\n offsetMap = StepMap.offset(pos + 1);\n for (let i = 0; i < transactions.length; i++) {\n const steps = transactions[i].steps;\n for (let j = 0; j < steps.length; j++) {\n const step = steps[j];\n let mappedStep: Step;\n if (step instanceof AttrStep) {\n const mappedPos = offsetMap.mapResult(step.pos, 1);\n if (mappedPos.deleted) {\n throw new Error('Mapped position has been deleted');\n }\n mappedStep = new AttrStep(mappedPos.pos, step.attr, step.value);\n } else {\n mappedStep = unwrap(step.map(offsetMap));\n }\n outerTr.step(mappedStep);\n }\n }\n if (outerTr.docChanged) this.outerView.dispatch(outerTr);\n }\n }\n };\n\n willDestroy(): void {\n super.willDestroy();\n this.innerView?.destroy();\n this.innerView = null;\n }\n}\n"],"names":["EmbeddedEditor","Component","g","prototype","service","i","innerView","contentWrapper","editorId","uuid","outerView","args","view","node","schema","controller","pos","getPos","plugins","keymap","undoRedoMap","Mod-z","undo","state","dispatch","bind","Mod-Z","Mod-y","redo","Mod-Y","embeddedEditorBaseKeymap","nodeViews","props","didInsertContentWrapper","target","SayView","decorations","contentDecorations","editable","EditorState","create","doc","attributes","placeholder","dispatchTransaction","dispatchInner","handleDOMEvents","mousedown","hasFocus","focus","undefined","outerSelectionTr","tr","outerSelection","NodeSelection","resolve","setSelection","setActiveView","handleKeyDown","selection","event","empty","from","code","content","size","preventDefault","selectOutside","nodeSize","initEditor","n","action","onSelected","_","sel","selected","lastKeyPressedPluginState","lastKeyPressedPluginKey","getState","mainEditorState","lastKeyPressed","Selection","includes","TextSelection","onNodeUpdate","start","findDiffStart","end","findDiffEnd","trChanged","isSome","a","endA","b","endB","overlap","Math","min","replace","slice","setMeta","hasMarkup","type","attrs","key","val","Object","entries","setDocAttribute","onDecorationsUpdate","side","selectionSide","outerState","transactions","applyTransaction","updateState","getMeta","outerTr","offsetMap","StepMap","offset","length","steps","j","step","mappedStep","AttrStep","mappedPos","mapResult","deleted","Error","attr","value","unwrap","map","docChanged","willDestroy","destroy","setComponentTemplate","TEMPLATE"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACe,MAAMA,cAAc,SAASC,SAAS,CAAO;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,MAAA,EAAA,CACzDC,OAAO,CAAA,CAAA;AAAA;EAAA,KAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EAAA,MAAA;AACRC,EAAAA,SAAS,GAAmB,IAAI;AAEhCC,EAAAA,cAAc,GAAmB,IAAI;EAErCC,QAAQ,GAAGC,EAAI,EAAE;EAEjB,IAAIC,SAASA,GAAG;AACd,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,IAAI;AACvB,EAAA;EAEA,IAAIC,IAAIA,GAAG;AACT,IAAA,OAAO,IAAI,CAACF,IAAI,CAACE,IAAI;AACvB,EAAA;EAEA,IAAIC,MAAMA,GAAG;AACX,IAAA,OAAO,IAAI,CAACC,UAAU,CAACD,MAAM;AAC/B,EAAA;EAEA,IAAIE,GAAGA,GAAG;AACR,IAAA,OAAO,IAAI,CAACL,IAAI,CAACM,MAA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AAC5G,CAAC,CAAC,CAACqH,KAAK;AACnC,UAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,KAAK,CAACD,MAAM,EAAEE,CAAC,EAAE,EAAE;AACrC,YAAA,MAAMC,IAAI,GAAGF,KAAK,CAACC,CAAC,CAAC;AACrB,YAAA,IAAIE,UAAgB;YACpB,IAAID,IAAI,YAAYE,QAAQ,EAAE;cAC5B,MAAMC,SAAS,GAAGT,SAAS,CAACU,SAAS,CAACJ,IAAI,CAAC5G,GAAG,EAAE,CAAC,CAAC;cAClD,IAAI+G,SAAS,CAACE,OAAO,EAAE;AACrB,gBAAA,MAAM,IAAIC,KAAK,CAAC,kCAAkC,CAAC;AACrD,cAAA;AACAL,cAAAA,UAAU,GAAG,IAAIC,QAAQ,CAACC,SAAS,CAAC/G,GAAG,EAAE4G,IAAI,CAACO,IAAI,EAAEP,IAAI,CAACQ,KAAK,CAAC;AACjE,YAAA,CAAC,MAAM;cACLP,UAAU,GAAGQ,MAAM,CAACT,IAAI,CAACU,GAAG,CAAChB,SAAS,CAAC,CAAC;AAC1C,YAAA;AACAD,YAAAA,OAAO,CAACO,IAAI,CAACC,UAAU,CAAC;AAC1B,UAAA;AACF,QAAA;QACA,IAAIR,OAAO,CAACkB,UAAU,EAAE,IAAI,CAAC7H,SAAS,CAACc,QAAQ,CAAC6F,OAAO,CAAC;AAC1D,MAAA;AACF,IAAA;EACF,CAAC;AAEDmB,EAAAA,WAAWA,GAAS;IAClB,KAAK,CAACA,WAAW,EAAE;AACnB,IAAA,IAAI,CAAClI,SAAS,EAAEmI,OAAO,EAAE;IACzB,IAAI,CAACnI,SAAS,GAAG,IAAI;AACvB,EAAA;AACF;AAACoI,oBAAA,CAAAC,QAAA,EAtQoB3I,cAAc,CAAA;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { action } from '@ember/object';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
|
-
import { redo } from '
|
|
3
|
+
import { r as redo } from '../../../index-CxRqg5Kr.js';
|
|
4
4
|
import '../../../core/say-controller.js';
|
|
5
5
|
import { RedoIcon } from '@appuniversum/ember-appuniversum/components/icons/redo';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { action } from '@ember/object';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
|
-
import { undo } from '
|
|
3
|
+
import { u as undo } from '../../../index-CxRqg5Kr.js';
|
|
4
4
|
import '../../../core/say-controller.js';
|
|
5
5
|
import { UndoIcon } from '@appuniversum/ember-appuniversum/components/icons/undo';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
@@ -13,7 +13,7 @@ import '../../../utils/_private/constants.js';
|
|
|
13
13
|
import 'uuid';
|
|
14
14
|
import 'relative-to-absolute-iri';
|
|
15
15
|
import 'rdf-data-factory';
|
|
16
|
-
import '../../../main-
|
|
16
|
+
import '../../../main-DFf-0En3.js';
|
|
17
17
|
import '../../../config/rdfa.js';
|
|
18
18
|
import 'iter-tools';
|
|
19
19
|
import '../../../plugins/list/nodes/list-nodes.js';
|
|
@@ -12,7 +12,7 @@ import '../../../utils/_private/constants.js';
|
|
|
12
12
|
import 'uuid';
|
|
13
13
|
import 'relative-to-absolute-iri';
|
|
14
14
|
import 'rdf-data-factory';
|
|
15
|
-
import '../../../main-
|
|
15
|
+
import '../../../main-DFf-0En3.js';
|
|
16
16
|
import '../../../config/rdfa.js';
|
|
17
17
|
import 'iter-tools';
|
|
18
18
|
import '../../../plugins/list/nodes/list-nodes.js';
|
|
@@ -6,7 +6,7 @@ import 'prosemirror-model';
|
|
|
6
6
|
import 'uuid';
|
|
7
7
|
import 'relative-to-absolute-iri';
|
|
8
8
|
import 'rdf-data-factory';
|
|
9
|
-
import '../../main-
|
|
9
|
+
import '../../main-DFf-0En3.js';
|
|
10
10
|
import '../../core/say-data-factory/data-factory.js';
|
|
11
11
|
import '../../core/say-data-factory/default-graph.js';
|
|
12
12
|
import '../../config/rdfa.js';
|
package/dist/core/keymap.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { redo, undo } from '
|
|
1
|
+
import { r as redo, u as undo } from '../index-CxRqg5Kr.js';
|
|
2
2
|
import { liftListItem, sinkListItem, splitListItem } from 'prosemirror-schema-list';
|
|
3
3
|
import 'prosemirror-model';
|
|
4
4
|
import { chainCommands, deleteSelection, joinForward, selectTextblockEnd, selectTextblockStart, selectAll, exitCode, toggleMark, newlineInCode, createParagraphNear, splitBlock, joinBackward, liftEmptyBlock } from 'prosemirror-commands';
|
|
@@ -7,7 +7,7 @@ import '../utils/_private/constants.js';
|
|
|
7
7
|
import 'uuid';
|
|
8
8
|
import 'relative-to-absolute-iri';
|
|
9
9
|
import 'rdf-data-factory';
|
|
10
|
-
import '../main-
|
|
10
|
+
import '../main-DFf-0En3.js';
|
|
11
11
|
import './say-data-factory/data-factory.js';
|
|
12
12
|
import './say-data-factory/default-graph.js';
|
|
13
13
|
import '../config/rdfa.js';
|
package/dist/core/rdfa-types.js
CHANGED
|
@@ -3,7 +3,7 @@ import 'uuid';
|
|
|
3
3
|
import '../utils/_private/constants.js';
|
|
4
4
|
import 'relative-to-absolute-iri';
|
|
5
5
|
import 'rdf-data-factory';
|
|
6
|
-
import '../main-
|
|
6
|
+
import '../main-DFf-0En3.js';
|
|
7
7
|
import './say-data-factory/data-factory.js';
|
|
8
8
|
import './say-data-factory/default-graph.js';
|
|
9
9
|
import '../config/rdfa.js';
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
+
import { tracked } from '@glimmer/tracking';
|
|
2
|
+
import 'prosemirror-model';
|
|
3
|
+
import { EditorState, Selection } from 'prosemirror-state';
|
|
4
|
+
import { g as getHistoryStateId } from '../index-CxRqg5Kr.js';
|
|
1
5
|
import 'relative-to-absolute-iri';
|
|
2
6
|
import 'rdf-data-factory';
|
|
3
7
|
import '../utils/_private/constants.js';
|
|
4
8
|
import { unwrap } from '../utils/_private/option.js';
|
|
5
|
-
import '../main-
|
|
9
|
+
import '../main-DFf-0En3.js';
|
|
6
10
|
import './say-data-factory/data-factory.js';
|
|
7
11
|
import './say-data-factory/default-graph.js';
|
|
8
12
|
import '../config/rdfa.js';
|
|
9
|
-
import { EditorState, Selection } from 'prosemirror-state';
|
|
10
13
|
import 'iter-tools';
|
|
11
14
|
import { shallowEqual } from '../utils/_private/object-utils.js';
|
|
12
15
|
import { datastoreKey } from '../plugins/datastore/index.js';
|
|
13
16
|
import { selectionHasMarkEverywhere } from '../utils/_private/mark-utils.js';
|
|
14
17
|
import './say-view.js';
|
|
15
|
-
import { tracked } from '@glimmer/tracking';
|
|
16
|
-
import 'prosemirror-model';
|
|
17
18
|
import { htmlToDoc } from '../utils/_private/html-utils.js';
|
|
18
19
|
import { g, i } from 'decorator-transforms/runtime';
|
|
19
20
|
|
|
21
|
+
const ALREADY_SAVED = 'ALREADY_SAVED';
|
|
20
22
|
class SayController {
|
|
21
23
|
static {
|
|
22
24
|
g(this.prototype, "editor", [tracked]);
|
|
23
25
|
}
|
|
24
26
|
#editor = (i(this, "editor"), void 0);
|
|
27
|
+
static {
|
|
28
|
+
g(this.prototype, "savedStateId", [tracked]);
|
|
29
|
+
}
|
|
30
|
+
#savedStateId = (i(this, "savedStateId"), void 0);
|
|
25
31
|
constructor(pm) {
|
|
26
32
|
this.editor = pm;
|
|
27
33
|
}
|
|
@@ -49,6 +55,16 @@ class SayController {
|
|
|
49
55
|
get domParser() {
|
|
50
56
|
return this.mainEditorView.domParser;
|
|
51
57
|
}
|
|
58
|
+
get editable() {
|
|
59
|
+
return this.mainEditorView.editable;
|
|
60
|
+
}
|
|
61
|
+
setEditable(editable) {
|
|
62
|
+
this.mainEditorView.setProps({
|
|
63
|
+
editable: () => {
|
|
64
|
+
return editable;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
52
68
|
clone() {
|
|
53
69
|
return new SayController(this.editor);
|
|
54
70
|
}
|
|
@@ -59,6 +75,22 @@ class SayController {
|
|
|
59
75
|
this.editor.setActiveView(view);
|
|
60
76
|
}
|
|
61
77
|
|
|
78
|
+
/** Is the editor in the same state as the last time it was marked as clean */
|
|
79
|
+
get isDirty() {
|
|
80
|
+
if (!this.savedStateId) return true;
|
|
81
|
+
const stateId = getHistoryStateId(this.mainEditorState);
|
|
82
|
+
if (this.savedStateId === ALREADY_SAVED) {
|
|
83
|
+
// If we start in a saved state, then 'no history', i.e. undefined id, means we're not dirty
|
|
84
|
+
return !!stateId;
|
|
85
|
+
} else {
|
|
86
|
+
return this.savedStateId !== stateId;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Mark the history state at which the document will be considered 'clean' */
|
|
90
|
+
markClean() {
|
|
91
|
+
this.savedStateId = getHistoryStateId(this.mainEditorState);
|
|
92
|
+
}
|
|
93
|
+
|
|
62
94
|
/**
|
|
63
95
|
* Replaces the state (and current document) with a parsed version of the provided `html` string.
|
|
64
96
|
* This method creates a new `doc` node and parses it correctly based on the provided html.
|
|
@@ -66,8 +98,12 @@ class SayController {
|
|
|
66
98
|
*/
|
|
67
99
|
initialize(html, {
|
|
68
100
|
shouldFocus = true,
|
|
69
|
-
doNotClean = false
|
|
101
|
+
doNotClean = false,
|
|
102
|
+
startsDirty = false
|
|
70
103
|
} = {}) {
|
|
104
|
+
if (!startsDirty) {
|
|
105
|
+
this.savedStateId = ALREADY_SAVED;
|
|
106
|
+
}
|
|
71
107
|
const doc = htmlToDoc(html, {
|
|
72
108
|
schema: this.schema,
|
|
73
109
|
editorView: this.editor.mainView,
|
|
@@ -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 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","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;EAAA,OAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA;EAGRC,WAAWA,CAACC,EAAa,EAAE;IACzB,IAAI,CAACC,MAAM,GAAGD,EAAE;AAClB,EAAA;EAEA,IAAIE,oBAAoBA,GAAa;AACnC,IAAA,OAAOC,MAAM,CAACC,YAAY,CAACC,QAAQ,CAAC,IAAI,CAACJ,MAAM,CAACK,QAAQ,CAACC,KAAK,CAAC,CAAC,CAC7DC,YAAY;AACjB,EAAA;EAEA,IAAIC,cAAcA,GAAG;AACnB,IAAA,OAAO,IAAI,CAACR,MAAM,CAACK,QAAQ;AAC7B,EAAA;EAEA,IAAII,gBAAgBA,GAAG;AACrB,IAAA,OAAO,IAAI,CAACT,MAAM,CAACU,UAAU;AAC/B,EAAA;EAEA,IAAIC,eAAeA,GAAG;AACpB,IAAA,OAAO,IAAI,CAACX,MAAM,CAACK,QAAQ,CAACC,KAAK;AACnC,EAAA;EAEA,IAAIM,iBAAiBA,GAAG;AACtB,IAAA,OAAO,IAAI,CAACZ,MAAM,CAACU,UAAU,CAACJ,KAAK;AACrC,EAAA;EAEA,IAAIO,WAAWA,GAAW;AACxB,IAAA,OAAO,IAAI,CAACb,MAAM,CAACa,WAAW;AAChC,EAAA;EAEA,IAAIC,cAAcA,GAAY;AAC5B,IAAA,OAAO,CAAC,CAAC,IAAI,CAACL,gBAAgB,CAACM,MAAM;AACvC,EAAA;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IAAI,CAACd,KAAK,CAAC;AACvC,IAAA,IAAIoD,MAAM,EAAE;AACVtC,MAAAA,IAAI,CAACsB,QAAQ,CAACgB,MAAM,CAAC;AACvB,IAAA;AACF,EAAA;EAEA,IAAIC,SAASA,GAAa;AACxB,IAAA,OAAOzD,MAAM,CAACC,YAAY,CAACC,QAAQ,CAAC,IAAI,CAACO,eAAe,CAAC,CAAC,CAACgD,SAAS,EAAE;AACxE,EAAA;EAEA,IAAIhC,MAAMA,GAAW;AACnB,IAAA,OAAO,IAAI,CAAChB,eAAe,CAACgB,MAAM;AACpC,EAAA;EAEA,IAAIiC,KAAKA,GAAU;AACjB,IAAA,OAAO,IAAI,CAAC5D,MAAM,CAAC4D,KAAK;AAC1B,EAAA;EAEA,IAAIC,gBAAgBA,GAAG;AACrB,IAAA,OAAO,IAAI,CAACC,oBAAoB,CAAC,MAAM,CAAC;AAC1C,EAAA;EAEA,IAAID,gBAAgBA,CAACE,QAAgB,EAAE;AACrC,IAAA,IAAI,CAACC,oBAAoB,CAAC,MAAM,EAAED,QAAQ,CAAC;AAC7C,EAAA;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,IAAA,CAAC,CAAC;AACJ,EAAA;EAEAJ,oBAAoBA,CAAsBM,SAAiB,EAAE;IAC3D,OAAO,IAAI,CAACzD,eAAe,CAACc,GAAG,CAACqB,KAAK,CAACsB,SAAS,CAAC;AAClD,EAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"say-controller.js","sources":["../../src/core/say-controller.ts"],"sourcesContent":["import type Owner from '@ember/owner';\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 { getHistoryStateId } from 'prosemirror-history';\nimport { SayStore } from '#root/utils/_private/datastore/say-store.ts';\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 { htmlToDoc } from '#root/utils/_private/html-utils.ts';\n\nconst ALREADY_SAVED = 'ALREADY_SAVED';\n\nexport default class SayController {\n @tracked\n private readonly editor: SayEditor;\n @tracked\n private savedStateId?: string;\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 get editable() {\n return this.mainEditorView.editable;\n }\n\n setEditable(editable: boolean) {\n this.mainEditorView.setProps({\n editable: () => {\n return editable;\n },\n });\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 /** Is the editor in the same state as the last time it was marked as clean */\n get isDirty(): boolean {\n if (!this.savedStateId) return true;\n const stateId = getHistoryStateId(this.mainEditorState);\n if (this.savedStateId === ALREADY_SAVED) {\n // If we start in a saved state, then 'no history', i.e. undefined id, means we're not dirty\n return !!stateId;\n } else {\n return this.savedStateId !== stateId;\n }\n }\n /** Mark the history state at which the document will be considered 'clean' */\n markClean() {\n this.savedStateId = getHistoryStateId(this.mainEditorState);\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 startsDirty = false,\n }: Exclude<SetHtmlOptions, 'range'> = {},\n ) {\n if (!startsDirty) {\n this.savedStateId = ALREADY_SAVED;\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":["ALREADY_SAVED","SayController","g","prototype","tracked","i","constructor","pm","editor","externalContextStore","unwrap","datastoreKey","getState","mainView","state","contextStore","mainEditorView","activeEditorView","activeView","mainEditorState","activeEditorState","htmlContent","inEmbeddedView","parent","domParser","editable","setEditable","setProps","clone","focus","setActiveView","view","isDirty","savedStateId","stateId","getHistoryStateId","markClean","initialize","html","shouldFocus","doNotClean","startsDirty","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":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,aAAa,GAAG,eAAe;AAEtB,MAAMC,aAAa,CAAC;AAAA,EAAA;IAAAC,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,QAAA,EAAA,CAChCC,OAAO,CAAA,CAAA;AAAA;EAAA,OAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,QAAA,CAAA,EAAA,MAAA;AAAA,EAAA;IAAAH,CAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAEPC,OAAO,CAAA,CAAA;AAAA;EAAA,aAAA,IAAAC,CAAA,CAAA,IAAA,EAAA,cAAA,CAAA,EAAA,MA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MAAA,OAAOA,EAAE,CAACU,eAAe,CAACF,GAAG,EAAEC,KAAK,CAAC;AACvC,IAAA,CAAC,CAAC;AACJ,EAAA;EAEAJ,oBAAoBA,CAAsBM,SAAiB,EAAE;IAC3D,OAAO,IAAI,CAAClE,eAAe,CAACuB,GAAG,CAACqB,KAAK,CAACsB,SAAS,CAAC;AAClD,EAAA;AACF;;;;"}
|
|
@@ -7,9 +7,9 @@ class SayBlankNode {
|
|
|
7
7
|
constructor(value) {
|
|
8
8
|
this.value = value;
|
|
9
9
|
}
|
|
10
|
-
equals
|
|
10
|
+
equals(other) {
|
|
11
11
|
return !!other && other.termType === 'BlankNode' && other.value === this.value;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
toJSON() {
|
|
14
14
|
return {
|
|
15
15
|
termType: this.termType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blank-node.js","sources":["../../../src/core/say-data-factory/blank-node.ts"],"sourcesContent":["import type * as RDF from '@rdfjs/types';\nimport type { Option } from '#root/utils/_private/option.ts';\nimport type { SayTerm } from './term.ts';\n\n/**\n * A term that represents an RDF blank node with a label.\n */\nexport class SayBlankNode implements RDF.BlankNode {\n public readonly termType = 'BlankNode';\n public readonly value: string;\n\n public constructor(value: string) {\n this.value = value;\n }\n\n equals
|
|
1
|
+
{"version":3,"file":"blank-node.js","sources":["../../../src/core/say-data-factory/blank-node.ts"],"sourcesContent":["import type * as RDF from '@rdfjs/types';\nimport type { Option } from '#root/utils/_private/option.ts';\nimport type { SayTerm } from './term.ts';\n\n/**\n * A term that represents an RDF blank node with a label.\n */\nexport class SayBlankNode implements RDF.BlankNode {\n public readonly termType = 'BlankNode';\n public readonly value: string;\n\n public constructor(value: string) {\n this.value = value;\n }\n\n equals(other?: Option<SayTerm>) {\n return (\n !!other && other.termType === 'BlankNode' && other.value === this.value\n );\n }\n\n toJSON() {\n return {\n termType: this.termType,\n value: this.value,\n };\n }\n}\n"],"names":["SayBlankNode","termType","value","constructor","equals","other","toJSON"],"mappings":"AAIA;AACA;AACA;AACO,MAAMA,YAAY,CAA0B;AACjCC,EAAAA,QAAQ,GAAG,WAAW;EACtBC,KAAK;EAEdC,WAAWA,CAACD,KAAa,EAAE;IAChC,IAAI,CAACA,KAAK,GAAGA,KAAK;AACpB,EAAA;EAEAE,MAAMA,CAACC,KAAuB,EAAE;AAC9B,IAAA,OACE,CAAC,CAACA,KAAK,IAAIA,KAAK,CAACJ,QAAQ,KAAK,WAAW,IAAII,KAAK,CAACH,KAAK,KAAK,IAAI,CAACA,KAAK;AAE3E,EAAA;AAEAI,EAAAA,MAAMA,GAAG;IACP,OAAO;MACLL,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBC,KAAK,EAAE,IAAI,CAACA;KACb;AACH,EAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-graph.js","sources":["../../../src/core/say-data-factory/default-graph.ts"],"sourcesContent":["import type { Option } from '#root/utils/_private/option.ts';\nimport type * as RDF from '@rdfjs/types';\nimport type { SayTerm } from './term.ts';\n\n/**\n * A singleton term instance that represents the default graph.\n * It's only allowed to assign a DefaultGraph to the .graph property of a Quad.\n */\nexport class SayDefaultGraph implements RDF.DefaultGraph {\n public static INSTANCE = new SayDefaultGraph();\n\n public readonly termType = 'DefaultGraph';\n public readonly value = '';\n\n private constructor() {\n // Private constructor\n }\n\n equals
|
|
1
|
+
{"version":3,"file":"default-graph.js","sources":["../../../src/core/say-data-factory/default-graph.ts"],"sourcesContent":["import type { Option } from '#root/utils/_private/option.ts';\nimport type * as RDF from '@rdfjs/types';\nimport type { SayTerm } from './term.ts';\n\n/**\n * A singleton term instance that represents the default graph.\n * It's only allowed to assign a DefaultGraph to the .graph property of a Quad.\n */\nexport class SayDefaultGraph implements RDF.DefaultGraph {\n public static INSTANCE = new SayDefaultGraph();\n\n public readonly termType = 'DefaultGraph';\n public readonly value = '';\n\n private constructor() {\n // Private constructor\n }\n\n equals(other?: Option<SayTerm>) {\n return !!other && other.termType === 'DefaultGraph';\n }\n}\n"],"names":["SayDefaultGraph","INSTANCE","termType","value","constructor","equals","other"],"mappings":"AAIA;AACA;AACA;AACA;AACO,MAAMA,eAAe,CAA6B;AACvD,EAAA,OAAcC,QAAQ,GAAG,IAAID,eAAe,EAAE;AAE9BE,EAAAA,QAAQ,GAAG,cAAc;AACzBC,EAAAA,KAAK,GAAG,EAAE;AAElBC,EAAAA,WAAWA,GAAG;AACpB;AAAA,EAAA;EAGFC,MAAMA,CAACC,KAAuB,EAAE;IAC9B,OAAO,CAAC,CAACA,KAAK,IAAIA,KAAK,CAACJ,QAAQ,KAAK,cAAc;AACrD,EAAA;AACF;;;;"}
|
|
@@ -23,9 +23,9 @@ class SayLiteral {
|
|
|
23
23
|
this.datatype = SayLiteral.XSD_STRING;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
equals
|
|
26
|
+
equals(other) {
|
|
27
27
|
return !!other && other.termType === 'Literal' && other.value === this.value && other.language === this.language && this.datatype.equals(other.datatype);
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
toJSON() {
|
|
30
30
|
return {
|
|
31
31
|
termType: this.termType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"literal.js","sources":["../../../src/core/say-data-factory/literal.ts"],"sourcesContent":["import type * as RDF from '@rdfjs/types';\nimport { SayNamedNode } from './named-node.ts';\nimport type { Option } from '#root/utils/_private/option.ts';\nimport type { SayTerm } from './term.ts';\n\n/**\n * A term that represents an RDF literal, containing a string with an optional language tag or datatype.\n */\nexport class SayLiteral implements RDF.Literal {\n public readonly termType = 'Literal';\n public readonly value: string;\n public readonly language: string;\n public readonly datatype: RDF.NamedNode;\n\n public static readonly RDF_LANGUAGE_STRING: RDF.NamedNode = new SayNamedNode(\n 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString',\n );\n\n public static readonly XSD_STRING: RDF.NamedNode = new SayNamedNode(\n 'http://www.w3.org/2001/XMLSchema#string',\n );\n\n public constructor(\n value: string,\n languageOrDatatype?: string | RDF.NamedNode,\n ) {\n this.value = value;\n if (typeof languageOrDatatype === 'string') {\n this.language = languageOrDatatype;\n this.datatype = SayLiteral.RDF_LANGUAGE_STRING;\n } else if (languageOrDatatype) {\n this.language = '';\n this.datatype = languageOrDatatype;\n } else {\n this.language = '';\n this.datatype = SayLiteral.XSD_STRING;\n }\n }\n\n equals
|
|
1
|
+
{"version":3,"file":"literal.js","sources":["../../../src/core/say-data-factory/literal.ts"],"sourcesContent":["import type * as RDF from '@rdfjs/types';\nimport { SayNamedNode } from './named-node.ts';\nimport type { Option } from '#root/utils/_private/option.ts';\nimport type { SayTerm } from './term.ts';\n\n/**\n * A term that represents an RDF literal, containing a string with an optional language tag or datatype.\n */\nexport class SayLiteral implements RDF.Literal {\n public readonly termType = 'Literal';\n public readonly value: string;\n public readonly language: string;\n public readonly datatype: RDF.NamedNode;\n\n public static readonly RDF_LANGUAGE_STRING: RDF.NamedNode = new SayNamedNode(\n 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString',\n );\n\n public static readonly XSD_STRING: RDF.NamedNode = new SayNamedNode(\n 'http://www.w3.org/2001/XMLSchema#string',\n );\n\n public constructor(\n value: string,\n languageOrDatatype?: string | RDF.NamedNode,\n ) {\n this.value = value;\n if (typeof languageOrDatatype === 'string') {\n this.language = languageOrDatatype;\n this.datatype = SayLiteral.RDF_LANGUAGE_STRING;\n } else if (languageOrDatatype) {\n this.language = '';\n this.datatype = languageOrDatatype;\n } else {\n this.language = '';\n this.datatype = SayLiteral.XSD_STRING;\n }\n }\n\n equals(other?: Option<SayTerm>) {\n return (\n !!other &&\n other.termType === 'Literal' &&\n other.value === this.value &&\n other.language === this.language &&\n this.datatype.equals(other.datatype)\n );\n }\n\n toJSON() {\n return {\n termType: this.termType,\n value: this.value,\n language: this.language,\n datatype: {\n termType: this.datatype.termType,\n value: this.datatype.value,\n },\n };\n }\n}\n"],"names":["SayLiteral","termType","value","language","datatype","RDF_LANGUAGE_STRING","SayNamedNode","XSD_STRING","constructor","languageOrDatatype","equals","other","toJSON"],"mappings":";;AAKA;AACA;AACA;AACO,MAAMA,UAAU,CAAwB;AAC7BC,EAAAA,QAAQ,GAAG,SAAS;EACpBC,KAAK;EACLC,QAAQ;EACRC,QAAQ;AAExB,EAAA,OAAuBC,mBAAmB,GAAkB,IAAIC,YAAY,CAC1E,uDACF,CAAC;AAED,EAAA,OAAuBC,UAAU,GAAkB,IAAID,YAAY,CACjE,yCACF,CAAC;AAEME,EAAAA,WAAWA,CAChBN,KAAa,EACbO,kBAA2C,EAC3C;IACA,IAAI,CAACP,KAAK,GAAGA,KAAK;AAClB,IAAA,IAAI,OAAOO,kBAAkB,KAAK,QAAQ,EAAE;MAC1C,IAAI,CAACN,QAAQ,GAAGM,kBAAkB;AAClC,MAAA,IAAI,CAACL,QAAQ,GAAGJ,UAAU,CAACK,mBAAmB;IAChD,CAAC,MAAM,IAAII,kBAAkB,EAAE;MAC7B,IAAI,CAACN,QAAQ,GAAG,EAAE;MAClB,IAAI,CAACC,QAAQ,GAAGK,kBAAkB;AACpC,IAAA,CAAC,MAAM;MACL,IAAI,CAACN,QAAQ,GAAG,EAAE;AAClB,MAAA,IAAI,CAACC,QAAQ,GAAGJ,UAAU,CAACO,UAAU;AACvC,IAAA;AACF,EAAA;EAEAG,MAAMA,CAACC,KAAuB,EAAE;AAC9B,IAAA,OACE,CAAC,CAACA,KAAK,IACPA,KAAK,CAACV,QAAQ,KAAK,SAAS,IAC5BU,KAAK,CAACT,KAAK,KAAK,IAAI,CAACA,KAAK,IAC1BS,KAAK,CAACR,QAAQ,KAAK,IAAI,CAACA,QAAQ,IAChC,IAAI,CAACC,QAAQ,CAACM,MAAM,CAACC,KAAK,CAACP,QAAQ,CAAC;AAExC,EAAA;AAEAQ,EAAAA,MAAMA,GAAG;IACP,OAAO;MACLX,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBC,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBC,QAAQ,EAAE,IAAI,CAACA,QAAQ;AACvBC,MAAAA,QAAQ,EAAE;AACRH,QAAAA,QAAQ,EAAE,IAAI,CAACG,QAAQ,CAACH,QAAQ;AAChCC,QAAAA,KAAK,EAAE,IAAI,CAACE,QAAQ,CAACF;AACvB;KACD;AACH,EAAA;AACF;;;;"}
|
|
@@ -7,9 +7,9 @@ class SayNamedNode {
|
|
|
7
7
|
constructor(value) {
|
|
8
8
|
this.value = value;
|
|
9
9
|
}
|
|
10
|
-
equals
|
|
10
|
+
equals(other) {
|
|
11
11
|
return !!other && other.termType === 'NamedNode' && other.value === this.value;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
toJSON() {
|
|
14
14
|
return {
|
|
15
15
|
termType: this.termType,
|