@kineticdata/react 5.1.2 → 6.0.1
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/assets/task/icons/drag-handle.svg +3 -0
- package/assets/task/icons/plus_small.svg +2 -4
- package/lib/apis/agent/adapters.js +16 -12
- package/lib/apis/agent/bridges.js +54 -41
- package/lib/apis/agent/handlers.js +51 -38
- package/lib/apis/core/activity.js +19 -11
- package/lib/apis/core/attributeDefinitions.js +54 -46
- package/lib/apis/core/attributeDefinitions.test.js +47 -55
- package/lib/apis/core/authentication.js +58 -63
- package/lib/apis/core/backgroundJobs.js +38 -30
- package/lib/apis/core/bridgeModelAttributeMappings.js +42 -34
- package/lib/apis/core/bridgeModelAttributes.js +47 -37
- package/lib/apis/core/bridgeModelMappings.js +42 -34
- package/lib/apis/core/bridgeModelQualificationMappings.js +42 -34
- package/lib/apis/core/bridgeModelQualifications.js +42 -34
- package/lib/apis/core/bridgeModels.js +56 -46
- package/lib/apis/core/bridgeModels.test.js +64 -80
- package/lib/apis/core/bridgedresources.js +64 -72
- package/lib/apis/core/bridgedresources.test.js +33 -30
- package/lib/apis/core/categories.js +59 -52
- package/lib/apis/core/categories.test.js +36 -33
- package/lib/apis/core/fileResources.js +41 -33
- package/lib/apis/core/filestores.js +42 -34
- package/lib/apis/core/formTypes.js +50 -44
- package/lib/apis/core/forms.js +53 -49
- package/lib/apis/core/forms.test.js +60 -74
- package/lib/apis/core/kapps.js +45 -39
- package/lib/apis/core/kapps.test.js +45 -52
- package/lib/apis/core/logs.js +20 -16
- package/lib/apis/core/memberships.js +23 -20
- package/lib/apis/core/meta.js +31 -19
- package/lib/apis/core/notices.js +17 -9
- package/lib/apis/core/oauthClients.js +49 -45
- package/lib/apis/core/platformComponents.js +73 -57
- package/lib/apis/core/platformItems.js +22 -13
- package/lib/apis/core/profile.js +28 -21
- package/lib/apis/core/profile.test.js +20 -17
- package/lib/apis/core/securityPolicyDefinitions.js +48 -41
- package/lib/apis/core/securityPolicyDefinitions.test.js +50 -60
- package/lib/apis/core/space.js +23 -16
- package/lib/apis/core/space.test.js +31 -38
- package/lib/apis/core/submissions.js +213 -186
- package/lib/apis/core/submissions.test.js +39 -36
- package/lib/apis/core/teams.js +51 -44
- package/lib/apis/core/teams.test.js +42 -39
- package/lib/apis/core/translations.js +123 -130
- package/lib/apis/core/translations.test.js +278 -368
- package/lib/apis/core/users.js +56 -49
- package/lib/apis/core/users.test.js +42 -39
- package/lib/apis/core/version.js +20 -11
- package/lib/apis/core/webApis.js +42 -34
- package/lib/apis/core/webhooks.js +48 -41
- package/lib/apis/core/webhooks.test.js +50 -60
- package/lib/apis/core/webhooksJobs.js +30 -26
- package/lib/apis/core/workflows.js +52 -44
- package/lib/apis/http.js +121 -80
- package/lib/apis/http.test.js +137 -38
- package/lib/apis/index.js +506 -50
- package/lib/apis/system/index.js +363 -215
- package/lib/apis/task/index.js +294 -227
- package/lib/components/agent/bridge/BridgeForm.js +50 -50
- package/lib/components/agent/bridge/BridgeTable.js +16 -9
- package/lib/components/agent/filestore/FilestoreForm.js +49 -48
- package/lib/components/agent/filestore/FilestoreTable.js +16 -9
- package/lib/components/agent/handler/AgentHandlerForm.js +24 -27
- package/lib/components/agent/handler/AgentHandlerTable.js +17 -10
- package/lib/components/common/AttributeSelect.js +15 -9
- package/lib/components/common/BridgeSelect.js +48 -43
- package/lib/components/common/ComponentConfigContext.js +9 -2
- package/lib/components/common/ContentEditable.js +36 -60
- package/lib/components/common/FormSelect.js +70 -58
- package/lib/components/common/NodeSelect.js +23 -19
- package/lib/components/common/Scroller.js +24 -23
- package/lib/components/common/StaticSelect.js +57 -50
- package/lib/components/common/TableInput.js +54 -57
- package/lib/components/common/TeamSelect.js +42 -39
- package/lib/components/common/ToastContainer.js +170 -0
- package/lib/components/common/Typeahead.js +121 -138
- package/lib/components/common/UserSelect.js +42 -41
- package/lib/components/common/authentication/AuthInterceptor.js +15 -19
- package/lib/components/common/authentication/AuthInterceptor.test.js +46 -64
- package/lib/components/common/authentication/AuthenticationContainer.js +350 -454
- package/lib/components/common/authentication/RequestInterceptor.js +16 -19
- package/lib/components/common/code_input/CodeInput.js +92 -122
- package/lib/components/common/code_input/draftHelpers.js +96 -90
- package/lib/components/common/code_input/languageHelpers.js +49 -47
- package/lib/components/common/code_input/languageHelpers.test.js +21 -16
- package/lib/components/common/defaults/Toast.js +26 -0
- package/lib/components/common/defaults/index.js +13 -0
- package/lib/components/core/CoreFormModal.js +26 -24
- package/lib/components/core/CoreModal.js +37 -31
- package/lib/components/core/attribute_definition/AttributeDefinitionForm.js +24 -23
- package/lib/components/core/attribute_definition/AttributeDefinitionTable.js +25 -18
- package/lib/components/core/bridge_model/BridgeModelForm.js +27 -37
- package/lib/components/core/bridge_model/BridgeModelTable.js +17 -10
- package/lib/components/core/bridge_model_attribute/BridgeModelAttributeForm.js +17 -16
- package/lib/components/core/bridge_model_attribute/BridgeModelAttributeTable.js +25 -21
- package/lib/components/core/bridge_model_qualification/BridgeModelQualificationForm.js +20 -20
- package/lib/components/core/bridge_model_qualification/BridgeModelQualificationTable.js +27 -22
- package/lib/components/core/category/CategoryForm.js +22 -22
- package/lib/components/core/category/CategoryTable.js +28 -16
- package/lib/components/core/core_form/CoreForm.js +209 -285
- package/lib/components/core/core_form/CoreForm.test.js +12 -10
- package/lib/components/core/core_form/defaults/index.js +52 -44
- package/lib/components/core/core_form/globals.js +14 -5
- package/lib/components/core/field_definition/FieldDefinitionForm.js +23 -21
- package/lib/components/core/field_definition/FieldDefinitionTable.js +26 -15
- package/lib/components/core/file_resource/FileResourceForm.js +38 -37
- package/lib/components/core/file_resource/FileResourceTable.js +16 -12
- package/lib/components/core/form/FormForm.js +56 -61
- package/lib/components/core/form/FormTable.js +47 -33
- package/lib/components/core/form_type/FormTypeForm.js +14 -13
- package/lib/components/core/form_type/FormTypeTable.js +15 -9
- package/lib/components/core/i18n/I18n.js +54 -61
- package/lib/components/core/i18n/I18nContext.js +9 -2
- package/lib/components/core/i18n/I18nProvider.js +40 -43
- package/lib/components/core/i18n/Moment.js +40 -50
- package/lib/components/core/index_definition/IndexDefinitionForm.js +23 -24
- package/lib/components/core/index_definition/IndexDefinitionTable.js +31 -16
- package/lib/components/core/index_job/IndexJobTable.js +20 -15
- package/lib/components/core/kapp/KappForm.js +57 -58
- package/lib/components/core/kapp/KappTable.js +34 -44
- package/lib/components/core/log/LogTable.js +42 -34
- package/lib/components/core/oauth_client/OAuthClientForm.js +17 -17
- package/lib/components/core/oauth_client/OAuthClientTable.js +12 -8
- package/lib/components/core/platform_component/AgentComponentForm.js +15 -15
- package/lib/components/core/platform_component/AgentComponentTable.js +10 -5
- package/lib/components/core/platform_component/TaskComponentForm.js +14 -14
- package/lib/components/core/profile/ProfileForm.js +40 -39
- package/lib/components/core/security_definition/SecurityDefinitionForm.js +28 -25
- package/lib/components/core/security_definition/SecurityDefinitionTable.js +27 -17
- package/lib/components/core/space/SpaceForm.js +79 -90
- package/lib/components/core/submission/DatastoreSubmissionFilters.js +39 -40
- package/lib/components/core/submission/DatastoreSubmissionTable.js +37 -34
- package/lib/components/core/submission/FormSubmissionFilters.js +79 -75
- package/lib/components/core/submission/FormSubmissionTable.js +64 -39
- package/lib/components/core/submission/KappSubmissionTable.js +67 -48
- package/lib/components/core/submission/SubmissionForm.js +126 -55
- package/lib/components/core/submission/SubmissionTable.js +24 -20
- package/lib/components/core/submission/helpers.js +37 -33
- package/lib/components/core/submission/helpers.test.js +69 -20
- package/lib/components/core/team/TeamForm.js +24 -21
- package/lib/components/core/team/TeamTable.js +27 -16
- package/lib/components/core/translation/ContextForm.js +13 -10
- package/lib/components/core/translation/ContextTable.js +13 -10
- package/lib/components/core/translation/EntryForm.js +27 -24
- package/lib/components/core/translation/EntryTable.js +19 -16
- package/lib/components/core/translation/LocaleForm.js +16 -13
- package/lib/components/core/translation/LocaleTable.js +12 -8
- package/lib/components/core/user/UserForm.js +38 -37
- package/lib/components/core/user/UserTable.js +42 -20
- package/lib/components/core/webapi/WebApiForm.js +87 -80
- package/lib/components/core/webapi/WebApiTable.js +28 -17
- package/lib/components/core/webhook/WebhookForm.js +33 -32
- package/lib/components/core/webhook/WebhookTable.js +41 -29
- package/lib/components/core/webhook_job/WebhookJobTable.js +58 -35
- package/lib/components/form/Form.helpers.js +182 -108
- package/lib/components/form/Form.js +467 -524
- package/lib/components/form/Form.models.js +39 -24
- package/lib/components/form/FormState.js +8 -5
- package/lib/components/form/KitchenSinkForm.js +135 -4
- package/lib/components/form/defaults/AttributesField.js +48 -59
- package/lib/components/form/defaults/CheckboxField.js +14 -6
- package/lib/components/form/defaults/CodeField.js +15 -7
- package/lib/components/form/defaults/FormButtons.js +12 -4
- package/lib/components/form/defaults/FormError.js +12 -4
- package/lib/components/form/defaults/FormField.js +15 -7
- package/lib/components/form/defaults/FormLayout.js +12 -4
- package/lib/components/form/defaults/FormMultiField.js +15 -7
- package/lib/components/form/defaults/PasswordField.js +14 -6
- package/lib/components/form/defaults/RadioField.js +15 -7
- package/lib/components/form/defaults/SampleTeamsRolesFIeld.js +17 -9
- package/lib/components/form/defaults/SelectField.js +16 -8
- package/lib/components/form/defaults/SelectMultiField.js +15 -7
- package/lib/components/form/defaults/TableField.js +14 -6
- package/lib/components/form/defaults/TeamField.js +15 -7
- package/lib/components/form/defaults/TeamMultiField.js +15 -7
- package/lib/components/form/defaults/TextField.js +14 -6
- package/lib/components/form/defaults/TextMultiField.js +26 -28
- package/lib/components/form/defaults/UserField.js +15 -7
- package/lib/components/form/defaults/UserMultiField.js +15 -7
- package/lib/components/form/defaults/index.js +48 -41
- package/lib/components/form/tests/Form.test.js +568 -864
- package/lib/components/form/tests/components.js +15 -25
- package/lib/components/form/tests/helpers.test.js +35 -33
- package/lib/components/index.js +1034 -135
- package/lib/components/system/SystemBackgroundTasksTable.js +14 -10
- package/lib/components/system/SystemCassandraForm.js +98 -0
- package/lib/components/system/SystemElasticSearchForm.js +98 -0
- package/lib/components/system/SystemFilestoreForm.js +36 -28
- package/lib/components/system/SystemForm.js +19 -16
- package/lib/components/system/SystemIngressForm.js +85 -36
- package/lib/components/system/SystemSecurityForm.js +17 -14
- package/lib/components/system/SystemSmtpForm.js +13 -13
- package/lib/components/system/SystemTaskAdapterForm.js +49 -21
- package/lib/components/system/SystemTrustedCertificateForm.js +40 -0
- package/lib/components/system/SystemTrustedCertificatesTable.js +74 -0
- package/lib/components/system/SystemUserForm.js +15 -14
- package/lib/components/system/helpers.js +281 -98
- package/lib/components/system/helpers.test.js +16 -12
- package/lib/components/system/spaces/SystemSpaceForm.js +25 -24
- package/lib/components/system/spaces/SystemTenantForm.js +112 -68
- package/lib/components/system/spaces/SystemTenantTable.js +12 -8
- package/lib/components/table/Table.js +295 -227
- package/lib/components/table/Table.redux.js +339 -355
- package/lib/components/table/Table.redux.test.js +49 -47
- package/lib/components/table/Table.test.js +146 -132
- package/lib/components/table/defaults/BodyCell.js +12 -6
- package/lib/components/table/defaults/BodyRow.js +10 -4
- package/lib/components/table/defaults/BooleanFilter.js +17 -11
- package/lib/components/table/defaults/ColumnControl.js +26 -0
- package/lib/components/table/defaults/EmptyBodyRow.js +12 -6
- package/lib/components/table/defaults/FilterLayout.js +17 -11
- package/lib/components/table/defaults/Footer.js +11 -5
- package/lib/components/table/defaults/FooterCell.js +10 -4
- package/lib/components/table/defaults/FooterRow.js +10 -4
- package/lib/components/table/defaults/Header.js +10 -4
- package/lib/components/table/defaults/HeaderCell.js +16 -10
- package/lib/components/table/defaults/HeaderRow.js +10 -4
- package/lib/components/table/defaults/PaginationControl.js +18 -9
- package/lib/components/table/defaults/TableBody.js +10 -4
- package/lib/components/table/defaults/TableLayout.js +12 -6
- package/lib/components/table/defaults/TextFilter.js +16 -10
- package/lib/components/table/defaults/index.js +43 -33
- package/lib/components/task/builder/Connector.js +100 -111
- package/lib/components/task/builder/ConnectorForm.js +17 -11
- package/lib/components/task/builder/Node.js +101 -83
- package/lib/components/task/builder/NodeForm.js +30 -27
- package/lib/components/task/builder/NodeParametersForm.js +27 -24
- package/lib/components/task/builder/SvgCanvas.js +67 -96
- package/lib/components/task/builder/SvgText.js +19 -134
- package/lib/components/task/builder/TaskDefinitionConfigForm.js +27 -22
- package/lib/components/task/builder/TreeBuilder.js +140 -115
- package/lib/components/task/builder/builder.redux.js +311 -326
- package/lib/components/task/builder/constants.js +94 -45
- package/lib/components/task/builder/helpers.js +184 -173
- package/lib/components/task/builder/helpers.test.js +20 -18
- package/lib/components/task/builder/models.js +121 -98
- package/lib/components/task/category/TaskCategoryForm.js +31 -29
- package/lib/components/task/category/TaskCategoryTable.js +12 -8
- package/lib/components/task/common/UsageTable.js +16 -12
- package/lib/components/task/engine/EngineSettingsForm.js +13 -11
- package/lib/components/task/errors/RunErrorTable.js +50 -27
- package/lib/components/task/errors/SystemErrorsTable.js +13 -9
- package/lib/components/task/handlers/HandlerForm.js +55 -55
- package/lib/components/task/handlers/HandlerTable.js +35 -19
- package/lib/components/task/handlers/MissingHandlerTable.js +12 -8
- package/lib/components/task/policy_rule/PolicyRuleForm.js +33 -32
- package/lib/components/task/policy_rule/PolicyRuleTable.js +12 -8
- package/lib/components/task/runs/CreateManualTriggerForm.js +17 -15
- package/lib/components/task/runs/RunTable.js +45 -29
- package/lib/components/task/runs/RunTaskTable.js +10 -6
- package/lib/components/task/sources/SourceForm.js +47 -47
- package/lib/components/task/sources/SourceTable.js +29 -18
- package/lib/components/task/triggers/TriggerTable.js +71 -41
- package/lib/components/task/workflows/LinkedWorkflowForm.js +48 -54
- package/lib/components/task/workflows/LinkedWorkflowTable.js +46 -26
- package/lib/components/task/workflows/MissingRoutineTable.js +12 -8
- package/lib/components/task/workflows/WorkflowForm.js +49 -44
- package/lib/components/task/workflows/WorkflowTable.js +47 -29
- package/lib/helpers/SearchBuilder.js +73 -127
- package/lib/helpers/SearchBuilder.test.js +184 -175
- package/lib/helpers/index.js +116 -74
- package/lib/index.js +87 -38
- package/lib/reducer.js +11 -3
- package/lib/saga.js +42 -38
- package/lib/store.js +59 -35
- package/package.json +17 -29
- package/proxyhelper.js +122 -57
- package/assets/discussions/images/avi_128.png +0 -0
- package/assets/discussions/images/excel_128.png +0 -0
- package/assets/discussions/images/html_128.png +0 -0
- package/assets/discussions/images/illustrator_128.png +0 -0
- package/assets/discussions/images/indesign_128.png +0 -0
- package/assets/discussions/images/movie_128.png +0 -0
- package/assets/discussions/images/mpeg_128.png +0 -0
- package/assets/discussions/images/pdf_128.png +0 -0
- package/assets/discussions/images/photoshop_128.png +0 -0
- package/assets/discussions/images/powerpoint_128.png +0 -0
- package/assets/discussions/images/txt_128.png +0 -0
- package/assets/discussions/images/unknown_128.png +0 -0
- package/assets/discussions/images/word_128.png +0 -0
- package/assets/discussions/styles/_discussion.scss +0 -506
- package/lib/apis/discussions/index.js +0 -395
- package/lib/apis/socket/index.js +0 -77
- package/lib/apis/socket/socket.js +0 -350
- package/lib/apis/socket/socket.test.js +0 -90
- package/lib/apis/socket/timer.js +0 -45
- package/lib/apis/socket/timer.test.js +0 -51
- package/lib/apis/socket/topic.js +0 -185
- package/lib/apis/topics/index.js +0 -19
- package/lib/components/discussions/ChatInputForm.js +0 -424
- package/lib/components/discussions/DateBanner.js +0 -10
- package/lib/components/discussions/Discussion.js +0 -202
- package/lib/components/discussions/DiscussionForm.js +0 -227
- package/lib/components/discussions/InvitationForm.js +0 -107
- package/lib/components/discussions/MessageHistory.js +0 -110
- package/lib/components/discussions/MessagesByDate.js +0 -40
- package/lib/components/discussions/MessagesList.js +0 -30
- package/lib/components/discussions/MoreMessagesBanner.js +0 -26
- package/lib/components/discussions/ScrollHelper.js +0 -84
- package/lib/components/discussions/SystemMessage.js +0 -88
- package/lib/components/discussions/SystemMessageGroup.js +0 -15
- package/lib/components/discussions/UserMessage.js +0 -163
- package/lib/components/discussions/UserMessageGroup.js +0 -34
- package/lib/components/discussions/redux.js +0 -178
- package/lib/components/discussions/sagas.js +0 -500
- package/lib/helpers/discussions/canManage.js +0 -30
- package/lib/helpers/discussions/canManage.test.js +0 -69
- package/lib/helpers/discussions/generateSystemMessageContent.js +0 -131
- package/lib/helpers/discussions/generateSystemMessageContent.test.js +0 -450
- package/lib/models/discussions.js +0 -76
- package/lib/models/index.js +0 -1
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.traverseBindings = exports.startTypeahead = exports.selectTypeaheadItem = exports.select = exports.previousTypeaheadItem = exports.nextTypeaheadItem = exports.insertText = exports.getEntitiesImpl = exports.getEntities = exports.getCurrentIndentation = exports.findByEntityType = exports.closeTypeahead = exports.checkSelectionPosition = exports.checkSelectionEntities = exports.checkFocus = exports.applyFilter = exports.applyEntity = exports.apply = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
9
|
+
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toArray"));
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
11
|
+
var _draftJs = require("draft-js");
|
|
12
|
+
var _immutable = require("immutable");
|
|
13
|
+
// DOMAIN-SPECIFIC HELPERS
|
|
6
14
|
|
|
7
15
|
var filterEntity = {
|
|
8
16
|
type: 'typeahead-filter',
|
|
@@ -16,50 +24,48 @@ var selectionEntity = {
|
|
|
16
24
|
type: 'typeahead-selection',
|
|
17
25
|
mutability: 'IMMUTABLE'
|
|
18
26
|
};
|
|
19
|
-
|
|
20
27
|
var matches = function matches(searcher, text) {
|
|
21
28
|
return text.toLowerCase().indexOf(searcher.toLowerCase()) > -1;
|
|
22
29
|
};
|
|
23
|
-
|
|
24
|
-
export var nextTypeaheadItem = function nextTypeaheadItem(editorState) {
|
|
30
|
+
var nextTypeaheadItem = function nextTypeaheadItem(editorState) {
|
|
25
31
|
var filterEntity = getEntities(editorState).last();
|
|
26
32
|
var data = filterEntity.data;
|
|
27
33
|
var active = (data.active + 1) % data.options.size;
|
|
28
|
-
return applyEntity(
|
|
34
|
+
return applyEntity((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, filterEntity), {}, {
|
|
29
35
|
key: undefined,
|
|
30
|
-
data:
|
|
36
|
+
data: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, data), {}, {
|
|
31
37
|
active: active
|
|
32
38
|
})
|
|
33
39
|
}))(editorState);
|
|
34
40
|
};
|
|
35
|
-
|
|
41
|
+
exports.nextTypeaheadItem = nextTypeaheadItem;
|
|
42
|
+
var previousTypeaheadItem = function previousTypeaheadItem(editorState) {
|
|
36
43
|
var filterEntity = getEntities(editorState).last();
|
|
37
44
|
var data = filterEntity.data;
|
|
38
|
-
var n = data.options.size;
|
|
39
|
-
|
|
45
|
+
var n = data.options.size;
|
|
46
|
+
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
|
|
40
47
|
var active = ((data.active - 1) % n + n) % n;
|
|
41
|
-
return applyEntity(
|
|
48
|
+
return applyEntity((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, filterEntity), {}, {
|
|
42
49
|
key: undefined,
|
|
43
|
-
data:
|
|
50
|
+
data: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, data), {}, {
|
|
44
51
|
active: active
|
|
45
52
|
})
|
|
46
53
|
}))(editorState);
|
|
47
54
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
exports.previousTypeaheadItem = previousTypeaheadItem;
|
|
56
|
+
var traverseBindings = function traverseBindings(bindings, _ref) {
|
|
57
|
+
var _ref2 = (0, _toArray2["default"])(_ref),
|
|
58
|
+
head = _ref2[0],
|
|
59
|
+
tail = _ref2.slice(1);
|
|
53
60
|
return head ? traverseBindings(bindings.get(head).get('children'), tail) : bindings;
|
|
54
61
|
};
|
|
55
|
-
|
|
62
|
+
exports.traverseBindings = traverseBindings;
|
|
63
|
+
var checkSelectionEntities = function checkSelectionEntities(editorState) {
|
|
56
64
|
var entities = getEntities(editorState);
|
|
57
|
-
|
|
58
65
|
if (!entities.isEmpty()) {
|
|
59
66
|
var validEntities = entities.reduce(function (reduction, entity) {
|
|
60
67
|
return reduction.isEmpty() || entity.data.index === reduction.last().data.index + 1 ? reduction.push(entity) : reduction;
|
|
61
|
-
}, List());
|
|
62
|
-
|
|
68
|
+
}, (0, _immutable.List)());
|
|
63
69
|
if (validEntities.last().end !== entities.last().end) {
|
|
64
70
|
var start = validEntities.last().end;
|
|
65
71
|
var end = entities.last().end;
|
|
@@ -69,7 +75,7 @@ export var checkSelectionEntities = function checkSelectionEntities(editorState)
|
|
|
69
75
|
focus: end
|
|
70
76
|
}), insertText({
|
|
71
77
|
text: ' ',
|
|
72
|
-
entity:
|
|
78
|
+
entity: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, filterEntity), {}, {
|
|
73
79
|
data: {
|
|
74
80
|
index: index
|
|
75
81
|
}
|
|
@@ -84,37 +90,31 @@ export var checkSelectionEntities = function checkSelectionEntities(editorState)
|
|
|
84
90
|
}));
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
|
-
|
|
88
93
|
return editorState;
|
|
89
94
|
};
|
|
90
|
-
|
|
95
|
+
exports.checkSelectionEntities = checkSelectionEntities;
|
|
96
|
+
var applyFilter = function applyFilter(bindings) {
|
|
91
97
|
return function (editorState) {
|
|
92
98
|
var entities = getEntities(editorState);
|
|
93
|
-
|
|
94
99
|
if (!entities.isEmpty()) {
|
|
95
100
|
var selections = entities.rest().butLast().map(function (entity) {
|
|
96
101
|
return entity.text;
|
|
97
102
|
});
|
|
98
|
-
|
|
99
103
|
var _entities$last = entities.last(),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
end = _entities$last.end,
|
|
105
|
+
start = _entities$last.start,
|
|
106
|
+
filter = _entities$last.text,
|
|
107
|
+
index = _entities$last.data.index;
|
|
105
108
|
var options = traverseBindings(bindings, selections.toArray()).entrySeq().toList().filter(function (_ref3) {
|
|
106
|
-
var _ref4 =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
var _ref4 = (0, _slicedToArray2["default"])(_ref3, 1),
|
|
110
|
+
label = _ref4[0];
|
|
109
111
|
return matches(filter, label);
|
|
110
112
|
}).map(function (_ref5) {
|
|
111
|
-
var _ref6 =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
114
|
+
label = _ref6[0],
|
|
115
|
+
value = _ref6[1];
|
|
115
116
|
return value.set('label', label).toObject();
|
|
116
117
|
});
|
|
117
|
-
|
|
118
118
|
if (options.size === 0 && entities.size === 2) {
|
|
119
119
|
return closeTypeahead(editorState);
|
|
120
120
|
} else {
|
|
@@ -123,52 +123,49 @@ export var applyFilter = function applyFilter(bindings) {
|
|
|
123
123
|
options: options,
|
|
124
124
|
active: 0
|
|
125
125
|
};
|
|
126
|
-
return applyEntity(
|
|
126
|
+
return applyEntity((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, filterEntity), {}, {
|
|
127
127
|
start: start,
|
|
128
128
|
end: end,
|
|
129
129
|
data: data
|
|
130
130
|
}))(editorState);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
134
133
|
return editorState;
|
|
135
134
|
};
|
|
136
135
|
};
|
|
137
|
-
|
|
136
|
+
exports.applyFilter = applyFilter;
|
|
137
|
+
var checkSelectionPosition = function checkSelectionPosition(editorState) {
|
|
138
138
|
var entities = getEntities(editorState);
|
|
139
|
-
|
|
140
139
|
if (!entities.isEmpty()) {
|
|
141
140
|
var selection = editorState.getSelection();
|
|
142
141
|
var start = entities.first().start;
|
|
143
142
|
var end = entities.last().end;
|
|
144
|
-
|
|
145
143
|
if (selection.getStartOffset() <= start || selection.getEndOffset() >= end) {
|
|
146
144
|
return closeTypeahead(editorState);
|
|
147
145
|
}
|
|
148
146
|
}
|
|
149
|
-
|
|
150
147
|
return editorState;
|
|
151
148
|
};
|
|
152
|
-
|
|
149
|
+
exports.checkSelectionPosition = checkSelectionPosition;
|
|
150
|
+
var checkFocus = function checkFocus(editorState) {
|
|
153
151
|
var entities = getEntities(editorState);
|
|
154
|
-
|
|
155
152
|
if (!entities.isEmpty()) {
|
|
156
153
|
return editorState.getSelection().getHasFocus() ? editorState : closeTypeahead(editorState);
|
|
157
154
|
}
|
|
158
|
-
|
|
159
155
|
return editorState;
|
|
160
156
|
};
|
|
161
|
-
|
|
157
|
+
exports.checkFocus = checkFocus;
|
|
158
|
+
var startTypeahead = function startTypeahead(editorState) {
|
|
162
159
|
return apply(editorState, insertText({
|
|
163
160
|
text: '$',
|
|
164
|
-
entity:
|
|
161
|
+
entity: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, startEntity), {}, {
|
|
165
162
|
data: {
|
|
166
163
|
index: 0
|
|
167
164
|
}
|
|
168
165
|
})
|
|
169
166
|
}), insertText({
|
|
170
167
|
text: ' ',
|
|
171
|
-
entity:
|
|
168
|
+
entity: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, filterEntity), {}, {
|
|
172
169
|
data: {
|
|
173
170
|
index: 1
|
|
174
171
|
}
|
|
@@ -182,7 +179,8 @@ export var startTypeahead = function startTypeahead(editorState) {
|
|
|
182
179
|
}
|
|
183
180
|
}));
|
|
184
181
|
};
|
|
185
|
-
|
|
182
|
+
exports.startTypeahead = startTypeahead;
|
|
183
|
+
var closeTypeahead = function closeTypeahead(editorState) {
|
|
186
184
|
var entities = getEntities(editorState);
|
|
187
185
|
var start = entities.first().start;
|
|
188
186
|
var end = entities.last().end;
|
|
@@ -194,36 +192,35 @@ export var closeTypeahead = function closeTypeahead(editorState) {
|
|
|
194
192
|
text: text
|
|
195
193
|
}));
|
|
196
194
|
};
|
|
197
|
-
|
|
195
|
+
exports.closeTypeahead = closeTypeahead;
|
|
196
|
+
var selectTypeaheadItem = function selectTypeaheadItem(self) {
|
|
198
197
|
return function (label, value, selection) {
|
|
199
198
|
return function () {
|
|
200
199
|
// determine how the selected value should be wrapped based on the language of
|
|
201
200
|
// this CodeInput instance,
|
|
202
|
-
var text = self.props.language === 'js-template' ? "${".concat(value, "}") : self.props.language === 'erb' ? "<%= ".concat(value, " %>") : value;
|
|
201
|
+
var text = self.props.language === 'js-template' ? "${".concat(value, "}") : self.props.language === 'erb' ? "<%= ".concat(value, " %>") : value;
|
|
202
|
+
// when a selection is passed with a value we need to accommodate for the
|
|
203
203
|
// number of characters we add when we wrap the value
|
|
204
|
-
|
|
205
204
|
var templateOffset = self.props.language === 'js-template' ? 2 : self.props.language === 'erb' ? 4 : 0;
|
|
206
205
|
var entities = getEntities(self.state.editorState);
|
|
207
|
-
|
|
208
206
|
if (!value) {
|
|
209
207
|
var _entities$last2 = entities.last(),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
start = _entities$last2.start,
|
|
209
|
+
end = _entities$last2.end,
|
|
210
|
+
data = _entities$last2.data;
|
|
214
211
|
self.onChange(apply(self.state.editorState, select({
|
|
215
212
|
anchor: start,
|
|
216
213
|
focus: end
|
|
217
214
|
}), insertText({
|
|
218
215
|
text: label,
|
|
219
|
-
entity:
|
|
216
|
+
entity: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, selectionEntity), {}, {
|
|
220
217
|
data: {
|
|
221
218
|
index: data.index
|
|
222
219
|
}
|
|
223
220
|
})
|
|
224
221
|
}), insertText({
|
|
225
222
|
text: ' ',
|
|
226
|
-
entity:
|
|
223
|
+
entity: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, filterEntity), {}, {
|
|
227
224
|
data: {
|
|
228
225
|
index: data.index + 1
|
|
229
226
|
}
|
|
@@ -252,10 +249,12 @@ export var selectTypeaheadItem = function selectTypeaheadItem(self) {
|
|
|
252
249
|
};
|
|
253
250
|
};
|
|
254
251
|
};
|
|
255
|
-
|
|
252
|
+
exports.selectTypeaheadItem = selectTypeaheadItem;
|
|
253
|
+
var getEntities = function getEntities(editorState) {
|
|
256
254
|
return getEntitiesImpl(editorState.getCurrentContent().getFirstBlock(), editorState.getCurrentContent());
|
|
257
255
|
};
|
|
258
|
-
|
|
256
|
+
exports.getEntities = getEntities;
|
|
257
|
+
var getEntitiesImpl = function getEntitiesImpl(block, content) {
|
|
259
258
|
var text = block.getText();
|
|
260
259
|
var ranges = [];
|
|
261
260
|
block.findEntityRanges(function (character) {
|
|
@@ -272,10 +271,10 @@ export var getEntitiesImpl = function getEntitiesImpl(block, content) {
|
|
|
272
271
|
mutability: content.getEntity(key).getMutability()
|
|
273
272
|
});
|
|
274
273
|
});
|
|
275
|
-
return List(ranges).map(function (range, i) {
|
|
274
|
+
return (0, _immutable.List)(ranges).map(function (range, i) {
|
|
276
275
|
if (range.type === 'typeahead-filter') {
|
|
277
276
|
var start = i === 0 ? range.start : ranges[i - 1].end;
|
|
278
|
-
return
|
|
277
|
+
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, range), {}, {
|
|
279
278
|
start: start,
|
|
280
279
|
text: text.slice(start, range.end).replace(/\s$/, '')
|
|
281
280
|
});
|
|
@@ -283,66 +282,73 @@ export var getEntitiesImpl = function getEntitiesImpl(block, content) {
|
|
|
283
282
|
return range;
|
|
284
283
|
}
|
|
285
284
|
});
|
|
286
|
-
};
|
|
285
|
+
};
|
|
287
286
|
|
|
288
|
-
|
|
287
|
+
// SUPER GENERIC HELPERS
|
|
288
|
+
exports.getEntitiesImpl = getEntitiesImpl;
|
|
289
|
+
var apply = function apply(editorState) {
|
|
289
290
|
for (var _len = arguments.length, operations = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
290
291
|
operations[_key - 1] = arguments[_key];
|
|
291
292
|
}
|
|
292
|
-
|
|
293
293
|
return operations.filter(function (op) {
|
|
294
294
|
return !!op;
|
|
295
295
|
}).reduce(function (reduction, op) {
|
|
296
296
|
return op(reduction);
|
|
297
297
|
}, editorState);
|
|
298
298
|
};
|
|
299
|
-
|
|
299
|
+
exports.apply = apply;
|
|
300
|
+
var select = function select(_ref7) {
|
|
300
301
|
var anchor = _ref7.anchor,
|
|
301
|
-
|
|
302
|
+
focus = _ref7.focus;
|
|
302
303
|
return function (editorState) {
|
|
303
304
|
var selection0 = editorState.getSelection();
|
|
304
305
|
var selection1 = selection0.set('anchorOffset', typeof anchor === 'number' ? anchor : typeof anchor === 'function' ? anchor(selection0.getAnchorOffset()) : selection0.getAnchorOffset());
|
|
305
306
|
var selection2 = selection1.set('focusOffset', typeof focus === 'number' ? focus : typeof focus === 'function' ? focus(selection1.getFocusOffset()) : selection1.getFocusOffset());
|
|
306
|
-
return EditorState.forceSelection(editorState, selection2);
|
|
307
|
+
return _draftJs.EditorState.forceSelection(editorState, selection2);
|
|
307
308
|
};
|
|
308
309
|
};
|
|
309
|
-
|
|
310
|
+
exports.select = select;
|
|
311
|
+
var insertText = function insertText(_ref8) {
|
|
310
312
|
var text = _ref8.text,
|
|
311
|
-
|
|
313
|
+
entity = _ref8.entity;
|
|
312
314
|
return function (editorState) {
|
|
313
|
-
var modifier = editorState.getSelection().isCollapsed() ? Modifier.insertText : Modifier.replaceText;
|
|
315
|
+
var modifier = editorState.getSelection().isCollapsed() ? _draftJs.Modifier.insertText : _draftJs.Modifier.replaceText;
|
|
314
316
|
var contentState0 = editorState.getCurrentContent();
|
|
315
317
|
var contentState1 = entity ? contentState0.createEntity(entity.type, entity.mutability, entity.data) : contentState0;
|
|
316
318
|
var contentState2 = modifier(contentState1, editorState.getSelection(), text, null, entity ? contentState1.getLastCreatedEntityKey() : null);
|
|
317
|
-
return EditorState.push(editorState, contentState2, 'insert-characters', true);
|
|
319
|
+
return _draftJs.EditorState.push(editorState, contentState2, 'insert-characters', true);
|
|
318
320
|
};
|
|
319
321
|
};
|
|
320
|
-
|
|
322
|
+
exports.insertText = insertText;
|
|
323
|
+
var applyEntity = function applyEntity(_ref9) {
|
|
321
324
|
var data = _ref9.data,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
end = _ref9.end,
|
|
326
|
+
key = _ref9.key,
|
|
327
|
+
mutability = _ref9.mutability,
|
|
328
|
+
start = _ref9.start,
|
|
329
|
+
type = _ref9.type;
|
|
327
330
|
return function (editorState) {
|
|
328
331
|
var contentState0 = editorState.getCurrentContent();
|
|
329
332
|
var contentState1 = key ? contentState0 : contentState0.createEntity(type, mutability, data);
|
|
330
333
|
var entityKey = key || contentState1.getLastCreatedEntityKey();
|
|
331
334
|
var selection = editorState.getSelection().set('anchorOffset', start).set('focusOffset', end);
|
|
332
|
-
var contentState2 = Modifier.applyEntity(contentState1, selection, entityKey);
|
|
333
|
-
return EditorState.forceSelection(EditorState.push(editorState, contentState2, 'apply-entity'), editorState.getSelection());
|
|
335
|
+
var contentState2 = _draftJs.Modifier.applyEntity(contentState1, selection, entityKey);
|
|
336
|
+
return _draftJs.EditorState.forceSelection(_draftJs.EditorState.push(editorState, contentState2, 'apply-entity'), editorState.getSelection());
|
|
334
337
|
};
|
|
335
338
|
};
|
|
336
|
-
|
|
339
|
+
exports.applyEntity = applyEntity;
|
|
340
|
+
var findByEntityType = function findByEntityType(type) {
|
|
337
341
|
return function (contentBlock, callback, contentState) {
|
|
338
342
|
return contentBlock.findEntityRanges(function (_char) {
|
|
339
343
|
return _char.getEntity() ? contentState.getEntity(_char.getEntity()).getType() === type : false;
|
|
340
344
|
}, callback);
|
|
341
345
|
};
|
|
342
346
|
};
|
|
343
|
-
|
|
347
|
+
exports.findByEntityType = findByEntityType;
|
|
348
|
+
var getCurrentIndentation = function getCurrentIndentation(newLine, editorState) {
|
|
344
349
|
var text = editorState.getCurrentContent().getBlockForKey(editorState.getSelection().getStartKey()).getText();
|
|
345
350
|
var textBeforeCursor = text.slice(0, editorState.getSelection().getStartOffset());
|
|
346
351
|
var lineBeforeCursor = textBeforeCursor.slice(textBeforeCursor.lastIndexOf(newLine) + 1);
|
|
347
352
|
return lineBeforeCursor.replace(/\S.*$/, '');
|
|
348
|
-
};
|
|
353
|
+
};
|
|
354
|
+
exports.getCurrentIndentation = getCurrentIndentation;
|
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.processTemplate = exports.processRuby = exports.processJavaScriptTemplate = exports.processJavaScript = exports.processErbTemplate = exports.processCode = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
10
|
+
var _prismjs = _interopRequireDefault(require("prismjs"));
|
|
11
|
+
require("prismjs/components/prism-markup-templating.js");
|
|
12
|
+
require("prismjs/components/prism-ruby.js");
|
|
13
|
+
var _lodashEs = require("lodash-es");
|
|
8
14
|
var processToken = function processToken() {
|
|
9
15
|
for (var _len = arguments.length, parentTypes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
16
|
parentTypes[_key] = arguments[_key];
|
|
11
17
|
}
|
|
12
|
-
|
|
13
18
|
return function (token) {
|
|
14
|
-
if (isString(token)) {
|
|
19
|
+
if ((0, _lodashEs.isString)(token)) {
|
|
15
20
|
return [[token].concat(parentTypes)];
|
|
16
|
-
} else if (isString(token.content)) {
|
|
17
|
-
return isUndefined(token.type) ? [[token.content].concat(parentTypes)] : [[token.content, token.type].concat(parentTypes)];
|
|
18
|
-
} else if (isArray(token.content)) {
|
|
21
|
+
} else if ((0, _lodashEs.isString)(token.content)) {
|
|
22
|
+
return (0, _lodashEs.isUndefined)(token.type) ? [[token.content].concat(parentTypes)] : [[token.content, token.type].concat(parentTypes)];
|
|
23
|
+
} else if ((0, _lodashEs.isArray)(token.content)) {
|
|
19
24
|
return token.content.flatMap(processToken.apply(void 0, [token.type].concat(parentTypes)));
|
|
20
25
|
}
|
|
21
26
|
};
|
|
22
27
|
};
|
|
23
|
-
|
|
24
|
-
export var processCode = function processCode(language) {
|
|
28
|
+
var processCode = function processCode(language) {
|
|
25
29
|
return function (string) {
|
|
26
30
|
for (var _len2 = arguments.length, parentTypes = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
27
31
|
parentTypes[_key2 - 1] = arguments[_key2];
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
return Prism.tokenize(string, language).flatMap(processToken.apply(void 0, parentTypes));
|
|
33
|
+
return _prismjs["default"].tokenize(string, language).flatMap(processToken.apply(void 0, parentTypes));
|
|
31
34
|
};
|
|
32
35
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
exports.processCode = processCode;
|
|
37
|
+
var processJavaScript = processCode(_prismjs["default"].languages.javascript);
|
|
38
|
+
exports.processJavaScript = processJavaScript;
|
|
39
|
+
var processRuby = processCode(_prismjs["default"].languages.ruby);
|
|
40
|
+
exports.processRuby = processRuby;
|
|
36
41
|
var countLength = function countLength(tokens) {
|
|
37
42
|
return tokens.reduce(function (reduction, _ref) {
|
|
38
|
-
var _ref2 =
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
var _ref2 = (0, _slicedToArray2["default"])(_ref, 1),
|
|
44
|
+
tokenValue = _ref2[0];
|
|
41
45
|
return reduction + tokenValue.length;
|
|
42
46
|
}, 0);
|
|
43
47
|
};
|
|
44
|
-
|
|
45
48
|
var processEmbeddedRuby = function processEmbeddedRuby(string) {
|
|
46
49
|
var result = [[string.startsWith('<%=') ? '<%=' : '<%', 'opening-tag', 'erb']];
|
|
47
50
|
var rest = string.slice(result[0][0].length);
|
|
48
51
|
var done = false;
|
|
49
52
|
var foundPercent = null;
|
|
50
53
|
processRuby(rest, 'erb').forEach(function (token) {
|
|
51
|
-
var _token =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
var _token = (0, _slicedToArray2["default"])(token, 2),
|
|
55
|
+
content = _token[0],
|
|
56
|
+
type = _token[1];
|
|
55
57
|
if (!done) {
|
|
56
58
|
// Handle the check for closing tag. If the previous character was a %
|
|
57
59
|
// operator check to see if the current character is a > operator. If so
|
|
@@ -65,18 +67,19 @@ var processEmbeddedRuby = function processEmbeddedRuby(string) {
|
|
|
65
67
|
result.push(foundPercent);
|
|
66
68
|
foundPercent = null;
|
|
67
69
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
}
|
|
71
|
+
// Handle the current token.
|
|
71
72
|
if (!done) {
|
|
72
73
|
// If it is a % operator this may be the closing tag so we don't add
|
|
73
74
|
// it yet, set `foundPercent` and continue.
|
|
74
75
|
if (type === 'operator' && content === '%') {
|
|
75
|
-
foundPercent = token;
|
|
76
|
+
foundPercent = token;
|
|
77
|
+
// It may also be a string token with the %>foo> delimiter syntax, in
|
|
76
78
|
// this case we actually want to treat that as our closing tag.
|
|
77
79
|
} else if (type === 'string' && content.startsWith('%>')) {
|
|
78
80
|
result.push(['%>', 'closing-tag', 'erb']);
|
|
79
|
-
done = true;
|
|
81
|
+
done = true;
|
|
82
|
+
// Otherwise just add the token
|
|
80
83
|
} else {
|
|
81
84
|
result.push(token);
|
|
82
85
|
}
|
|
@@ -85,19 +88,17 @@ var processEmbeddedRuby = function processEmbeddedRuby(string) {
|
|
|
85
88
|
});
|
|
86
89
|
return result.concat(processErbTemplate(string.slice(countLength(result))));
|
|
87
90
|
};
|
|
88
|
-
|
|
89
91
|
var processInterpolation = function processInterpolation(string) {
|
|
90
92
|
var result = [['${', 'opening-interpolation', 'js-template']];
|
|
91
|
-
var rest = string.slice(2);
|
|
93
|
+
var rest = string.slice(2);
|
|
94
|
+
// track the number of opening curly braces, when the number of closing curly
|
|
92
95
|
// braces exceeds the opening ones we consider the interpolation completed
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
var curlyDepth = 0;
|
|
97
|
+
// use `some` instead of `forEach` so we can break early by returning true
|
|
96
98
|
processJavaScript(rest, 'js-template').some(function (token) {
|
|
97
|
-
var _token2 =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
var _token2 = (0, _slicedToArray2["default"])(token, 2),
|
|
100
|
+
content = _token2[0],
|
|
101
|
+
type = _token2[1];
|
|
101
102
|
if (content === '}' && type === 'punctuation' && curlyDepth === 0) {
|
|
102
103
|
result.push(['}', 'closing-interpolation', 'js-template']);
|
|
103
104
|
return true;
|
|
@@ -107,19 +108,20 @@ var processInterpolation = function processInterpolation(string) {
|
|
|
107
108
|
} else if (content === '}' && type === 'punctuation') {
|
|
108
109
|
curlyDepth--;
|
|
109
110
|
}
|
|
110
|
-
|
|
111
111
|
result.push(token);
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
return result.concat(processJavaScriptTemplate(string.slice(countLength(result))));
|
|
116
116
|
};
|
|
117
|
-
|
|
118
|
-
export var processTemplate = function processTemplate(openingString, processor) {
|
|
117
|
+
var processTemplate = function processTemplate(openingString, processor) {
|
|
119
118
|
return function (string) {
|
|
120
119
|
var openingIndex = string.indexOf(openingString);
|
|
121
|
-
return openingIndex > -1 ? [[string.slice(0, openingIndex)]].concat(
|
|
120
|
+
return openingIndex > -1 ? [[string.slice(0, openingIndex)]].concat((0, _toConsumableArray2["default"])(processor(string.slice(openingIndex)))) : [[string]];
|
|
122
121
|
};
|
|
123
122
|
};
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
exports.processTemplate = processTemplate;
|
|
124
|
+
var processErbTemplate = processTemplate('<%', processEmbeddedRuby);
|
|
125
|
+
exports.processErbTemplate = processErbTemplate;
|
|
126
|
+
var processJavaScriptTemplate = processTemplate('${', processInterpolation);
|
|
127
|
+
exports.processJavaScriptTemplate = processJavaScriptTemplate;
|